s3: Allow full_audit to play nice with smbd if it's using syslog
authortprouty <tprouty@b72e2a10-2d34-0410-9a71-d3beadf02b57>
Wed, 26 Aug 2009 01:38:14 +0000 (01:38 +0000)
committerTim Prouty <tprouty@samba.org>
Wed, 26 Aug 2009 17:41:54 +0000 (10:41 -0700)
Explictly pass the facility from both smbd and full_audit to syslog.
Really the only major change is to not call openlog() in full_audit if
WITH_SYSLOG is defined, which implies that smbd is already using
syslog.  This allows full audit to piggy-back on the same ident as
smbd, while still differentiating the logging via the facility.

source3/lib/debug.c
source3/modules/vfs_full_audit.c

index e7dcfb4fdf3f6b2e887224a7055f00612f5016b1..2e19f89863120cc8802dcbfadd29e7fb4f986780 100644 (file)
@@ -856,6 +856,12 @@ void check_log_size( void )
                else
                        priority = priority_map[syslog_level];
 
+               /*
+                * Specify the facility to interoperate with other syslog
+                * callers (vfs_full_audit for example).
+                */
+               priority |= SYSLOG_FACILITY;
+
                va_start(ap, format_str);
                ret = vasprintf(&msgbuf, format_str, ap);
                va_end(ap);
index 667db7a4bde14dd9a2083fdf041074b89301a86b..0f6de79bcfa1cdbc7dd995b348585630f39e4763 100644 (file)
@@ -510,6 +510,7 @@ static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
        char *audit_pre = NULL;
        va_list ap;
        char *op_msg = NULL;
+       int priority;
 
        if (success && (!log_success(handle, op)))
                goto out;
@@ -530,8 +531,15 @@ static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
                goto out;
        }
 
+       /*
+        * Specify the facility to interoperate with other syslog callers
+        * (smbd for example).
+        */
+       priority = audit_syslog_priority(handle) |
+           audit_syslog_facility(handle);
+
        audit_pre = audit_prefix(talloc_tos(), handle->conn);
-       syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
+       syslog(priority, "%s|%s|%s|%s\n",
                audit_pre ? audit_pre : "",
                audit_opname(op), err_msg, op_msg);
 
@@ -606,7 +614,9 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
        }
        ZERO_STRUCTP(pd);
 
+#ifndef WITH_SYSLOG
        openlog("smbd_audit", 0, audit_syslog_facility(handle));
+#endif
 
        init_bitmap(&pd->success_ops,
                    lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",