static void smb_full_audit_disconnect(vfs_handle_struct *handle);
static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
const char *path,
- BOOL small_query, SMB_BIG_UINT *bsize,
+ bool small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
enum SMB_QUOTA_TYPE qtype, unid_t id,
SMB_DISK_QUOTA *qt);
static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
+ SHADOW_COPY_DATA *shadow_copy_data, bool labels);
static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
const char *path,
struct vfs_statvfs_struct *statbuf);
static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
int fd, void *data, size_t n);
static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
- int fd, void *data, size_t n, SMB_OFF_T offset);
+ void *data, size_t n, SMB_OFF_T offset);
static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
int fd, const void *data, size_t n);
static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
- int fd, const void *data, size_t n,
+ const void *data, size_t n,
SMB_OFF_T offset);
static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
- int filedes, SMB_OFF_T offset, int whence);
+ SMB_OFF_T offset, int whence);
static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
files_struct *fsp, int fromfd,
const DATA_BLOB *hdr, SMB_OFF_T offset,
size_t n);
+static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
+ files_struct *fsp, int tofd,
+ SMB_OFF_T offset,
+ size_t n);
static int smb_full_audit_rename(vfs_handle_struct *handle,
const char *oldname, const char *newname);
static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd);
const char *path, const struct timespec ts[2]);
static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
int fd, SMB_OFF_T len);
-static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
+static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
struct files_struct *fsp, int fd,
uint32 share_mode);
static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
int fd, int leasetype);
-static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
+static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
static int smb_full_audit_symlink(vfs_handle_struct *handle,
const char *oldpath, const char *newpath);
struct notify_event *ev),
void *private_data, void *handle_p);
static int smb_full_audit_chflags(vfs_handle_struct *handle,
- const char *path, uint flags);
+ const char *path, unsigned int flags);
static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
SMB_DEV_T dev, SMB_INO_T inode);
-static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info,
+static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+ uint32 security_info,
SEC_DESC **ppdesc);
-static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
const char *name, uint32 security_info,
SEC_DESC **ppdesc);
static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info_sent,
+ uint32 security_info_sent,
SEC_DESC *psd);
static NTSTATUS smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
const char *name, uint32 security_info_sent,
SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
SMB_VFS_LAYER_LOGGER},
+ {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
+ SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
SMB_VFS_LAYER_LOGGER},
{SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
return priority;
}
-static char *audit_prefix(connection_struct *conn)
+static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
{
- static pstring prefix;
+ char *prefix = NULL;
- pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
+ prefix = talloc_strdup(ctx,
+ lp_parm_const_string(SNUM(conn), "full_audit",
"prefix", "%u|%I"));
- standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
- conn->connectpath, conn->gid,
- get_current_username(),
- current_user_info.domain,
- prefix, sizeof(prefix));
- return prefix;
+ if (!prefix) {
+ return NULL;
+ }
+ return talloc_sub_advanced(ctx,
+ lp_servicename(SNUM(conn)), conn->user,
+ conn->connectpath, conn->gid,
+ get_current_username(),
+ current_user_info.domain,
+ prefix);
}
-static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op)
+static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
{
struct vfs_full_audit_private_data *pd = NULL;
return bitmap_query(pd->success_ops, op);
}
-static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op)
+static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
{
struct vfs_full_audit_private_data *pd = NULL;
static void init_bitmap(struct bitmap **bm, const char **ops)
{
- BOOL log_all = False;
+ bool log_all = False;
if (*bm != NULL)
return;
while (*ops != NULL) {
int i;
- BOOL found = False;
+ bool found = False;
if (strequal(*ops, "all")) {
log_all = True;
return vfs_op_names[op].name;
}
-static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle,
+static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
const char *format, ...)
{
fstring err_msg;
- pstring op_msg;
+ char *audit_pre = NULL;
va_list ap;
+ char *op_msg = NULL;
if (success && (!log_success(handle, op)))
return;
fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
va_start(ap, format);
- vsnprintf(op_msg, sizeof(op_msg), format, ap);
+ op_msg = talloc_vasprintf(NULL, format, ap);
va_end(ap);
+ if (!op_msg) {
+ return;
+ }
+
+ audit_pre = audit_prefix(NULL, handle->conn);
syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
- audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
+ audit_pre ? audit_pre : "",
+ audit_opname(op), err_msg, op_msg);
+
+ TALLOC_FREE(audit_pre);
+ TALLOC_FREE(op_msg);
return;
}
static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
const char *path,
- BOOL small_query, SMB_BIG_UINT *bsize,
+ bool small_query, SMB_BIG_UINT *bsize,
SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
{
SMB_BIG_UINT result;
static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
struct files_struct *fsp,
- SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
+ SHADOW_COPY_DATA *shadow_copy_data, bool labels)
{
int result;
}
static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
- int fd, void *data, size_t n, SMB_OFF_T offset)
+ void *data, size_t n, SMB_OFF_T offset)
{
ssize_t result;
- result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
+ result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
}
static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
- int fd, const void *data, size_t n,
+ const void *data, size_t n,
SMB_OFF_T offset)
{
ssize_t result;
- result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
+ result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
}
static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
- int filedes, SMB_OFF_T offset, int whence)
+ SMB_OFF_T offset, int whence)
{
ssize_t result;
- result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
+ result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
"%s", fsp->fsp_name);
return result;
}
+static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
+ files_struct *fsp, int tofd,
+ SMB_OFF_T offset,
+ size_t n)
+{
+ ssize_t result;
+
+ result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, fsp, tofd,
+ offset, n);
+
+ do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
+ "%s", fsp->fsp_name);
+
+ return result;
+}
+
static int smb_full_audit_rename(vfs_handle_struct *handle,
const char *oldname, const char *newname)
{
return result;
}
-static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
+static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
{
- BOOL result;
+ bool result;
result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
- do_log(SMB_VFS_OP_LOCK, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
return result;
}
return result;
}
-static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
+static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
{
- BOOL result;
+ bool result;
result = SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid);
- do_log(SMB_VFS_OP_GETLOCK, (result >= 0), handle, "%s", fsp->fsp_name);
+ do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
return result;
}
}
static int smb_full_audit_chflags(vfs_handle_struct *handle,
- const char *path, uint flags)
+ const char *path, unsigned int flags)
{
int result;
return result;
}
-static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info,
+static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
+ uint32 security_info,
SEC_DESC **ppdesc)
{
- size_t result;
+ NTSTATUS result;
- result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info,
- ppdesc);
+ result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
- do_log(SMB_VFS_OP_FGET_NT_ACL, (result > 0), handle,
+ do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
"%s", fsp->fsp_name);
return result;
}
-static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- const char *name, uint32 security_info,
- SEC_DESC **ppdesc)
+static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
+ files_struct *fsp,
+ const char *name,
+ uint32 security_info,
+ SEC_DESC **ppdesc)
{
- size_t result;
+ NTSTATUS result;
- result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
- ppdesc);
+ result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
- do_log(SMB_VFS_OP_GET_NT_ACL, (result > 0), handle,
+ do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
"%s", fsp->fsp_name);
return result;
}
static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
- int fd, uint32 security_info_sent,
+ uint32 security_info_sent,
SEC_DESC *psd)
{
NTSTATUS result;
- result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent,
- psd);
+ result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);