📄 vfs_full_audit.c
字号:
ZERO_STRUCTP(pd); openlog("smbd_audit", 0, audit_syslog_facility(handle)); init_bitmap(&pd->success_ops, lp_parm_string_list(SNUM(conn), "full_audit", "success", none)); init_bitmap(&pd->failure_ops, lp_parm_string_list(SNUM(conn), "full_audit", "failure", all)); /* Store the private data. */ SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data, struct vfs_full_audit_private_data, return -1); result = SMB_VFS_NEXT_CONNECT(handle, conn, svc, user); do_log(SMB_VFS_OP_CONNECT, True, handle, "%s", svc); return result;}static void smb_full_audit_disconnect(vfs_handle_struct *handle, connection_struct *conn){ SMB_VFS_NEXT_DISCONNECT(handle, conn); do_log(SMB_VFS_OP_DISCONNECT, True, handle, "%s", lp_servicename(SNUM(conn))); /* The bitmaps will be disconnected when the private data is deleted. */ return;}static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle, connection_struct *conn, const char *path, BOOL small_query, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize){ SMB_BIG_UINT result; result = SMB_VFS_NEXT_DISK_FREE(handle, conn, path, small_query, bsize, dfree, dsize); /* Don't have a reasonable notion of failure here */ do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path); return result;}static int smb_full_audit_get_quota(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt){ int result; result = SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, qt); do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, ""); return result;} static int smb_full_audit_set_quota(struct vfs_handle_struct *handle, struct connection_struct *conn, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt){ int result; result = SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, qt); do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, ""); return 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){ int result; result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels); do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, ""); return result;}static int smb_full_audit_statvfs(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, struct vfs_statvfs_struct *statbuf){ int result; result = SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf); do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, ""); return result;}static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr){ SMB_STRUCT_DIR *result; result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname); return result;}static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp){ SMB_STRUCT_DIRENT *result; result = SMB_VFS_NEXT_READDIR(handle, conn, dirp); /* This operation has no reasonable error condition * (End of dir is also failure), so always succeed. */ do_log(SMB_VFS_OP_READDIR, True, handle, ""); return result;}static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp, long offset){ SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset); do_log(SMB_VFS_OP_SEEKDIR, True, handle, ""); return;}static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp){ long result; result = SMB_VFS_NEXT_TELLDIR(handle, conn, dirp); do_log(SMB_VFS_OP_TELLDIR, True, handle, ""); return result;}static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp){ SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp); do_log(SMB_VFS_OP_REWINDDIR, True, handle, ""); return;}static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode){ int result; result = SMB_VFS_NEXT_MKDIR(handle, conn, path, mode); do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path); return result;}static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path){ int result; result = SMB_VFS_NEXT_RMDIR(handle, conn, path); do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path); return result;}static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp){ int result; result = SMB_VFS_NEXT_CLOSEDIR(handle, conn, dirp); do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, ""); return result;}static int smb_full_audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode){ int result; result = SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode); do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s", ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r", fname); return result;}static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd){ int result; result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd); do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data, size_t n){ ssize_t result; result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n); do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name); return 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){ ssize_t result; result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset); do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n){ ssize_t result; result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n); do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data, size_t n, SMB_OFF_T offset){ ssize_t result; result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset); do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence){ ssize_t result; result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, 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_sendfile(vfs_handle_struct *handle, int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *hdr, SMB_OFF_T offset, size_t n){ ssize_t result; result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr, offset, n); do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn, const char *oldname, const char *newname){ int result; result = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname); do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname); return result; }static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd){ int result; result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd); do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name); return result; }static int smb_full_audit_stat(vfs_handle_struct *handle, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf){ int result; result = SMB_VFS_NEXT_STAT(handle, conn, fname, sbuf); do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname); return result; }static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf){ int result; result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name); return result;}static int smb_full_audit_lstat(vfs_handle_struct *handle, connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf){ int result; result = SMB_VFS_NEXT_LSTAT(handle, conn, path, sbuf); do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path); return result; }static int smb_full_audit_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *path){ int result; result = SMB_VFS_NEXT_UNLINK(handle, conn, path); do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path); return result;}static int smb_full_audit_chmod(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode){ int result; result = SMB_VFS_NEXT_CHMOD(handle, conn, path, mode); do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode); return result;}static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd, mode_t mode){ int result; result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode); do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle, "%s|%o", fsp->fsp_name, mode); return result;}static int smb_full_audit_chown(vfs_handle_struct *handle, connection_struct *conn, const char *path, uid_t uid, gid_t gid){ int result; result = SMB_VFS_NEXT_CHOWN(handle, conn, path, uid, gid); do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld", path, (long int)uid, (long int)gid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -