1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

vfs_full_audit: Add "full_audit:syslog"

Defaults to true (for compatibility)

With full_audit:syslog=false we DEBUG the messages with level 1.

You can explicitly [en|dis]able this with debug class full_audit:0/1

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2014-08-07 10:44:01 +00:00 committed by Jeremy Allison
parent b76bc4b713
commit 221afae9ae
2 changed files with 33 additions and 11 deletions

View File

@ -202,6 +202,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term>full_audit:syslog = true/false</term>
<listitem>
<para>Log messages to syslog (default) or as a debug level 1
message.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -75,6 +75,7 @@ struct vfs_full_audit_private_data {
struct bitmap *failure_ops;
int syslog_facility;
int syslog_priority;
bool do_syslog;
};
#undef DBGC_CLASS
@ -493,7 +494,6 @@ 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;
SMB_VFS_HANDLE_GET_DATA(handle, pd,
struct vfs_full_audit_private_data,
@ -518,17 +518,25 @@ 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 = pd->syslog_priority | pd->syslog_facility;
audit_pre = audit_prefix(talloc_tos(), handle->conn);
syslog(priority, "%s|%s|%s|%s\n",
audit_pre ? audit_pre : "",
audit_opname(op), err_msg, op_msg);
if (pd->do_syslog) {
int priority;
/*
* Specify the facility to interoperate with other syslog
* callers (smbd for example).
*/
priority = pd->syslog_priority | pd->syslog_facility;
syslog(priority, "%s|%s|%s|%s\n",
audit_pre ? audit_pre : "",
audit_opname(op), err_msg, op_msg);
} else {
DEBUG(1, ("%s|%s|%s|%s\n",
audit_pre ? audit_pre : "",
audit_opname(op), err_msg, op_msg));
}
out:
TALLOC_FREE(audit_pre);
TALLOC_FREE(op_msg);
@ -593,8 +601,13 @@ static int smb_full_audit_connect(vfs_handle_struct *handle,
pd->syslog_priority = audit_syslog_priority(handle);
pd->do_syslog = lp_parm_bool(SNUM(handle->conn),
"full_audit", "syslog", true);
#ifdef WITH_SYSLOG
openlog("smbd_audit", 0, pd->syslog_facility);
if (pd->do_syslog) {
openlog("smbd_audit", 0, pd->syslog_facility);
}
#endif
pd->success_ops = init_bitmap(