00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include "includes.h"
00062
00063 extern userdom_struct current_user_info;
00064
00065 static int vfs_full_audit_debug_level = DBGC_VFS;
00066
00067 struct vfs_full_audit_private_data {
00068 struct bitmap *success_ops;
00069 struct bitmap *failure_ops;
00070 };
00071
00072 #undef DBGC_CLASS
00073 #define DBGC_CLASS vfs_full_audit_debug_level
00074
00075
00076
00077 static int smb_full_audit_connect(vfs_handle_struct *handle,
00078 const char *svc, const char *user);
00079 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
00080 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
00081 const char *path,
00082 BOOL small_query, SMB_BIG_UINT *bsize,
00083 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
00084 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
00085 enum SMB_QUOTA_TYPE qtype, unid_t id,
00086 SMB_DISK_QUOTA *qt);
00087 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
00088 enum SMB_QUOTA_TYPE qtype, unid_t id,
00089 SMB_DISK_QUOTA *qt);
00090 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
00091 struct files_struct *fsp,
00092 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
00093 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
00094 const char *path,
00095 struct vfs_statvfs_struct *statbuf);
00096
00097 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
00098 const char *fname, const char *mask, uint32 attr);
00099 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
00100 SMB_STRUCT_DIR *dirp);
00101 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
00102 SMB_STRUCT_DIR *dirp, long offset);
00103 static long smb_full_audit_telldir(vfs_handle_struct *handle,
00104 SMB_STRUCT_DIR *dirp);
00105 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
00106 SMB_STRUCT_DIR *dirp);
00107 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
00108 const char *path, mode_t mode);
00109 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
00110 const char *path);
00111 static int smb_full_audit_closedir(vfs_handle_struct *handle,
00112 SMB_STRUCT_DIR *dirp);
00113 static int smb_full_audit_open(vfs_handle_struct *handle,
00114 const char *fname, files_struct *fsp, int flags, mode_t mode);
00115 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
00116 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
00117 int fd, void *data, size_t n);
00118 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
00119 int fd, void *data, size_t n, SMB_OFF_T offset);
00120 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
00121 int fd, const void *data, size_t n);
00122 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
00123 int fd, const void *data, size_t n,
00124 SMB_OFF_T offset);
00125 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
00126 int filedes, SMB_OFF_T offset, int whence);
00127 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
00128 files_struct *fsp, int fromfd,
00129 const DATA_BLOB *hdr, SMB_OFF_T offset,
00130 size_t n);
00131 static int smb_full_audit_rename(vfs_handle_struct *handle,
00132 const char *oldname, const char *newname);
00133 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd);
00134 static int smb_full_audit_stat(vfs_handle_struct *handle,
00135 const char *fname, SMB_STRUCT_STAT *sbuf);
00136 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
00137 SMB_STRUCT_STAT *sbuf);
00138 static int smb_full_audit_lstat(vfs_handle_struct *handle,
00139 const char *path, SMB_STRUCT_STAT *sbuf);
00140 static int smb_full_audit_unlink(vfs_handle_struct *handle,
00141 const char *path);
00142 static int smb_full_audit_chmod(vfs_handle_struct *handle,
00143 const char *path, mode_t mode);
00144 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
00145 mode_t mode);
00146 static int smb_full_audit_chown(vfs_handle_struct *handle,
00147 const char *path, uid_t uid, gid_t gid);
00148 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
00149 uid_t uid, gid_t gid);
00150 static int smb_full_audit_chdir(vfs_handle_struct *handle,
00151 const char *path);
00152 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
00153 char *path);
00154 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
00155 const char *path, const struct timespec ts[2]);
00156 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
00157 int fd, SMB_OFF_T len);
00158 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
00159 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
00160 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
00161 struct files_struct *fsp, int fd,
00162 uint32 share_mode);
00163 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
00164 int fd, int leasetype);
00165 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
00166 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
00167 static int smb_full_audit_symlink(vfs_handle_struct *handle,
00168 const char *oldpath, const char *newpath);
00169 static int smb_full_audit_readlink(vfs_handle_struct *handle,
00170 const char *path, char *buf, size_t bufsiz);
00171 static int smb_full_audit_link(vfs_handle_struct *handle,
00172 const char *oldpath, const char *newpath);
00173 static int smb_full_audit_mknod(vfs_handle_struct *handle,
00174 const char *pathname, mode_t mode, SMB_DEV_T dev);
00175 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
00176 const char *path, char *resolved_path);
00177 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
00178 struct sys_notify_context *ctx,
00179 struct notify_entry *e,
00180 void (*callback)(struct sys_notify_context *ctx,
00181 void *private_data,
00182 struct notify_event *ev),
00183 void *private_data, void *handle_p);
00184 static int smb_full_audit_chflags(vfs_handle_struct *handle,
00185 const char *path, uint flags);
00186 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
00187 int fd, uint32 security_info,
00188 SEC_DESC **ppdesc);
00189 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
00190 const char *name, uint32 security_info,
00191 SEC_DESC **ppdesc);
00192 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
00193 int fd, uint32 security_info_sent,
00194 SEC_DESC *psd);
00195 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
00196 const char *name, uint32 security_info_sent,
00197 SEC_DESC *psd);
00198 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
00199 const char *path, mode_t mode);
00200 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
00201 int fd, mode_t mode);
00202 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
00203 SMB_ACL_T theacl, int entry_id,
00204 SMB_ACL_ENTRY_T *entry_p);
00205 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
00206 SMB_ACL_ENTRY_T entry_d,
00207 SMB_ACL_TAG_T *tag_type_p);
00208 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
00209 SMB_ACL_ENTRY_T entry_d,
00210 SMB_ACL_PERMSET_T *permset_p);
00211 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
00212 SMB_ACL_ENTRY_T entry_d);
00213 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
00214 const char *path_p,
00215 SMB_ACL_TYPE_T type);
00216 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
00217 files_struct *fsp,
00218 int fd);
00219 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
00220 SMB_ACL_PERMSET_T permset);
00221 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
00222 SMB_ACL_PERMSET_T permset,
00223 SMB_ACL_PERM_T perm);
00224 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
00225 SMB_ACL_T theacl,
00226 ssize_t *plen);
00227 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
00228 int count);
00229 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
00230 SMB_ACL_T *pacl,
00231 SMB_ACL_ENTRY_T *pentry);
00232 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
00233 SMB_ACL_ENTRY_T entry,
00234 SMB_ACL_TAG_T tagtype);
00235 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
00236 SMB_ACL_ENTRY_T entry,
00237 void *qual);
00238 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
00239 SMB_ACL_ENTRY_T entry,
00240 SMB_ACL_PERMSET_T permset);
00241 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
00242 SMB_ACL_T theacl );
00243 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
00244 const char *name, SMB_ACL_TYPE_T acltype,
00245 SMB_ACL_T theacl);
00246 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
00247 int fd, SMB_ACL_T theacl);
00248 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
00249 const char *path);
00250 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
00251 SMB_ACL_PERMSET_T permset,
00252 SMB_ACL_PERM_T perm);
00253 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
00254 char *text);
00255 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
00256 SMB_ACL_T posix_acl);
00257 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
00258 void *qualifier,
00259 SMB_ACL_TAG_T tagtype);
00260 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
00261 const char *path,
00262 const char *name, void *value, size_t size);
00263 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
00264 const char *path, const char *name,
00265 void *value, size_t size);
00266 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
00267 struct files_struct *fsp, int fd,
00268 const char *name, void *value, size_t size);
00269 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
00270 const char *path, char *list, size_t size);
00271 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
00272 const char *path, char *list, size_t size);
00273 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
00274 struct files_struct *fsp, int fd, char *list,
00275 size_t size);
00276 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
00277 const char *path,
00278 const char *name);
00279 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
00280 const char *path,
00281 const char *name);
00282 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
00283 struct files_struct *fsp, int fd,
00284 const char *name);
00285 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
00286 const char *path,
00287 const char *name, const void *value, size_t size,
00288 int flags);
00289 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
00290 const char *path,
00291 const char *name, const void *value, size_t size,
00292 int flags);
00293 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
00294 struct files_struct *fsp, int fd, const char *name,
00295 const void *value, size_t size, int flags);
00296
00297 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
00298 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
00299 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
00300 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb);
00301 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
00302 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
00303 static int smb_full_audit_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *ts);
00304
00305
00306
00307 static vfs_op_tuple audit_op_tuples[] = {
00308
00309
00310
00311 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
00312 SMB_VFS_LAYER_LOGGER},
00313 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
00314 SMB_VFS_LAYER_LOGGER},
00315 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
00316 SMB_VFS_LAYER_LOGGER},
00317 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
00318 SMB_VFS_LAYER_LOGGER},
00319 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
00320 SMB_VFS_LAYER_LOGGER},
00321 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
00322 SMB_VFS_LAYER_LOGGER},
00323 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
00324 SMB_VFS_LAYER_LOGGER},
00325
00326
00327
00328 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
00329 SMB_VFS_LAYER_LOGGER},
00330 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
00331 SMB_VFS_LAYER_LOGGER},
00332 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
00333 SMB_VFS_LAYER_LOGGER},
00334 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
00335 SMB_VFS_LAYER_LOGGER},
00336 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
00337 SMB_VFS_LAYER_LOGGER},
00338 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
00339 SMB_VFS_LAYER_LOGGER},
00340 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
00341 SMB_VFS_LAYER_LOGGER},
00342 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
00343 SMB_VFS_LAYER_LOGGER},
00344
00345
00346
00347 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
00348 SMB_VFS_LAYER_LOGGER},
00349 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
00350 SMB_VFS_LAYER_LOGGER},
00351 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
00352 SMB_VFS_LAYER_LOGGER},
00353 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
00354 SMB_VFS_LAYER_LOGGER},
00355 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
00356 SMB_VFS_LAYER_LOGGER},
00357 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
00358 SMB_VFS_LAYER_LOGGER},
00359 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
00360 SMB_VFS_LAYER_LOGGER},
00361 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
00362 SMB_VFS_LAYER_LOGGER},
00363 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
00364 SMB_VFS_LAYER_LOGGER},
00365 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
00366 SMB_VFS_LAYER_LOGGER},
00367 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
00368 SMB_VFS_LAYER_LOGGER},
00369 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
00370 SMB_VFS_LAYER_LOGGER},
00371 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
00372 SMB_VFS_LAYER_LOGGER},
00373 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
00374 SMB_VFS_LAYER_LOGGER},
00375 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
00376 SMB_VFS_LAYER_LOGGER},
00377 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
00378 SMB_VFS_LAYER_LOGGER},
00379 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
00380 SMB_VFS_LAYER_LOGGER},
00381 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
00382 SMB_VFS_LAYER_LOGGER},
00383 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
00384 SMB_VFS_LAYER_LOGGER},
00385 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
00386 SMB_VFS_LAYER_LOGGER},
00387 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
00388 SMB_VFS_LAYER_LOGGER},
00389 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
00390 SMB_VFS_LAYER_LOGGER},
00391 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
00392 SMB_VFS_LAYER_LOGGER},
00393 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
00394 SMB_VFS_LAYER_LOGGER},
00395 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
00396 SMB_VFS_LAYER_LOGGER},
00397 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
00398 SMB_VFS_LAYER_LOGGER},
00399 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
00400 SMB_VFS_LAYER_LOGGER},
00401 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
00402 SMB_VFS_LAYER_LOGGER},
00403 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
00404 SMB_VFS_LAYER_LOGGER},
00405 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
00406 SMB_VFS_LAYER_LOGGER},
00407 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
00408 SMB_VFS_LAYER_LOGGER},
00409 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
00410 SMB_VFS_LAYER_LOGGER},
00411 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
00412 SMB_VFS_LAYER_LOGGER},
00413
00414
00415
00416 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
00417 SMB_VFS_LAYER_LOGGER},
00418 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
00419 SMB_VFS_LAYER_LOGGER},
00420 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
00421 SMB_VFS_LAYER_LOGGER},
00422 {SMB_VFS_OP(smb_full_audit_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
00423 SMB_VFS_LAYER_LOGGER},
00424
00425
00426
00427 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
00428 SMB_VFS_LAYER_LOGGER},
00429 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
00430 SMB_VFS_LAYER_LOGGER},
00431 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
00432 SMB_VFS_LAYER_LOGGER},
00433 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
00434 SMB_VFS_LAYER_LOGGER},
00435 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
00436 SMB_VFS_LAYER_LOGGER},
00437 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
00438 SMB_VFS_LAYER_LOGGER},
00439 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
00440 SMB_VFS_LAYER_LOGGER},
00441 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
00442 SMB_VFS_LAYER_LOGGER},
00443 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
00444 SMB_VFS_LAYER_LOGGER},
00445 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
00446 SMB_VFS_LAYER_LOGGER},
00447 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
00448 SMB_VFS_LAYER_LOGGER},
00449 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
00450 SMB_VFS_LAYER_LOGGER},
00451 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
00452 SMB_VFS_LAYER_LOGGER},
00453 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
00454 SMB_VFS_LAYER_LOGGER},
00455 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
00456 SMB_VFS_LAYER_LOGGER},
00457 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
00458 SMB_VFS_LAYER_LOGGER},
00459 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
00460 SMB_VFS_LAYER_LOGGER},
00461 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
00462 SMB_VFS_LAYER_LOGGER},
00463 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
00464 SMB_VFS_LAYER_LOGGER},
00465 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
00466 SMB_VFS_LAYER_LOGGER},
00467 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
00468 SMB_VFS_LAYER_LOGGER},
00469 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
00470 SMB_VFS_LAYER_LOGGER},
00471 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
00472 SMB_VFS_LAYER_LOGGER},
00473 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
00474 SMB_VFS_LAYER_LOGGER},
00475
00476
00477
00478 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
00479 SMB_VFS_LAYER_LOGGER},
00480 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
00481 SMB_VFS_LAYER_LOGGER},
00482 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
00483 SMB_VFS_LAYER_LOGGER},
00484 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
00485 SMB_VFS_LAYER_LOGGER},
00486 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
00487 SMB_VFS_LAYER_LOGGER},
00488 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
00489 SMB_VFS_LAYER_LOGGER},
00490 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
00491 SMB_VFS_LAYER_LOGGER},
00492 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
00493 SMB_VFS_LAYER_LOGGER},
00494 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
00495 SMB_VFS_LAYER_LOGGER},
00496 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
00497 SMB_VFS_LAYER_LOGGER},
00498 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
00499 SMB_VFS_LAYER_LOGGER},
00500 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
00501 SMB_VFS_LAYER_LOGGER},
00502
00503 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
00504 SMB_VFS_LAYER_LOGGER},
00505 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
00506 SMB_VFS_LAYER_LOGGER},
00507 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
00508 SMB_VFS_LAYER_LOGGER},
00509 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
00510 SMB_VFS_LAYER_LOGGER},
00511 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
00512 SMB_VFS_LAYER_LOGGER},
00513 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
00514 SMB_VFS_LAYER_LOGGER},
00515 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
00516 SMB_VFS_LAYER_LOGGER},
00517
00518
00519
00520 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
00521 SMB_VFS_LAYER_NOOP}
00522 };
00523
00524
00525
00526 static struct {
00527 vfs_op_type type;
00528 const char *name;
00529 } vfs_op_names[] = {
00530 { SMB_VFS_OP_CONNECT, "connect" },
00531 { SMB_VFS_OP_DISCONNECT, "disconnect" },
00532 { SMB_VFS_OP_DISK_FREE, "disk_free" },
00533 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
00534 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
00535 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
00536 { SMB_VFS_OP_STATVFS, "statvfs" },
00537 { SMB_VFS_OP_OPENDIR, "opendir" },
00538 { SMB_VFS_OP_READDIR, "readdir" },
00539 { SMB_VFS_OP_SEEKDIR, "seekdir" },
00540 { SMB_VFS_OP_TELLDIR, "telldir" },
00541 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
00542 { SMB_VFS_OP_MKDIR, "mkdir" },
00543 { SMB_VFS_OP_RMDIR, "rmdir" },
00544 { SMB_VFS_OP_CLOSEDIR, "closedir" },
00545 { SMB_VFS_OP_OPEN, "open" },
00546 { SMB_VFS_OP_CLOSE, "close" },
00547 { SMB_VFS_OP_READ, "read" },
00548 { SMB_VFS_OP_PREAD, "pread" },
00549 { SMB_VFS_OP_WRITE, "write" },
00550 { SMB_VFS_OP_PWRITE, "pwrite" },
00551 { SMB_VFS_OP_LSEEK, "lseek" },
00552 { SMB_VFS_OP_SENDFILE, "sendfile" },
00553 { SMB_VFS_OP_RENAME, "rename" },
00554 { SMB_VFS_OP_FSYNC, "fsync" },
00555 { SMB_VFS_OP_STAT, "stat" },
00556 { SMB_VFS_OP_FSTAT, "fstat" },
00557 { SMB_VFS_OP_LSTAT, "lstat" },
00558 { SMB_VFS_OP_UNLINK, "unlink" },
00559 { SMB_VFS_OP_CHMOD, "chmod" },
00560 { SMB_VFS_OP_FCHMOD, "fchmod" },
00561 { SMB_VFS_OP_CHOWN, "chown" },
00562 { SMB_VFS_OP_FCHOWN, "fchown" },
00563 { SMB_VFS_OP_CHDIR, "chdir" },
00564 { SMB_VFS_OP_GETWD, "getwd" },
00565 { SMB_VFS_OP_NTIMES, "ntimes" },
00566 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
00567 { SMB_VFS_OP_LOCK, "lock" },
00568 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
00569 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
00570 { SMB_VFS_OP_GETLOCK, "getlock" },
00571 { SMB_VFS_OP_SYMLINK, "symlink" },
00572 { SMB_VFS_OP_READLINK, "readlink" },
00573 { SMB_VFS_OP_LINK, "link" },
00574 { SMB_VFS_OP_MKNOD, "mknod" },
00575 { SMB_VFS_OP_REALPATH, "realpath" },
00576 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
00577 { SMB_VFS_OP_CHFLAGS, "chflags" },
00578 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
00579 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
00580 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
00581 { SMB_VFS_OP_SET_NT_ACL, "set_nt_acl" },
00582 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
00583 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
00584 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
00585 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
00586 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
00587 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
00588 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
00589 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
00590 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
00591 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
00592 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
00593 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
00594 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
00595 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
00596 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
00597 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
00598 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
00599 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
00600 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
00601 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
00602 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
00603 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
00604 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
00605 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
00606 { SMB_VFS_OP_GETXATTR, "getxattr" },
00607 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
00608 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
00609 { SMB_VFS_OP_LISTXATTR, "listxattr" },
00610 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
00611 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
00612 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
00613 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
00614 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
00615 { SMB_VFS_OP_SETXATTR, "setxattr" },
00616 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
00617 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
00618 { SMB_VFS_OP_AIO_READ, "aio_read" },
00619 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
00620 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
00621 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
00622 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
00623 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
00624 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
00625 { SMB_VFS_OP_LAST, NULL }
00626 };
00627
00628 static int audit_syslog_facility(vfs_handle_struct *handle)
00629 {
00630 static const struct enum_list enum_log_facilities[] = {
00631 { LOG_USER, "USER" },
00632 { LOG_LOCAL0, "LOCAL0" },
00633 { LOG_LOCAL1, "LOCAL1" },
00634 { LOG_LOCAL2, "LOCAL2" },
00635 { LOG_LOCAL3, "LOCAL3" },
00636 { LOG_LOCAL4, "LOCAL4" },
00637 { LOG_LOCAL5, "LOCAL5" },
00638 { LOG_LOCAL6, "LOCAL6" },
00639 { LOG_LOCAL7, "LOCAL7" }
00640 };
00641
00642 int facility;
00643
00644 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
00645
00646 return facility;
00647 }
00648
00649 static int audit_syslog_priority(vfs_handle_struct *handle)
00650 {
00651 static const struct enum_list enum_log_priorities[] = {
00652 { LOG_EMERG, "EMERG" },
00653 { LOG_ALERT, "ALERT" },
00654 { LOG_CRIT, "CRIT" },
00655 { LOG_ERR, "ERR" },
00656 { LOG_WARNING, "WARNING" },
00657 { LOG_NOTICE, "NOTICE" },
00658 { LOG_INFO, "INFO" },
00659 { LOG_DEBUG, "DEBUG" }
00660 };
00661
00662 int priority;
00663
00664 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority", enum_log_priorities, LOG_NOTICE);
00665
00666 return priority;
00667 }
00668
00669 static char *audit_prefix(connection_struct *conn)
00670 {
00671 static pstring prefix;
00672
00673 pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
00674 "prefix", "%u|%I"));
00675 standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
00676 conn->connectpath, conn->gid,
00677 get_current_username(),
00678 current_user_info.domain,
00679 prefix, sizeof(prefix));
00680 return prefix;
00681 }
00682
00683 static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op)
00684 {
00685 struct vfs_full_audit_private_data *pd = NULL;
00686
00687 SMB_VFS_HANDLE_GET_DATA(handle, pd,
00688 struct vfs_full_audit_private_data,
00689 return True);
00690
00691 if (pd->success_ops == NULL) {
00692 return True;
00693 }
00694
00695 return bitmap_query(pd->success_ops, op);
00696 }
00697
00698 static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op)
00699 {
00700 struct vfs_full_audit_private_data *pd = NULL;
00701
00702 SMB_VFS_HANDLE_GET_DATA(handle, pd,
00703 struct vfs_full_audit_private_data,
00704 return True);
00705
00706 if (pd->failure_ops == NULL)
00707 return True;
00708
00709 return bitmap_query(pd->failure_ops, op);
00710 }
00711
00712 static void init_bitmap(struct bitmap **bm, const char **ops)
00713 {
00714 BOOL log_all = False;
00715
00716 if (*bm != NULL)
00717 return;
00718
00719 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
00720
00721 if (*bm == NULL) {
00722 DEBUG(0, ("Could not alloc bitmap -- "
00723 "defaulting to logging everything\n"));
00724 return;
00725 }
00726
00727 while (*ops != NULL) {
00728 int i;
00729 BOOL found = False;
00730
00731 if (strequal(*ops, "all")) {
00732 log_all = True;
00733 break;
00734 }
00735
00736 if (strequal(*ops, "none")) {
00737 break;
00738 }
00739
00740 for (i=0; i<SMB_VFS_OP_LAST; i++) {
00741 if (vfs_op_names[i].name == NULL) {
00742 smb_panic("vfs_full_audit.c: name table not "
00743 "in sync with vfs.h\n");
00744 }
00745
00746 if (strequal(*ops, vfs_op_names[i].name)) {
00747 bitmap_set(*bm, i);
00748 found = True;
00749 }
00750 }
00751 if (!found) {
00752 DEBUG(0, ("Could not find opname %s, logging all\n",
00753 *ops));
00754 log_all = True;
00755 break;
00756 }
00757 ops += 1;
00758 }
00759
00760 if (log_all) {
00761
00762 bitmap_free(*bm);
00763 *bm = NULL;
00764 }
00765 }
00766
00767 static const char *audit_opname(vfs_op_type op)
00768 {
00769 if (op >= SMB_VFS_OP_LAST)
00770 return "INVALID VFS OP";
00771 return vfs_op_names[op].name;
00772 }
00773
00774 static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle,
00775 const char *format, ...)
00776 {
00777 fstring err_msg;
00778 pstring op_msg;
00779 va_list ap;
00780
00781 if (success && (!log_success(handle, op)))
00782 return;
00783
00784 if (!success && (!log_failure(handle, op)))
00785 return;
00786
00787 if (success)
00788 fstrcpy(err_msg, "ok");
00789 else
00790 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
00791
00792 va_start(ap, format);
00793 vsnprintf(op_msg, sizeof(op_msg), format, ap);
00794 va_end(ap);
00795
00796 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
00797 audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
00798
00799 return;
00800 }
00801
00802
00803
00804 static void free_private_data(void **p_data)
00805 {
00806 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
00807
00808 if (pd->success_ops) {
00809 bitmap_free(pd->success_ops);
00810 }
00811 if (pd->failure_ops) {
00812 bitmap_free(pd->failure_ops);
00813 }
00814 SAFE_FREE(pd);
00815 *p_data = NULL;
00816 }
00817
00818
00819
00820
00821 static int smb_full_audit_connect(vfs_handle_struct *handle,
00822 const char *svc, const char *user)
00823 {
00824 int result;
00825 struct vfs_full_audit_private_data *pd = NULL;
00826 const char *none[] = { NULL };
00827 const char *all [] = { "all" };
00828
00829 if (!handle) {
00830 return -1;
00831 }
00832
00833 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
00834 if (!pd) {
00835 return -1;
00836 }
00837 ZERO_STRUCTP(pd);
00838
00839 openlog("smbd_audit", 0, audit_syslog_facility(handle));
00840
00841 init_bitmap(&pd->success_ops,
00842 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
00843 none));
00844 init_bitmap(&pd->failure_ops,
00845 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
00846 all));
00847
00848
00849 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
00850 struct vfs_full_audit_private_data, return -1);
00851
00852 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
00853
00854 do_log(SMB_VFS_OP_CONNECT, True, handle,
00855 "%s", svc);
00856
00857 return result;
00858 }
00859
00860 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
00861 {
00862 SMB_VFS_NEXT_DISCONNECT(handle);
00863
00864 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
00865 "%s", lp_servicename(SNUM(handle->conn)));
00866
00867
00868
00869
00870 return;
00871 }
00872
00873 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
00874 const char *path,
00875 BOOL small_query, SMB_BIG_UINT *bsize,
00876 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
00877 {
00878 SMB_BIG_UINT result;
00879
00880 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
00881 dfree, dsize);
00882
00883
00884
00885 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
00886
00887 return result;
00888 }
00889
00890 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
00891 enum SMB_QUOTA_TYPE qtype, unid_t id,
00892 SMB_DISK_QUOTA *qt)
00893 {
00894 int result;
00895
00896 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
00897
00898 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
00899
00900 return result;
00901 }
00902
00903
00904 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
00905 enum SMB_QUOTA_TYPE qtype, unid_t id,
00906 SMB_DISK_QUOTA *qt)
00907 {
00908 int result;
00909
00910 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
00911
00912 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
00913
00914 return result;
00915 }
00916
00917 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
00918 struct files_struct *fsp,
00919 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
00920 {
00921 int result;
00922
00923 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
00924
00925 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
00926
00927 return result;
00928 }
00929
00930 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
00931 const char *path,
00932 struct vfs_statvfs_struct *statbuf)
00933 {
00934 int result;
00935
00936 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
00937
00938 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
00939
00940 return result;
00941 }
00942
00943 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
00944 const char *fname, const char *mask, uint32 attr)
00945 {
00946 SMB_STRUCT_DIR *result;
00947
00948 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
00949
00950 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
00951
00952 return result;
00953 }
00954
00955 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
00956 SMB_STRUCT_DIR *dirp)
00957 {
00958 SMB_STRUCT_DIRENT *result;
00959
00960 result = SMB_VFS_NEXT_READDIR(handle, dirp);
00961
00962
00963
00964
00965 do_log(SMB_VFS_OP_READDIR, True, handle, "");
00966
00967 return result;
00968 }
00969
00970 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
00971 SMB_STRUCT_DIR *dirp, long offset)
00972 {
00973 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
00974
00975 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
00976 return;
00977 }
00978
00979 static long smb_full_audit_telldir(vfs_handle_struct *handle,
00980 SMB_STRUCT_DIR *dirp)
00981 {
00982 long result;
00983
00984 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
00985
00986 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
00987
00988 return result;
00989 }
00990
00991 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
00992 SMB_STRUCT_DIR *dirp)
00993 {
00994 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
00995
00996 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
00997 return;
00998 }
00999
01000 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
01001 const char *path, mode_t mode)
01002 {
01003 int result;
01004
01005 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
01006
01007 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
01008
01009 return result;
01010 }
01011
01012 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
01013 const char *path)
01014 {
01015 int result;
01016
01017 result = SMB_VFS_NEXT_RMDIR(handle, path);
01018
01019 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
01020
01021 return result;
01022 }
01023
01024 static int smb_full_audit_closedir(vfs_handle_struct *handle,
01025 SMB_STRUCT_DIR *dirp)
01026 {
01027 int result;
01028
01029 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
01030
01031 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
01032
01033 return result;
01034 }
01035
01036 static int smb_full_audit_open(vfs_handle_struct *handle,
01037 const char *fname, files_struct *fsp, int flags, mode_t mode)
01038 {
01039 int result;
01040
01041 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
01042
01043 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
01044 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
01045 fname);
01046
01047 return result;
01048 }
01049
01050 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
01051 {
01052 int result;
01053
01054 result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
01055
01056 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
01057
01058 return result;
01059 }
01060
01061 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
01062 int fd, void *data, size_t n)
01063 {
01064 ssize_t result;
01065
01066 result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
01067
01068 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
01069
01070 return result;
01071 }
01072
01073 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
01074 int fd, void *data, size_t n, SMB_OFF_T offset)
01075 {
01076 ssize_t result;
01077
01078 result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
01079
01080 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
01081
01082 return result;
01083 }
01084
01085 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
01086 int fd, const void *data, size_t n)
01087 {
01088 ssize_t result;
01089
01090 result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
01091
01092 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
01093
01094 return result;
01095 }
01096
01097 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
01098 int fd, const void *data, size_t n,
01099 SMB_OFF_T offset)
01100 {
01101 ssize_t result;
01102
01103 result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
01104
01105 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
01106
01107 return result;
01108 }
01109
01110 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
01111 int filedes, SMB_OFF_T offset, int whence)
01112 {
01113 ssize_t result;
01114
01115 result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
01116
01117 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
01118 "%s", fsp->fsp_name);
01119
01120 return result;
01121 }
01122
01123 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
01124 files_struct *fsp, int fromfd,
01125 const DATA_BLOB *hdr, SMB_OFF_T offset,
01126 size_t n)
01127 {
01128 ssize_t result;
01129
01130 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr,
01131 offset, n);
01132
01133 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
01134 "%s", fsp->fsp_name);
01135
01136 return result;
01137 }
01138
01139 static int smb_full_audit_rename(vfs_handle_struct *handle,
01140 const char *oldname, const char *newname)
01141 {
01142 int result;
01143
01144 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
01145
01146 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
01147
01148 return result;
01149 }
01150
01151 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
01152 {
01153 int result;
01154
01155 result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd);
01156
01157 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
01158
01159 return result;
01160 }
01161
01162 static int smb_full_audit_stat(vfs_handle_struct *handle,
01163 const char *fname, SMB_STRUCT_STAT *sbuf)
01164 {
01165 int result;
01166
01167 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
01168
01169 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
01170
01171 return result;
01172 }
01173
01174 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
01175 SMB_STRUCT_STAT *sbuf)
01176 {
01177 int result;
01178
01179 result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf);
01180
01181 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
01182
01183 return result;
01184 }
01185
01186 static int smb_full_audit_lstat(vfs_handle_struct *handle,
01187 const char *path, SMB_STRUCT_STAT *sbuf)
01188 {
01189 int result;
01190
01191 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
01192
01193 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
01194
01195 return result;
01196 }
01197
01198 static int smb_full_audit_unlink(vfs_handle_struct *handle,
01199 const char *path)
01200 {
01201 int result;
01202
01203 result = SMB_VFS_NEXT_UNLINK(handle, path);
01204
01205 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
01206
01207 return result;
01208 }
01209
01210 static int smb_full_audit_chmod(vfs_handle_struct *handle,
01211 const char *path, mode_t mode)
01212 {
01213 int result;
01214
01215 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
01216
01217 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
01218
01219 return result;
01220 }
01221
01222 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
01223 mode_t mode)
01224 {
01225 int result;
01226
01227 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode);
01228
01229 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
01230 "%s|%o", fsp->fsp_name, mode);
01231
01232 return result;
01233 }
01234
01235 static int smb_full_audit_chown(vfs_handle_struct *handle,
01236 const char *path, uid_t uid, gid_t gid)
01237 {
01238 int result;
01239
01240 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
01241
01242 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
01243 path, (long int)uid, (long int)gid);
01244
01245 return result;
01246 }
01247
01248 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
01249 uid_t uid, gid_t gid)
01250 {
01251 int result;
01252
01253 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid);
01254
01255 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
01256 fsp->fsp_name, (long int)uid, (long int)gid);
01257
01258 return result;
01259 }
01260
01261 static int smb_full_audit_chdir(vfs_handle_struct *handle,
01262 const char *path)
01263 {
01264 int result;
01265
01266 result = SMB_VFS_NEXT_CHDIR(handle, path);
01267
01268 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
01269
01270 return result;
01271 }
01272
01273 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
01274 char *path)
01275 {
01276 char *result;
01277
01278 result = SMB_VFS_NEXT_GETWD(handle, path);
01279
01280 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
01281
01282 return result;
01283 }
01284
01285 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
01286 const char *path, const struct timespec ts[2])
01287 {
01288 int result;
01289
01290 result = SMB_VFS_NEXT_NTIMES(handle, path, ts);
01291
01292 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
01293
01294 return result;
01295 }
01296
01297 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
01298 int fd, SMB_OFF_T len)
01299 {
01300 int result;
01301
01302 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
01303
01304 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
01305 "%s", fsp->fsp_name);
01306
01307 return result;
01308 }
01309
01310 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
01311 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
01312 {
01313 BOOL result;
01314
01315 result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
01316
01317 do_log(SMB_VFS_OP_LOCK, (result >= 0), handle, "%s", fsp->fsp_name);
01318
01319 return result;
01320 }
01321
01322 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
01323 struct files_struct *fsp, int fd,
01324 uint32 share_mode)
01325 {
01326 int result;
01327
01328 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, fd, share_mode);
01329
01330 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
01331 fsp->fsp_name);
01332
01333 return result;
01334 }
01335
01336 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
01337 int fd, int leasetype)
01338 {
01339 int result;
01340
01341 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, fd, leasetype);
01342
01343 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
01344 fsp->fsp_name);
01345
01346 return result;
01347 }
01348
01349 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
01350 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
01351 {
01352 BOOL result;
01353
01354 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid);
01355
01356 do_log(SMB_VFS_OP_GETLOCK, (result >= 0), handle, "%s", fsp->fsp_name);
01357
01358 return result;
01359 }
01360
01361 static int smb_full_audit_symlink(vfs_handle_struct *handle,
01362 const char *oldpath, const char *newpath)
01363 {
01364 int result;
01365
01366 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
01367
01368 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
01369 "%s|%s", oldpath, newpath);
01370
01371 return result;
01372 }
01373
01374 static int smb_full_audit_readlink(vfs_handle_struct *handle,
01375 const char *path, char *buf, size_t bufsiz)
01376 {
01377 int result;
01378
01379 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
01380
01381 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
01382
01383 return result;
01384 }
01385
01386 static int smb_full_audit_link(vfs_handle_struct *handle,
01387 const char *oldpath, const char *newpath)
01388 {
01389 int result;
01390
01391 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
01392
01393 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
01394 "%s|%s", oldpath, newpath);
01395
01396 return result;
01397 }
01398
01399 static int smb_full_audit_mknod(vfs_handle_struct *handle,
01400 const char *pathname, mode_t mode, SMB_DEV_T dev)
01401 {
01402 int result;
01403
01404 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
01405
01406 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
01407
01408 return result;
01409 }
01410
01411 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
01412 const char *path, char *resolved_path)
01413 {
01414 char *result;
01415
01416 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
01417
01418 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
01419
01420 return result;
01421 }
01422
01423 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
01424 struct sys_notify_context *ctx,
01425 struct notify_entry *e,
01426 void (*callback)(struct sys_notify_context *ctx,
01427 void *private_data,
01428 struct notify_event *ev),
01429 void *private_data, void *handle_p)
01430 {
01431 NTSTATUS result;
01432
01433 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
01434
01435 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
01436
01437 return result;
01438 }
01439
01440 static int smb_full_audit_chflags(vfs_handle_struct *handle,
01441 const char *path, uint flags)
01442 {
01443 int result;
01444
01445 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
01446
01447 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
01448
01449 return result;
01450 }
01451
01452 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
01453 int fd, uint32 security_info,
01454 SEC_DESC **ppdesc)
01455 {
01456 size_t result;
01457
01458 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info,
01459 ppdesc);
01460
01461 do_log(SMB_VFS_OP_FGET_NT_ACL, (result > 0), handle,
01462 "%s", fsp->fsp_name);
01463
01464 return result;
01465 }
01466
01467 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
01468 const char *name, uint32 security_info,
01469 SEC_DESC **ppdesc)
01470 {
01471 size_t result;
01472
01473 result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
01474 ppdesc);
01475
01476 do_log(SMB_VFS_OP_GET_NT_ACL, (result > 0), handle,
01477 "%s", fsp->fsp_name);
01478
01479 return result;
01480 }
01481
01482 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
01483 int fd, uint32 security_info_sent,
01484 SEC_DESC *psd)
01485 {
01486 BOOL result;
01487
01488 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent,
01489 psd);
01490
01491 do_log(SMB_VFS_OP_FSET_NT_ACL, result, handle, "%s", fsp->fsp_name);
01492
01493 return result;
01494 }
01495
01496 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
01497 const char *name, uint32 security_info_sent,
01498 SEC_DESC *psd)
01499 {
01500 BOOL result;
01501
01502 result = SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent,
01503 psd);
01504
01505 do_log(SMB_VFS_OP_SET_NT_ACL, result, handle, "%s", fsp->fsp_name);
01506
01507 return result;
01508 }
01509
01510 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
01511 const char *path, mode_t mode)
01512 {
01513 int result;
01514
01515 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
01516
01517 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
01518 "%s|%o", path, mode);
01519
01520 return result;
01521 }
01522
01523 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
01524 int fd, mode_t mode)
01525 {
01526 int result;
01527
01528 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode);
01529
01530 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
01531 "%s|%o", fsp->fsp_name, mode);
01532
01533 return result;
01534 }
01535
01536 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
01537
01538 SMB_ACL_T theacl, int entry_id,
01539 SMB_ACL_ENTRY_T *entry_p)
01540 {
01541 int result;
01542
01543 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
01544 entry_p);
01545
01546 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
01547 "");
01548
01549 return result;
01550 }
01551
01552 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
01553
01554 SMB_ACL_ENTRY_T entry_d,
01555 SMB_ACL_TAG_T *tag_type_p)
01556 {
01557 int result;
01558
01559 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
01560 tag_type_p);
01561
01562 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
01563 "");
01564
01565 return result;
01566 }
01567
01568 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
01569
01570 SMB_ACL_ENTRY_T entry_d,
01571 SMB_ACL_PERMSET_T *permset_p)
01572 {
01573 int result;
01574
01575 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
01576 permset_p);
01577
01578 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
01579 "");
01580
01581 return result;
01582 }
01583
01584 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
01585
01586 SMB_ACL_ENTRY_T entry_d)
01587 {
01588 void *result;
01589
01590 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
01591
01592 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
01593 "");
01594
01595 return result;
01596 }
01597
01598 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
01599 const char *path_p,
01600 SMB_ACL_TYPE_T type)
01601 {
01602 SMB_ACL_T result;
01603
01604 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
01605
01606 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
01607 "%s", path_p);
01608
01609 return result;
01610 }
01611
01612 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
01613 files_struct *fsp, int fd)
01614 {
01615 SMB_ACL_T result;
01616
01617 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd);
01618
01619 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
01620 "%s", fsp->fsp_name);
01621
01622 return result;
01623 }
01624
01625 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
01626
01627 SMB_ACL_PERMSET_T permset)
01628 {
01629 int result;
01630
01631 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
01632
01633 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
01634 "");
01635
01636 return result;
01637 }
01638
01639 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
01640
01641 SMB_ACL_PERMSET_T permset,
01642 SMB_ACL_PERM_T perm)
01643 {
01644 int result;
01645
01646 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
01647
01648 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
01649 "");
01650
01651 return result;
01652 }
01653
01654 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
01655 SMB_ACL_T theacl,
01656 ssize_t *plen)
01657 {
01658 char * result;
01659
01660 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
01661
01662 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
01663 "");
01664
01665 return result;
01666 }
01667
01668 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
01669
01670 int count)
01671 {
01672 SMB_ACL_T result;
01673
01674 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
01675
01676 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
01677 "");
01678
01679 return result;
01680 }
01681
01682 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
01683 SMB_ACL_T *pacl,
01684 SMB_ACL_ENTRY_T *pentry)
01685 {
01686 int result;
01687
01688 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
01689
01690 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
01691 "");
01692
01693 return result;
01694 }
01695
01696 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
01697
01698 SMB_ACL_ENTRY_T entry,
01699 SMB_ACL_TAG_T tagtype)
01700 {
01701 int result;
01702
01703 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
01704 tagtype);
01705
01706 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
01707 "");
01708
01709 return result;
01710 }
01711
01712 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
01713
01714 SMB_ACL_ENTRY_T entry,
01715 void *qual)
01716 {
01717 int result;
01718
01719 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
01720
01721 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
01722 "");
01723
01724 return result;
01725 }
01726
01727 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
01728
01729 SMB_ACL_ENTRY_T entry,
01730 SMB_ACL_PERMSET_T permset)
01731 {
01732 int result;
01733
01734 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
01735
01736 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
01737 "");
01738
01739 return result;
01740 }
01741
01742 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
01743
01744 SMB_ACL_T theacl )
01745 {
01746 int result;
01747
01748 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
01749
01750 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
01751 "");
01752
01753 return result;
01754 }
01755
01756 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
01757
01758 const char *name, SMB_ACL_TYPE_T acltype,
01759 SMB_ACL_T theacl)
01760 {
01761 int result;
01762
01763 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
01764 theacl);
01765
01766 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
01767 "%s", name);
01768
01769 return result;
01770 }
01771
01772 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
01773 int fd, SMB_ACL_T theacl)
01774 {
01775 int result;
01776
01777 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl);
01778
01779 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
01780 "%s", fsp->fsp_name);
01781
01782 return result;
01783 }
01784
01785 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
01786
01787 const char *path)
01788 {
01789 int result;
01790
01791 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
01792
01793 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
01794 "%s", path);
01795
01796 return result;
01797 }
01798
01799 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
01800
01801 SMB_ACL_PERMSET_T permset,
01802 SMB_ACL_PERM_T perm)
01803 {
01804 int result;
01805
01806 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
01807
01808 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
01809 "");
01810
01811 return result;
01812 }
01813
01814 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
01815
01816 char *text)
01817 {
01818 int result;
01819
01820 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
01821
01822 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
01823 "");
01824
01825 return result;
01826 }
01827
01828 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
01829
01830 SMB_ACL_T posix_acl)
01831 {
01832 int result;
01833
01834 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
01835
01836 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
01837 "");
01838
01839 return result;
01840 }
01841
01842 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
01843 void *qualifier,
01844 SMB_ACL_TAG_T tagtype)
01845 {
01846 int result;
01847
01848 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
01849 tagtype);
01850
01851 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
01852 "");
01853
01854 return result;
01855 }
01856
01857 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
01858 const char *path,
01859 const char *name, void *value, size_t size)
01860 {
01861 ssize_t result;
01862
01863 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
01864
01865 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
01866 "%s|%s", path, name);
01867
01868 return result;
01869 }
01870
01871 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
01872 const char *path, const char *name,
01873 void *value, size_t size)
01874 {
01875 ssize_t result;
01876
01877 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
01878
01879 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
01880 "%s|%s", path, name);
01881
01882 return result;
01883 }
01884
01885 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
01886 struct files_struct *fsp, int fd,
01887 const char *name, void *value, size_t size)
01888 {
01889 ssize_t result;
01890
01891 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size);
01892
01893 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
01894 "%s|%s", fsp->fsp_name, name);
01895
01896 return result;
01897 }
01898
01899 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
01900 const char *path, char *list, size_t size)
01901 {
01902 ssize_t result;
01903
01904 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
01905
01906 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
01907
01908 return result;
01909 }
01910
01911 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
01912 const char *path, char *list, size_t size)
01913 {
01914 ssize_t result;
01915
01916 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
01917
01918 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
01919
01920 return result;
01921 }
01922
01923 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
01924 struct files_struct *fsp, int fd, char *list,
01925 size_t size)
01926 {
01927 ssize_t result;
01928
01929 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size);
01930
01931 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
01932 "%s", fsp->fsp_name);
01933
01934 return result;
01935 }
01936
01937 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
01938 const char *path,
01939 const char *name)
01940 {
01941 int result;
01942
01943 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
01944
01945 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
01946 "%s|%s", path, name);
01947
01948 return result;
01949 }
01950
01951 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
01952 const char *path,
01953 const char *name)
01954 {
01955 int result;
01956
01957 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
01958
01959 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
01960 "%s|%s", path, name);
01961
01962 return result;
01963 }
01964
01965 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
01966 struct files_struct *fsp, int fd,
01967 const char *name)
01968 {
01969 int result;
01970
01971 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name);
01972
01973 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
01974 "%s|%s", fsp->fsp_name, name);
01975
01976 return result;
01977 }
01978
01979 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
01980 const char *path,
01981 const char *name, const void *value, size_t size,
01982 int flags)
01983 {
01984 int result;
01985
01986 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
01987 flags);
01988
01989 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
01990 "%s|%s", path, name);
01991
01992 return result;
01993 }
01994
01995 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
01996 const char *path,
01997 const char *name, const void *value, size_t size,
01998 int flags)
01999 {
02000 int result;
02001
02002 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
02003 flags);
02004
02005 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
02006 "%s|%s", path, name);
02007
02008 return result;
02009 }
02010
02011 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
02012 struct files_struct *fsp, int fd, const char *name,
02013 const void *value, size_t size, int flags)
02014 {
02015 int result;
02016
02017 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size,
02018 flags);
02019
02020 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
02021 "%s|%s", fsp->fsp_name, name);
02022
02023 return result;
02024 }
02025
02026 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
02027 {
02028 int result;
02029
02030 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
02031 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
02032 "%s", fsp->fsp_name);
02033
02034 return result;
02035 }
02036
02037 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
02038 {
02039 int result;
02040
02041 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
02042 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
02043 "%s", fsp->fsp_name);
02044
02045 return result;
02046 }
02047
02048 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
02049 {
02050 int result;
02051
02052 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
02053 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
02054 "%s", fsp->fsp_name);
02055
02056 return result;
02057 }
02058
02059 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
02060 {
02061 int result;
02062
02063 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb);
02064 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
02065 "%s", fsp->fsp_name);
02066
02067 return result;
02068 }
02069
02070 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
02071 {
02072 int result;
02073
02074 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
02075 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
02076 "%s", fsp->fsp_name);
02077
02078 return result;
02079 }
02080
02081 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
02082 {
02083 int result;
02084
02085 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
02086 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
02087 "%s", fsp->fsp_name);
02088
02089 return result;
02090 }
02091
02092 static int smb_full_audit_aio_suspend(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *ts)
02093 {
02094 int result;
02095
02096 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
02097 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
02098 "%s", fsp->fsp_name);
02099
02100 return result;
02101 }
02102
02103
02104 NTSTATUS vfs_full_audit_init(void);
02105 NTSTATUS vfs_full_audit_init(void)
02106 {
02107 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
02108 "full_audit", audit_op_tuples);
02109
02110 if (!NT_STATUS_IS_OK(ret))
02111 return ret;
02112
02113 vfs_full_audit_debug_level = debug_add_class("full_audit");
02114 if (vfs_full_audit_debug_level == -1) {
02115 vfs_full_audit_debug_level = DBGC_VFS;
02116 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
02117 "class!\n"));
02118 } else {
02119 DEBUG(10, ("vfs_full_audit: Debug class number of "
02120 "'full_audit': %d\n", vfs_full_audit_debug_level));
02121 }
02122
02123 return ret;
02124 }