2 * Auditing VFS module for samba. Log selected file operations to syslog
5 * Copyright (C) Tim Potter, 1999-2000
6 * Copyright (C) Alexander Bokovoy, 2002
7 * Copyright (C) John H Terpstra, 2003
8 * Copyright (C) Stefan (metze) Metzmacher, 2003
9 * Copyright (C) Volker Lendecke, 2004
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <http://www.gnu.org/licenses/>.
26 * This module implements parseable logging for all Samba VFS operations.
28 * You use it as follows:
32 * vfs objects = full_audit
33 * full_audit:prefix = %u|%I
34 * full_audit:success = open opendir
35 * full_audit:failure = all
37 * vfs op can be "all" which means log all operations.
38 * vfs op can be "none" which means no logging.
40 * This leads to syslog entries of the form:
41 * smbd_audit: nobody|192.168.234.1|opendir|ok|.
42 * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
44 * where "nobody" is the connected username and "192.168.234.1" is the
45 * client's IP address.
49 * prefix: A macro expansion template prepended to the syslog entry.
51 * success: A list of VFS operations for which a successful completion should
52 * be logged. Defaults to no logging at all. The special operation "all" logs
53 * - you guessed it - everything.
55 * failure: A list of VFS operations for which failure to complete should be
56 * logged. Defaults to logging everything.
62 static int vfs_full_audit_debug_level = DBGC_VFS;
64 struct vfs_full_audit_private_data {
65 struct bitmap *success_ops;
66 struct bitmap *failure_ops;
70 #define DBGC_CLASS vfs_full_audit_debug_level
72 /* Function prototypes */
74 static int smb_full_audit_connect(vfs_handle_struct *handle,
75 const char *svc, const char *user);
76 static void smb_full_audit_disconnect(vfs_handle_struct *handle);
77 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
79 bool small_query, uint64_t *bsize,
80 uint64_t *dfree, uint64_t *dsize);
81 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
82 enum SMB_QUOTA_TYPE qtype, unid_t id,
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
87 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
88 struct files_struct *fsp,
89 SHADOW_COPY_DATA *shadow_copy_data, bool labels);
90 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
92 struct vfs_statvfs_struct *statbuf);
94 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
95 const char *fname, const char *mask, uint32 attr);
96 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
97 SMB_STRUCT_DIR *dirp);
98 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
99 SMB_STRUCT_DIR *dirp, long offset);
100 static long smb_full_audit_telldir(vfs_handle_struct *handle,
101 SMB_STRUCT_DIR *dirp);
102 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
103 SMB_STRUCT_DIR *dirp);
104 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
105 const char *path, mode_t mode);
106 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
108 static int smb_full_audit_closedir(vfs_handle_struct *handle,
109 SMB_STRUCT_DIR *dirp);
110 static int smb_full_audit_open(vfs_handle_struct *handle,
111 const char *fname, files_struct *fsp, int flags, mode_t mode);
112 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
113 struct smb_request *req,
114 uint16_t root_dir_fid,
117 uint32_t access_mask,
118 uint32_t share_access,
119 uint32_t create_disposition,
120 uint32_t create_options,
121 uint32_t file_attributes,
122 uint32_t oplock_request,
123 uint64_t allocation_size,
124 struct security_descriptor *sd,
125 struct ea_list *ea_list,
126 files_struct **result,
128 SMB_STRUCT_STAT *psbuf);
129 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
130 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
131 void *data, size_t n);
132 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
133 void *data, size_t n, SMB_OFF_T offset);
134 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
135 const void *data, size_t n);
136 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
137 const void *data, size_t n,
139 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
140 SMB_OFF_T offset, int whence);
141 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
142 files_struct *fromfsp,
143 const DATA_BLOB *hdr, SMB_OFF_T offset,
145 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
149 static int smb_full_audit_rename(vfs_handle_struct *handle,
150 const char *oldname, const char *newname);
151 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
152 static int smb_full_audit_stat(vfs_handle_struct *handle,
153 const char *fname, SMB_STRUCT_STAT *sbuf);
154 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
155 SMB_STRUCT_STAT *sbuf);
156 static int smb_full_audit_lstat(vfs_handle_struct *handle,
157 const char *path, SMB_STRUCT_STAT *sbuf);
158 static int smb_full_audit_unlink(vfs_handle_struct *handle,
160 static int smb_full_audit_chmod(vfs_handle_struct *handle,
161 const char *path, mode_t mode);
162 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
164 static int smb_full_audit_chown(vfs_handle_struct *handle,
165 const char *path, uid_t uid, gid_t gid);
166 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
167 uid_t uid, gid_t gid);
168 static int smb_full_audit_lchown(vfs_handle_struct *handle,
169 const char *path, uid_t uid, gid_t gid);
170 static int smb_full_audit_chdir(vfs_handle_struct *handle,
172 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
174 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
175 const char *path, const struct timespec ts[2]);
176 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
178 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
179 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
180 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
181 struct files_struct *fsp,
183 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
185 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
186 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
187 static int smb_full_audit_symlink(vfs_handle_struct *handle,
188 const char *oldpath, const char *newpath);
189 static int smb_full_audit_readlink(vfs_handle_struct *handle,
190 const char *path, char *buf, size_t bufsiz);
191 static int smb_full_audit_link(vfs_handle_struct *handle,
192 const char *oldpath, const char *newpath);
193 static int smb_full_audit_mknod(vfs_handle_struct *handle,
194 const char *pathname, mode_t mode, SMB_DEV_T dev);
195 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
196 const char *path, char *resolved_path);
197 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
198 struct sys_notify_context *ctx,
199 struct notify_entry *e,
200 void (*callback)(struct sys_notify_context *ctx,
202 struct notify_event *ev),
203 void *private_data, void *handle_p);
204 static int smb_full_audit_chflags(vfs_handle_struct *handle,
205 const char *path, unsigned int flags);
206 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
207 SMB_DEV_T dev, SMB_INO_T inode);
208 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
209 struct files_struct *fsp,
212 unsigned int *pnum_streams,
213 struct stream_struct **pstreams);
214 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
215 uint32 security_info,
217 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
218 const char *name, uint32 security_info,
220 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
221 uint32 security_info_sent,
222 const SEC_DESC *psd);
223 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
224 const char *path, mode_t mode);
225 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
227 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
228 SMB_ACL_T theacl, int entry_id,
229 SMB_ACL_ENTRY_T *entry_p);
230 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
231 SMB_ACL_ENTRY_T entry_d,
232 SMB_ACL_TAG_T *tag_type_p);
233 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
234 SMB_ACL_ENTRY_T entry_d,
235 SMB_ACL_PERMSET_T *permset_p);
236 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
237 SMB_ACL_ENTRY_T entry_d);
238 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
240 SMB_ACL_TYPE_T type);
241 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
243 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
244 SMB_ACL_PERMSET_T permset);
245 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
246 SMB_ACL_PERMSET_T permset,
247 SMB_ACL_PERM_T perm);
248 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
251 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
253 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
255 SMB_ACL_ENTRY_T *pentry);
256 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
257 SMB_ACL_ENTRY_T entry,
258 SMB_ACL_TAG_T tagtype);
259 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
260 SMB_ACL_ENTRY_T entry,
262 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
263 SMB_ACL_ENTRY_T entry,
264 SMB_ACL_PERMSET_T permset);
265 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
267 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
268 const char *name, SMB_ACL_TYPE_T acltype,
270 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
272 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
274 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
275 SMB_ACL_PERMSET_T permset,
276 SMB_ACL_PERM_T perm);
277 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
279 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
280 SMB_ACL_T posix_acl);
281 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
283 SMB_ACL_TAG_T tagtype);
284 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
286 const char *name, void *value, size_t size);
287 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
288 const char *path, const char *name,
289 void *value, size_t size);
290 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
291 struct files_struct *fsp,
292 const char *name, void *value, size_t size);
293 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
294 const char *path, char *list, size_t size);
295 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
296 const char *path, char *list, size_t size);
297 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
298 struct files_struct *fsp, char *list,
300 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
303 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
306 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
307 struct files_struct *fsp,
309 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
311 const char *name, const void *value, size_t size,
313 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
315 const char *name, const void *value, size_t size,
317 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
318 struct files_struct *fsp, const char *name,
319 const void *value, size_t size, int flags);
321 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
322 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
323 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
324 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
325 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
326 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
327 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);
331 static vfs_op_tuple audit_op_tuples[] = {
333 /* Disk operations */
335 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
336 SMB_VFS_LAYER_LOGGER},
337 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
338 SMB_VFS_LAYER_LOGGER},
339 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
340 SMB_VFS_LAYER_LOGGER},
341 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
342 SMB_VFS_LAYER_LOGGER},
343 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
344 SMB_VFS_LAYER_LOGGER},
345 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
346 SMB_VFS_LAYER_LOGGER},
347 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
348 SMB_VFS_LAYER_LOGGER},
350 /* Directory operations */
352 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
353 SMB_VFS_LAYER_LOGGER},
354 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
355 SMB_VFS_LAYER_LOGGER},
356 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
357 SMB_VFS_LAYER_LOGGER},
358 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
359 SMB_VFS_LAYER_LOGGER},
360 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
361 SMB_VFS_LAYER_LOGGER},
362 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
367 SMB_VFS_LAYER_LOGGER},
369 /* File operations */
371 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
372 SMB_VFS_LAYER_LOGGER},
373 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
374 SMB_VFS_LAYER_LOGGER},
375 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
376 SMB_VFS_LAYER_LOGGER},
377 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
378 SMB_VFS_LAYER_LOGGER},
379 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
380 SMB_VFS_LAYER_LOGGER},
381 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
382 SMB_VFS_LAYER_LOGGER},
383 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
384 SMB_VFS_LAYER_LOGGER},
385 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
402 SMB_VFS_LAYER_LOGGER},
403 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
404 SMB_VFS_LAYER_LOGGER},
405 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
406 SMB_VFS_LAYER_LOGGER},
407 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
408 SMB_VFS_LAYER_LOGGER},
409 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
410 SMB_VFS_LAYER_LOGGER},
411 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
412 SMB_VFS_LAYER_LOGGER},
413 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
414 SMB_VFS_LAYER_LOGGER},
415 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
416 SMB_VFS_LAYER_LOGGER},
417 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
418 SMB_VFS_LAYER_LOGGER},
419 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
420 SMB_VFS_LAYER_LOGGER},
421 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
422 SMB_VFS_LAYER_LOGGER},
423 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
424 SMB_VFS_LAYER_LOGGER},
425 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
426 SMB_VFS_LAYER_LOGGER},
427 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
428 SMB_VFS_LAYER_LOGGER},
429 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
430 SMB_VFS_LAYER_LOGGER},
431 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
432 SMB_VFS_LAYER_LOGGER},
433 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
434 SMB_VFS_LAYER_LOGGER},
435 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
436 SMB_VFS_LAYER_LOGGER},
437 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
438 SMB_VFS_LAYER_LOGGER},
439 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
440 SMB_VFS_LAYER_LOGGER},
441 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
442 SMB_VFS_LAYER_LOGGER},
443 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
444 SMB_VFS_LAYER_LOGGER},
445 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
446 SMB_VFS_LAYER_LOGGER},
448 /* NT ACL operations. */
450 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
455 SMB_VFS_LAYER_LOGGER},
457 /* POSIX ACL operations. */
459 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
460 SMB_VFS_LAYER_LOGGER},
461 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
462 SMB_VFS_LAYER_LOGGER},
463 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
464 SMB_VFS_LAYER_LOGGER},
465 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
466 SMB_VFS_LAYER_LOGGER},
467 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
468 SMB_VFS_LAYER_LOGGER},
469 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
470 SMB_VFS_LAYER_LOGGER},
471 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
472 SMB_VFS_LAYER_LOGGER},
473 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
474 SMB_VFS_LAYER_LOGGER},
475 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
476 SMB_VFS_LAYER_LOGGER},
477 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
478 SMB_VFS_LAYER_LOGGER},
479 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
480 SMB_VFS_LAYER_LOGGER},
481 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
482 SMB_VFS_LAYER_LOGGER},
483 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
484 SMB_VFS_LAYER_LOGGER},
485 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
486 SMB_VFS_LAYER_LOGGER},
487 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
488 SMB_VFS_LAYER_LOGGER},
489 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
494 SMB_VFS_LAYER_LOGGER},
495 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
496 SMB_VFS_LAYER_LOGGER},
497 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
498 SMB_VFS_LAYER_LOGGER},
499 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
500 SMB_VFS_LAYER_LOGGER},
501 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
506 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
533 SMB_VFS_LAYER_LOGGER},
535 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
536 SMB_VFS_LAYER_LOGGER},
537 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
538 SMB_VFS_LAYER_LOGGER},
539 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
540 SMB_VFS_LAYER_LOGGER},
541 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
542 SMB_VFS_LAYER_LOGGER},
543 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
544 SMB_VFS_LAYER_LOGGER},
545 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
546 SMB_VFS_LAYER_LOGGER},
547 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
548 SMB_VFS_LAYER_LOGGER},
550 /* Finish VFS operations definition */
552 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
556 /* The following array *must* be in the same order as defined in vfs.h */
562 { SMB_VFS_OP_CONNECT, "connect" },
563 { SMB_VFS_OP_DISCONNECT, "disconnect" },
564 { SMB_VFS_OP_DISK_FREE, "disk_free" },
565 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
566 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
567 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
568 { SMB_VFS_OP_STATVFS, "statvfs" },
569 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
570 { SMB_VFS_OP_OPENDIR, "opendir" },
571 { SMB_VFS_OP_READDIR, "readdir" },
572 { SMB_VFS_OP_SEEKDIR, "seekdir" },
573 { SMB_VFS_OP_TELLDIR, "telldir" },
574 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
575 { SMB_VFS_OP_MKDIR, "mkdir" },
576 { SMB_VFS_OP_RMDIR, "rmdir" },
577 { SMB_VFS_OP_CLOSEDIR, "closedir" },
578 { SMB_VFS_OP_OPEN, "open" },
579 { SMB_VFS_OP_CLOSE, "close" },
580 { SMB_VFS_OP_READ, "read" },
581 { SMB_VFS_OP_PREAD, "pread" },
582 { SMB_VFS_OP_WRITE, "write" },
583 { SMB_VFS_OP_PWRITE, "pwrite" },
584 { SMB_VFS_OP_LSEEK, "lseek" },
585 { SMB_VFS_OP_SENDFILE, "sendfile" },
586 { SMB_VFS_OP_RECVFILE, "recvfile" },
587 { SMB_VFS_OP_RENAME, "rename" },
588 { SMB_VFS_OP_FSYNC, "fsync" },
589 { SMB_VFS_OP_STAT, "stat" },
590 { SMB_VFS_OP_FSTAT, "fstat" },
591 { SMB_VFS_OP_LSTAT, "lstat" },
592 { SMB_VFS_OP_UNLINK, "unlink" },
593 { SMB_VFS_OP_CHMOD, "chmod" },
594 { SMB_VFS_OP_FCHMOD, "fchmod" },
595 { SMB_VFS_OP_CHOWN, "chown" },
596 { SMB_VFS_OP_FCHOWN, "fchown" },
597 { SMB_VFS_OP_LCHOWN, "lchown" },
598 { SMB_VFS_OP_CHDIR, "chdir" },
599 { SMB_VFS_OP_GETWD, "getwd" },
600 { SMB_VFS_OP_NTIMES, "ntimes" },
601 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
602 { SMB_VFS_OP_LOCK, "lock" },
603 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
604 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
605 { SMB_VFS_OP_GETLOCK, "getlock" },
606 { SMB_VFS_OP_SYMLINK, "symlink" },
607 { SMB_VFS_OP_READLINK, "readlink" },
608 { SMB_VFS_OP_LINK, "link" },
609 { SMB_VFS_OP_MKNOD, "mknod" },
610 { SMB_VFS_OP_REALPATH, "realpath" },
611 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
612 { SMB_VFS_OP_CHFLAGS, "chflags" },
613 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
614 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
615 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
616 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
617 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
618 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
619 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
620 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
621 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
622 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
623 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
624 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
625 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
626 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
627 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
628 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
629 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
630 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
631 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
632 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
633 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
634 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
635 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
636 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
637 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
638 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
639 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
640 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
641 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
642 { SMB_VFS_OP_GETXATTR, "getxattr" },
643 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
644 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
645 { SMB_VFS_OP_LISTXATTR, "listxattr" },
646 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
647 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
648 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
649 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
650 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
651 { SMB_VFS_OP_SETXATTR, "setxattr" },
652 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
653 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
654 { SMB_VFS_OP_AIO_READ, "aio_read" },
655 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
656 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
657 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
658 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
659 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
660 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
661 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
662 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
663 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
664 { SMB_VFS_OP_LAST, NULL }
667 static int audit_syslog_facility(vfs_handle_struct *handle)
669 static const struct enum_list enum_log_facilities[] = {
670 { LOG_USER, "USER" },
671 { LOG_LOCAL0, "LOCAL0" },
672 { LOG_LOCAL1, "LOCAL1" },
673 { LOG_LOCAL2, "LOCAL2" },
674 { LOG_LOCAL3, "LOCAL3" },
675 { LOG_LOCAL4, "LOCAL4" },
676 { LOG_LOCAL5, "LOCAL5" },
677 { LOG_LOCAL6, "LOCAL6" },
678 { LOG_LOCAL7, "LOCAL7" }
683 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
688 static int audit_syslog_priority(vfs_handle_struct *handle)
690 static const struct enum_list enum_log_priorities[] = {
691 { LOG_EMERG, "EMERG" },
692 { LOG_ALERT, "ALERT" },
693 { LOG_CRIT, "CRIT" },
695 { LOG_WARNING, "WARNING" },
696 { LOG_NOTICE, "NOTICE" },
697 { LOG_INFO, "INFO" },
698 { LOG_DEBUG, "DEBUG" }
703 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
704 enum_log_priorities, LOG_NOTICE);
705 if (priority == -1) {
706 priority = LOG_WARNING;
712 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
716 prefix = talloc_strdup(ctx,
717 lp_parm_const_string(SNUM(conn), "full_audit",
722 return talloc_sub_advanced(ctx,
723 lp_servicename(SNUM(conn)),
724 conn->server_info->unix_name,
726 conn->server_info->utok.gid,
727 conn->server_info->sanitized_username,
728 pdb_get_domain(conn->server_info->sam_account),
732 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
734 struct vfs_full_audit_private_data *pd = NULL;
736 SMB_VFS_HANDLE_GET_DATA(handle, pd,
737 struct vfs_full_audit_private_data,
740 if (pd->success_ops == NULL) {
744 return bitmap_query(pd->success_ops, op);
747 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
749 struct vfs_full_audit_private_data *pd = NULL;
751 SMB_VFS_HANDLE_GET_DATA(handle, pd,
752 struct vfs_full_audit_private_data,
755 if (pd->failure_ops == NULL)
758 return bitmap_query(pd->failure_ops, op);
761 static void init_bitmap(struct bitmap **bm, const char **ops)
763 bool log_all = False;
768 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
771 DEBUG(0, ("Could not alloc bitmap -- "
772 "defaulting to logging everything\n"));
776 while (*ops != NULL) {
780 if (strequal(*ops, "all")) {
785 if (strequal(*ops, "none")) {
789 for (i=0; i<SMB_VFS_OP_LAST; i++) {
790 if (vfs_op_names[i].name == NULL) {
791 smb_panic("vfs_full_audit.c: name table not "
792 "in sync with vfs.h\n");
795 if (strequal(*ops, vfs_op_names[i].name)) {
801 DEBUG(0, ("Could not find opname %s, logging all\n",
810 /* The query functions default to True */
816 static const char *audit_opname(vfs_op_type op)
818 if (op >= SMB_VFS_OP_LAST)
819 return "INVALID VFS OP";
820 return vfs_op_names[op].name;
823 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
824 const char *format, ...)
827 char *audit_pre = NULL;
831 if (success && (!log_success(handle, op)))
834 if (!success && (!log_failure(handle, op)))
838 fstrcpy(err_msg, "ok");
840 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
842 va_start(ap, format);
843 op_msg = talloc_vasprintf(NULL, format, ap);
850 audit_pre = audit_prefix(NULL, handle->conn);
851 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
852 audit_pre ? audit_pre : "",
853 audit_opname(op), err_msg, op_msg);
855 TALLOC_FREE(audit_pre);
861 /* Free function for the private data. */
863 static void free_private_data(void **p_data)
865 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
867 if (pd->success_ops) {
868 bitmap_free(pd->success_ops);
870 if (pd->failure_ops) {
871 bitmap_free(pd->failure_ops);
877 /* Implementation of vfs_ops. Pass everything on to the default
878 operation but log event first. */
880 static int smb_full_audit_connect(vfs_handle_struct *handle,
881 const char *svc, const char *user)
884 struct vfs_full_audit_private_data *pd = NULL;
885 const char *none[] = { NULL };
886 const char *all [] = { "all" };
892 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
898 openlog("smbd_audit", 0, audit_syslog_facility(handle));
900 init_bitmap(&pd->success_ops,
901 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
903 init_bitmap(&pd->failure_ops,
904 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
907 /* Store the private data. */
908 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
909 struct vfs_full_audit_private_data, return -1);
911 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
913 do_log(SMB_VFS_OP_CONNECT, True, handle,
919 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
921 SMB_VFS_NEXT_DISCONNECT(handle);
923 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
924 "%s", lp_servicename(SNUM(handle->conn)));
926 /* The bitmaps will be disconnected when the private
932 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
934 bool small_query, uint64_t *bsize,
935 uint64_t *dfree, uint64_t *dsize)
939 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
942 /* Don't have a reasonable notion of failure here */
944 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
949 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
950 enum SMB_QUOTA_TYPE qtype, unid_t id,
955 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
957 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
963 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
964 enum SMB_QUOTA_TYPE qtype, unid_t id,
969 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
971 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
976 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
977 struct files_struct *fsp,
978 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
982 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
984 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
989 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
991 struct vfs_statvfs_struct *statbuf)
995 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
997 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1002 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1003 const char *fname, const char *mask, uint32 attr)
1005 SMB_STRUCT_DIR *result;
1007 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1009 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1014 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1015 SMB_STRUCT_DIR *dirp)
1017 SMB_STRUCT_DIRENT *result;
1019 result = SMB_VFS_NEXT_READDIR(handle, dirp);
1021 /* This operation has no reasonable error condition
1022 * (End of dir is also failure), so always succeed.
1024 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1029 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1030 SMB_STRUCT_DIR *dirp, long offset)
1032 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1034 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1038 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1039 SMB_STRUCT_DIR *dirp)
1043 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1045 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1050 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1051 SMB_STRUCT_DIR *dirp)
1053 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1055 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1059 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1060 const char *path, mode_t mode)
1064 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1066 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1071 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1076 result = SMB_VFS_NEXT_RMDIR(handle, path);
1078 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1083 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1084 SMB_STRUCT_DIR *dirp)
1088 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1090 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1095 static int smb_full_audit_open(vfs_handle_struct *handle,
1096 const char *fname, files_struct *fsp, int flags, mode_t mode)
1100 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1102 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1103 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1109 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1110 struct smb_request *req,
1111 uint16_t root_dir_fid,
1114 uint32_t access_mask,
1115 uint32_t share_access,
1116 uint32_t create_disposition,
1117 uint32_t create_options,
1118 uint32_t file_attributes,
1119 uint32_t oplock_request,
1120 uint64_t allocation_size,
1121 struct security_descriptor *sd,
1122 struct ea_list *ea_list,
1123 files_struct **result_fsp,
1125 SMB_STRUCT_STAT *psbuf)
1129 result = SMB_VFS_NEXT_CREATE_FILE(
1130 handle, /* handle */
1132 root_dir_fid, /* root_dir_fid */
1134 is_dos_path, /* is_dos_path */
1135 access_mask, /* access_mask */
1136 share_access, /* share_access */
1137 create_disposition, /* create_disposition*/
1138 create_options, /* create_options */
1139 file_attributes, /* file_attributes */
1140 oplock_request, /* oplock_request */
1141 allocation_size, /* allocation_size */
1143 ea_list, /* ea_list */
1144 result_fsp, /* result */
1148 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1149 access_mask, fname);
1154 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1158 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1160 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1165 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1166 void *data, size_t n)
1170 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1172 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1177 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1178 void *data, size_t n, SMB_OFF_T offset)
1182 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1184 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1189 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1190 const void *data, size_t n)
1194 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1196 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1201 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1202 const void *data, size_t n,
1207 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1209 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1214 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1215 SMB_OFF_T offset, int whence)
1219 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1221 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1222 "%s", fsp->fsp_name);
1227 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1228 files_struct *fromfsp,
1229 const DATA_BLOB *hdr, SMB_OFF_T offset,
1234 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1236 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1237 "%s", fromfsp->fsp_name);
1242 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1243 files_struct *tofsp,
1249 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1251 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1252 "%s", tofsp->fsp_name);
1257 static int smb_full_audit_rename(vfs_handle_struct *handle,
1258 const char *oldname, const char *newname)
1262 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1264 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1269 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1273 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1275 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1280 static int smb_full_audit_stat(vfs_handle_struct *handle,
1281 const char *fname, SMB_STRUCT_STAT *sbuf)
1285 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1287 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1292 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1293 SMB_STRUCT_STAT *sbuf)
1297 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1299 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1304 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1305 const char *path, SMB_STRUCT_STAT *sbuf)
1309 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1311 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1316 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1321 result = SMB_VFS_NEXT_UNLINK(handle, path);
1323 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1328 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1329 const char *path, mode_t mode)
1333 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1335 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1340 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1345 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1347 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1348 "%s|%o", fsp->fsp_name, mode);
1353 static int smb_full_audit_chown(vfs_handle_struct *handle,
1354 const char *path, uid_t uid, gid_t gid)
1358 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1360 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1361 path, (long int)uid, (long int)gid);
1366 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1367 uid_t uid, gid_t gid)
1371 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1373 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1374 fsp->fsp_name, (long int)uid, (long int)gid);
1379 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1380 const char *path, uid_t uid, gid_t gid)
1384 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1386 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1387 path, (long int)uid, (long int)gid);
1392 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1397 result = SMB_VFS_NEXT_CHDIR(handle, path);
1399 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1404 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1409 result = SMB_VFS_NEXT_GETWD(handle, path);
1411 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1416 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1417 const char *path, const struct timespec ts[2])
1421 result = SMB_VFS_NEXT_NTIMES(handle, path, ts);
1423 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1428 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1433 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1435 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1436 "%s", fsp->fsp_name);
1441 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1442 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1446 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1448 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1453 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1454 struct files_struct *fsp,
1459 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1461 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1467 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1472 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1474 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1480 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1481 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1485 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1487 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1492 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1493 const char *oldpath, const char *newpath)
1497 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1499 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1500 "%s|%s", oldpath, newpath);
1505 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1506 const char *path, char *buf, size_t bufsiz)
1510 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1512 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1517 static int smb_full_audit_link(vfs_handle_struct *handle,
1518 const char *oldpath, const char *newpath)
1522 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1524 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1525 "%s|%s", oldpath, newpath);
1530 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1531 const char *pathname, mode_t mode, SMB_DEV_T dev)
1535 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1537 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1542 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1543 const char *path, char *resolved_path)
1547 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1549 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1554 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1555 struct sys_notify_context *ctx,
1556 struct notify_entry *e,
1557 void (*callback)(struct sys_notify_context *ctx,
1559 struct notify_event *ev),
1560 void *private_data, void *handle_p)
1564 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1566 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1571 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1572 const char *path, unsigned int flags)
1576 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1578 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1583 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1584 SMB_DEV_T dev, SMB_INO_T inode)
1586 struct file_id id_zero;
1587 struct file_id result;
1589 ZERO_STRUCT(id_zero);
1591 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode);
1593 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1594 !file_id_equal(&id_zero, &result),
1595 handle, "%s", file_id_string_tos(&result));
1600 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1601 struct files_struct *fsp,
1603 TALLOC_CTX *mem_ctx,
1604 unsigned int *pnum_streams,
1605 struct stream_struct **pstreams)
1609 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1610 pnum_streams, pstreams);
1612 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1618 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1619 uint32 security_info,
1624 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1626 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1627 "%s", fsp->fsp_name);
1632 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1634 uint32 security_info,
1639 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1641 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1647 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1648 uint32 security_info_sent,
1649 const SEC_DESC *psd)
1653 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1655 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1660 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1661 const char *path, mode_t mode)
1665 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1667 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1668 "%s|%o", path, mode);
1673 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1678 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1680 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1681 "%s|%o", fsp->fsp_name, mode);
1686 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1688 SMB_ACL_T theacl, int entry_id,
1689 SMB_ACL_ENTRY_T *entry_p)
1693 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1696 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1702 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1704 SMB_ACL_ENTRY_T entry_d,
1705 SMB_ACL_TAG_T *tag_type_p)
1709 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1712 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1718 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1720 SMB_ACL_ENTRY_T entry_d,
1721 SMB_ACL_PERMSET_T *permset_p)
1725 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1728 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1734 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1736 SMB_ACL_ENTRY_T entry_d)
1740 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1742 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1748 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1750 SMB_ACL_TYPE_T type)
1754 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1756 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1762 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1767 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1769 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1770 "%s", fsp->fsp_name);
1775 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1777 SMB_ACL_PERMSET_T permset)
1781 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1783 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1789 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1791 SMB_ACL_PERMSET_T permset,
1792 SMB_ACL_PERM_T perm)
1796 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1798 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1804 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1810 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1812 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1818 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1824 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1826 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1832 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1834 SMB_ACL_ENTRY_T *pentry)
1838 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1840 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1846 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1848 SMB_ACL_ENTRY_T entry,
1849 SMB_ACL_TAG_T tagtype)
1853 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1856 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1862 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1864 SMB_ACL_ENTRY_T entry,
1869 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1871 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1877 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1879 SMB_ACL_ENTRY_T entry,
1880 SMB_ACL_PERMSET_T permset)
1884 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1886 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1892 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1898 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1900 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1906 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1908 const char *name, SMB_ACL_TYPE_T acltype,
1913 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1916 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1922 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1927 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1929 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1930 "%s", fsp->fsp_name);
1935 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1941 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1943 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1949 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1951 SMB_ACL_PERMSET_T permset,
1952 SMB_ACL_PERM_T perm)
1956 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1958 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1964 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1970 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1972 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1978 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1980 SMB_ACL_T posix_acl)
1984 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1986 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1992 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1994 SMB_ACL_TAG_T tagtype)
1998 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2001 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2007 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2009 const char *name, void *value, size_t size)
2013 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2015 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2016 "%s|%s", path, name);
2021 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2022 const char *path, const char *name,
2023 void *value, size_t size)
2027 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2029 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2030 "%s|%s", path, name);
2035 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2036 struct files_struct *fsp,
2037 const char *name, void *value, size_t size)
2041 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2043 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2044 "%s|%s", fsp->fsp_name, name);
2049 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2050 const char *path, char *list, size_t size)
2054 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2056 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2061 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2062 const char *path, char *list, size_t size)
2066 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2068 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2073 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2074 struct files_struct *fsp, char *list,
2079 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2081 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2082 "%s", fsp->fsp_name);
2087 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2093 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2095 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2096 "%s|%s", path, name);
2101 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2107 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2109 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2110 "%s|%s", path, name);
2115 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2116 struct files_struct *fsp,
2121 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2123 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2124 "%s|%s", fsp->fsp_name, name);
2129 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2131 const char *name, const void *value, size_t size,
2136 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2139 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2140 "%s|%s", path, name);
2145 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2147 const char *name, const void *value, size_t size,
2152 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2155 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2156 "%s|%s", path, name);
2161 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2162 struct files_struct *fsp, const char *name,
2163 const void *value, size_t size, int flags)
2167 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2169 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2170 "%s|%s", fsp->fsp_name, name);
2175 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2179 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2180 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2181 "%s", fsp->fsp_name);
2186 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2190 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2191 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2192 "%s", fsp->fsp_name);
2197 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2201 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2202 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2203 "%s", fsp->fsp_name);
2208 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2212 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2213 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2214 "%s", fsp->fsp_name);
2219 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2223 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2224 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2225 "%s", fsp->fsp_name);
2230 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2234 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2235 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2236 "%s", fsp->fsp_name);
2241 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)
2245 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2246 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2247 "%s", fsp->fsp_name);
2253 NTSTATUS vfs_full_audit_init(void);
2254 NTSTATUS vfs_full_audit_init(void)
2256 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2257 "full_audit", audit_op_tuples);
2259 if (!NT_STATUS_IS_OK(ret))
2262 vfs_full_audit_debug_level = debug_add_class("full_audit");
2263 if (vfs_full_audit_debug_level == -1) {
2264 vfs_full_audit_debug_level = DBGC_VFS;
2265 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2268 DEBUG(10, ("vfs_full_audit: Debug class number of "
2269 "'full_audit': %d\n", vfs_full_audit_debug_level));