s3: Add an async smbsock_connect
[Samba.git] / source3 / modules / vfs_full_audit.c
blobac7f7a3cc87d38efcbbdecf568f33f149e7f0dea
1 /*
2 * Auditing VFS module for samba. Log selected file operations to syslog
3 * facility.
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:
30 * [tmp]
31 * path = /tmp
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.
47 * Options:
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.
60 #include "includes.h"
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;
69 #undef DBGC_CLASS
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,
78 const char *path,
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,
83 SMB_DISK_QUOTA *qt);
84 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
85 enum SMB_QUOTA_TYPE qtype, unid_t id,
86 SMB_DISK_QUOTA *qt);
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,
91 const char *path,
92 struct vfs_statvfs_struct *statbuf);
93 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle);
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 SMB_STRUCT_STAT *sbuf);
99 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
100 SMB_STRUCT_DIR *dirp, long offset);
101 static long smb_full_audit_telldir(vfs_handle_struct *handle,
102 SMB_STRUCT_DIR *dirp);
103 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
104 SMB_STRUCT_DIR *dirp);
105 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
106 const char *path, mode_t mode);
107 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
108 const char *path);
109 static int smb_full_audit_closedir(vfs_handle_struct *handle,
110 SMB_STRUCT_DIR *dirp);
111 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
112 SMB_STRUCT_DIR *dirp);
113 static int smb_full_audit_open(vfs_handle_struct *handle,
114 const char *fname, files_struct *fsp, int flags, mode_t mode);
115 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
116 struct smb_request *req,
117 uint16_t root_dir_fid,
118 const char *fname,
119 uint32_t create_file_flags,
120 uint32_t access_mask,
121 uint32_t share_access,
122 uint32_t create_disposition,
123 uint32_t create_options,
124 uint32_t file_attributes,
125 uint32_t oplock_request,
126 uint64_t allocation_size,
127 struct security_descriptor *sd,
128 struct ea_list *ea_list,
129 files_struct **result,
130 int *pinfo,
131 SMB_STRUCT_STAT *psbuf);
132 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
133 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
134 void *data, size_t n);
135 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
136 void *data, size_t n, SMB_OFF_T offset);
137 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
138 const void *data, size_t n);
139 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
140 const void *data, size_t n,
141 SMB_OFF_T offset);
142 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
143 SMB_OFF_T offset, int whence);
144 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
145 files_struct *fromfsp,
146 const DATA_BLOB *hdr, SMB_OFF_T offset,
147 size_t n);
148 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
149 files_struct *tofsp,
150 SMB_OFF_T offset,
151 size_t n);
152 static int smb_full_audit_rename(vfs_handle_struct *handle,
153 const char *oldname, const char *newname);
154 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
155 static int smb_full_audit_stat(vfs_handle_struct *handle,
156 const char *fname, SMB_STRUCT_STAT *sbuf);
157 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
158 SMB_STRUCT_STAT *sbuf);
159 static int smb_full_audit_lstat(vfs_handle_struct *handle,
160 const char *path, SMB_STRUCT_STAT *sbuf);
161 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
162 files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
163 static int smb_full_audit_unlink(vfs_handle_struct *handle,
164 const char *path);
165 static int smb_full_audit_chmod(vfs_handle_struct *handle,
166 const char *path, mode_t mode);
167 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
168 mode_t mode);
169 static int smb_full_audit_chown(vfs_handle_struct *handle,
170 const char *path, uid_t uid, gid_t gid);
171 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
172 uid_t uid, gid_t gid);
173 static int smb_full_audit_lchown(vfs_handle_struct *handle,
174 const char *path, uid_t uid, gid_t gid);
175 static int smb_full_audit_chdir(vfs_handle_struct *handle,
176 const char *path);
177 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
178 char *path);
179 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
180 const char *path, struct smb_file_time *ft);
181 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
182 SMB_OFF_T len);
183 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
184 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
185 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
186 struct files_struct *fsp,
187 uint32 share_mode);
188 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
189 int leasetype);
190 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
191 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
192 static int smb_full_audit_symlink(vfs_handle_struct *handle,
193 const char *oldpath, const char *newpath);
194 static int smb_full_audit_readlink(vfs_handle_struct *handle,
195 const char *path, char *buf, size_t bufsiz);
196 static int smb_full_audit_link(vfs_handle_struct *handle,
197 const char *oldpath, const char *newpath);
198 static int smb_full_audit_mknod(vfs_handle_struct *handle,
199 const char *pathname, mode_t mode, SMB_DEV_T dev);
200 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
201 const char *path, char *resolved_path);
202 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
203 struct sys_notify_context *ctx,
204 struct notify_entry *e,
205 void (*callback)(struct sys_notify_context *ctx,
206 void *private_data,
207 struct notify_event *ev),
208 void *private_data, void *handle_p);
209 static int smb_full_audit_chflags(vfs_handle_struct *handle,
210 const char *path, unsigned int flags);
211 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
212 const SMB_STRUCT_STAT *sbuf);
213 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
214 struct files_struct *fsp,
215 const char *fname,
216 TALLOC_CTX *mem_ctx,
217 unsigned int *pnum_streams,
218 struct stream_struct **pstreams);
219 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
220 const char *path,
221 const char *name,
222 TALLOC_CTX *mem_ctx,
223 char **found_name);
224 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
225 struct byte_range_lock *br_lck,
226 struct lock_struct *plock,
227 bool blocking_lock,
228 struct blocking_lock_record *blr);
229 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
230 struct messaging_context *msg_ctx,
231 struct byte_range_lock *br_lck,
232 const struct lock_struct *plock);
233 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
234 struct byte_range_lock *br_lck,
235 struct lock_struct *plock,
236 struct blocking_lock_record *blr);
237 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
238 struct files_struct *fsp,
239 struct lock_struct *plock);
240 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
241 struct files_struct *fsp,
242 struct lock_struct *plock);
243 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
244 uint32 security_info,
245 SEC_DESC **ppdesc);
246 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
247 const char *name, uint32 security_info,
248 SEC_DESC **ppdesc);
249 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
250 uint32 security_info_sent,
251 const SEC_DESC *psd);
252 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
253 const char *path, mode_t mode);
254 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
255 mode_t mode);
256 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
257 SMB_ACL_T theacl, int entry_id,
258 SMB_ACL_ENTRY_T *entry_p);
259 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
260 SMB_ACL_ENTRY_T entry_d,
261 SMB_ACL_TAG_T *tag_type_p);
262 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
263 SMB_ACL_ENTRY_T entry_d,
264 SMB_ACL_PERMSET_T *permset_p);
265 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
266 SMB_ACL_ENTRY_T entry_d);
267 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
268 const char *path_p,
269 SMB_ACL_TYPE_T type);
270 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
271 files_struct *fsp);
272 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
273 SMB_ACL_PERMSET_T permset);
274 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
275 SMB_ACL_PERMSET_T permset,
276 SMB_ACL_PERM_T perm);
277 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
278 SMB_ACL_T theacl,
279 ssize_t *plen);
280 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
281 int count);
282 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
283 SMB_ACL_T *pacl,
284 SMB_ACL_ENTRY_T *pentry);
285 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
286 SMB_ACL_ENTRY_T entry,
287 SMB_ACL_TAG_T tagtype);
288 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
289 SMB_ACL_ENTRY_T entry,
290 void *qual);
291 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
292 SMB_ACL_ENTRY_T entry,
293 SMB_ACL_PERMSET_T permset);
294 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
295 SMB_ACL_T theacl );
296 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
297 const char *name, SMB_ACL_TYPE_T acltype,
298 SMB_ACL_T theacl);
299 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
300 SMB_ACL_T theacl);
301 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
302 const char *path);
303 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
304 SMB_ACL_PERMSET_T permset,
305 SMB_ACL_PERM_T perm);
306 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
307 char *text);
308 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
309 SMB_ACL_T posix_acl);
310 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
311 void *qualifier,
312 SMB_ACL_TAG_T tagtype);
313 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
314 const char *path,
315 const char *name, void *value, size_t size);
316 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
317 const char *path, const char *name,
318 void *value, size_t size);
319 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
320 struct files_struct *fsp,
321 const char *name, void *value, size_t size);
322 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
323 const char *path, char *list, size_t size);
324 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
325 const char *path, char *list, size_t size);
326 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
327 struct files_struct *fsp, char *list,
328 size_t size);
329 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
330 const char *path,
331 const char *name);
332 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
333 const char *path,
334 const char *name);
335 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
336 struct files_struct *fsp,
337 const char *name);
338 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
339 const char *path,
340 const char *name, const void *value, size_t size,
341 int flags);
342 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
343 const char *path,
344 const char *name, const void *value, size_t size,
345 int flags);
346 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
347 struct files_struct *fsp, const char *name,
348 const void *value, size_t size, int flags);
350 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
351 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
352 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
353 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
354 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
355 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
356 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);
357 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
358 struct files_struct *fsp);
360 /* VFS operations */
362 static vfs_op_tuple audit_op_tuples[] = {
364 /* Disk operations */
366 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_fs_capabilities), SMB_VFS_OP_FS_CAPABILITIES,
381 SMB_VFS_LAYER_LOGGER},
383 /* Directory operations */
385 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
386 SMB_VFS_LAYER_LOGGER},
387 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
388 SMB_VFS_LAYER_LOGGER},
389 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
390 SMB_VFS_LAYER_LOGGER},
391 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
392 SMB_VFS_LAYER_LOGGER},
393 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
394 SMB_VFS_LAYER_LOGGER},
395 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
396 SMB_VFS_LAYER_LOGGER},
397 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
398 SMB_VFS_LAYER_LOGGER},
399 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
400 SMB_VFS_LAYER_LOGGER},
401 {SMB_VFS_OP(smb_full_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
402 SMB_VFS_LAYER_LOGGER},
404 /* File operations */
406 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_create_file),SMB_VFS_OP_CREATE_FILE,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
415 SMB_VFS_LAYER_LOGGER},
416 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
417 SMB_VFS_LAYER_LOGGER},
418 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
419 SMB_VFS_LAYER_LOGGER},
420 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
421 SMB_VFS_LAYER_LOGGER},
422 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
423 SMB_VFS_LAYER_LOGGER},
424 {SMB_VFS_OP(smb_full_audit_recvfile), SMB_VFS_OP_RECVFILE,
425 SMB_VFS_LAYER_LOGGER},
426 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
427 SMB_VFS_LAYER_LOGGER},
428 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
429 SMB_VFS_LAYER_LOGGER},
430 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_get_alloc_size), SMB_VFS_OP_GET_ALLOC_SIZE,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_lchown), SMB_VFS_OP_LCHOWN,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_ntimes), SMB_VFS_OP_NTIMES,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_kernel_flock), SMB_VFS_OP_KERNEL_FLOCK,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_linux_setlease), SMB_VFS_OP_LINUX_SETLEASE,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
477 SMB_VFS_LAYER_LOGGER},
478 {SMB_VFS_OP(smb_full_audit_chflags), SMB_VFS_OP_CHFLAGS,
479 SMB_VFS_LAYER_LOGGER},
480 {SMB_VFS_OP(smb_full_audit_file_id_create), SMB_VFS_OP_FILE_ID_CREATE,
481 SMB_VFS_LAYER_LOGGER},
482 {SMB_VFS_OP(smb_full_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
483 SMB_VFS_LAYER_LOGGER},
484 {SMB_VFS_OP(smb_full_audit_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
485 SMB_VFS_LAYER_LOGGER},
486 {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
487 SMB_VFS_LAYER_LOGGER},
488 {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
489 SMB_VFS_LAYER_LOGGER},
490 {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
491 SMB_VFS_LAYER_LOGGER},
492 {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
493 SMB_VFS_LAYER_LOGGER},
494 {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
495 SMB_VFS_LAYER_LOGGER},
497 /* NT ACL operations. */
499 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
500 SMB_VFS_LAYER_LOGGER},
501 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
504 SMB_VFS_LAYER_LOGGER},
506 /* POSIX ACL operations. */
508 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
509 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
545 SMB_VFS_LAYER_LOGGER},
546 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
547 SMB_VFS_LAYER_LOGGER},
548 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
549 SMB_VFS_LAYER_LOGGER},
550 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
551 SMB_VFS_LAYER_LOGGER},
552 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
553 SMB_VFS_LAYER_LOGGER},
554 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
555 SMB_VFS_LAYER_LOGGER},
557 /* EA operations. */
559 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
560 SMB_VFS_LAYER_LOGGER},
561 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
562 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
564 SMB_VFS_LAYER_LOGGER},
565 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
566 SMB_VFS_LAYER_LOGGER},
567 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
568 SMB_VFS_LAYER_LOGGER},
569 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
570 SMB_VFS_LAYER_LOGGER},
571 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
572 SMB_VFS_LAYER_LOGGER},
573 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
574 SMB_VFS_LAYER_LOGGER},
575 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
576 SMB_VFS_LAYER_LOGGER},
577 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
578 SMB_VFS_LAYER_LOGGER},
579 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
580 SMB_VFS_LAYER_LOGGER},
581 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
582 SMB_VFS_LAYER_LOGGER},
584 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
585 SMB_VFS_LAYER_LOGGER},
586 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
587 SMB_VFS_LAYER_LOGGER},
588 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
589 SMB_VFS_LAYER_LOGGER},
590 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
591 SMB_VFS_LAYER_LOGGER},
592 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
593 SMB_VFS_LAYER_LOGGER},
594 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
595 SMB_VFS_LAYER_LOGGER},
596 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
597 SMB_VFS_LAYER_LOGGER},
598 {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
599 SMB_VFS_LAYER_LOGGER},
601 /* Finish VFS operations definition */
603 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
604 SMB_VFS_LAYER_NOOP}
607 /* The following array *must* be in the same order as defined in vfs.h */
609 static struct {
610 vfs_op_type type;
611 const char *name;
612 } vfs_op_names[] = {
613 { SMB_VFS_OP_CONNECT, "connect" },
614 { SMB_VFS_OP_DISCONNECT, "disconnect" },
615 { SMB_VFS_OP_DISK_FREE, "disk_free" },
616 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
617 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
618 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
619 { SMB_VFS_OP_STATVFS, "statvfs" },
620 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
621 { SMB_VFS_OP_OPENDIR, "opendir" },
622 { SMB_VFS_OP_READDIR, "readdir" },
623 { SMB_VFS_OP_SEEKDIR, "seekdir" },
624 { SMB_VFS_OP_TELLDIR, "telldir" },
625 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
626 { SMB_VFS_OP_MKDIR, "mkdir" },
627 { SMB_VFS_OP_RMDIR, "rmdir" },
628 { SMB_VFS_OP_CLOSEDIR, "closedir" },
629 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
630 { SMB_VFS_OP_OPEN, "open" },
631 { SMB_VFS_OP_CREATE_FILE, "create_file" },
632 { SMB_VFS_OP_CLOSE, "close" },
633 { SMB_VFS_OP_READ, "read" },
634 { SMB_VFS_OP_PREAD, "pread" },
635 { SMB_VFS_OP_WRITE, "write" },
636 { SMB_VFS_OP_PWRITE, "pwrite" },
637 { SMB_VFS_OP_LSEEK, "lseek" },
638 { SMB_VFS_OP_SENDFILE, "sendfile" },
639 { SMB_VFS_OP_RECVFILE, "recvfile" },
640 { SMB_VFS_OP_RENAME, "rename" },
641 { SMB_VFS_OP_FSYNC, "fsync" },
642 { SMB_VFS_OP_STAT, "stat" },
643 { SMB_VFS_OP_FSTAT, "fstat" },
644 { SMB_VFS_OP_LSTAT, "lstat" },
645 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
646 { SMB_VFS_OP_UNLINK, "unlink" },
647 { SMB_VFS_OP_CHMOD, "chmod" },
648 { SMB_VFS_OP_FCHMOD, "fchmod" },
649 { SMB_VFS_OP_CHOWN, "chown" },
650 { SMB_VFS_OP_FCHOWN, "fchown" },
651 { SMB_VFS_OP_LCHOWN, "lchown" },
652 { SMB_VFS_OP_CHDIR, "chdir" },
653 { SMB_VFS_OP_GETWD, "getwd" },
654 { SMB_VFS_OP_NTIMES, "ntimes" },
655 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
656 { SMB_VFS_OP_LOCK, "lock" },
657 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
658 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
659 { SMB_VFS_OP_GETLOCK, "getlock" },
660 { SMB_VFS_OP_SYMLINK, "symlink" },
661 { SMB_VFS_OP_READLINK, "readlink" },
662 { SMB_VFS_OP_LINK, "link" },
663 { SMB_VFS_OP_MKNOD, "mknod" },
664 { SMB_VFS_OP_REALPATH, "realpath" },
665 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
666 { SMB_VFS_OP_CHFLAGS, "chflags" },
667 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
668 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
669 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
670 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
671 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
672 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
673 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
674 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
675 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
676 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
677 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
678 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
679 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
680 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
681 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
682 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
683 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
684 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
685 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
686 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
687 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
688 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
689 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
690 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
691 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
692 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
693 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
694 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
695 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
696 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
697 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
698 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
699 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
700 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
701 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
702 { SMB_VFS_OP_GETXATTR, "getxattr" },
703 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
704 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
705 { SMB_VFS_OP_LISTXATTR, "listxattr" },
706 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
707 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
708 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
709 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
710 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
711 { SMB_VFS_OP_SETXATTR, "setxattr" },
712 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
713 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
714 { SMB_VFS_OP_AIO_READ, "aio_read" },
715 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
716 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
717 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
718 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
719 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
720 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
721 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
722 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
723 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
724 { SMB_VFS_OP_LAST, NULL }
727 static int audit_syslog_facility(vfs_handle_struct *handle)
729 static const struct enum_list enum_log_facilities[] = {
730 { LOG_USER, "USER" },
731 { LOG_LOCAL0, "LOCAL0" },
732 { LOG_LOCAL1, "LOCAL1" },
733 { LOG_LOCAL2, "LOCAL2" },
734 { LOG_LOCAL3, "LOCAL3" },
735 { LOG_LOCAL4, "LOCAL4" },
736 { LOG_LOCAL5, "LOCAL5" },
737 { LOG_LOCAL6, "LOCAL6" },
738 { LOG_LOCAL7, "LOCAL7" }
741 int facility;
743 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
745 return facility;
748 static int audit_syslog_priority(vfs_handle_struct *handle)
750 static const struct enum_list enum_log_priorities[] = {
751 { LOG_EMERG, "EMERG" },
752 { LOG_ALERT, "ALERT" },
753 { LOG_CRIT, "CRIT" },
754 { LOG_ERR, "ERR" },
755 { LOG_WARNING, "WARNING" },
756 { LOG_NOTICE, "NOTICE" },
757 { LOG_INFO, "INFO" },
758 { LOG_DEBUG, "DEBUG" }
761 int priority;
763 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
764 enum_log_priorities, LOG_NOTICE);
765 if (priority == -1) {
766 priority = LOG_WARNING;
769 return priority;
772 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
774 char *prefix = NULL;
775 char *result;
777 prefix = talloc_strdup(ctx,
778 lp_parm_const_string(SNUM(conn), "full_audit",
779 "prefix", "%u|%I"));
780 if (!prefix) {
781 return NULL;
783 result = talloc_sub_advanced(ctx,
784 lp_servicename(SNUM(conn)),
785 conn->server_info->unix_name,
786 conn->connectpath,
787 conn->server_info->utok.gid,
788 conn->server_info->sanitized_username,
789 pdb_get_domain(conn->server_info->sam_account),
790 prefix);
791 TALLOC_FREE(prefix);
792 return result;
795 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
797 struct vfs_full_audit_private_data *pd = NULL;
799 SMB_VFS_HANDLE_GET_DATA(handle, pd,
800 struct vfs_full_audit_private_data,
801 return True);
803 if (pd->success_ops == NULL) {
804 return True;
807 return bitmap_query(pd->success_ops, op);
810 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
812 struct vfs_full_audit_private_data *pd = NULL;
814 SMB_VFS_HANDLE_GET_DATA(handle, pd,
815 struct vfs_full_audit_private_data,
816 return True);
818 if (pd->failure_ops == NULL)
819 return True;
821 return bitmap_query(pd->failure_ops, op);
824 static void init_bitmap(struct bitmap **bm, const char **ops)
826 bool log_all = False;
828 if (*bm != NULL)
829 return;
831 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
833 if (*bm == NULL) {
834 DEBUG(0, ("Could not alloc bitmap -- "
835 "defaulting to logging everything\n"));
836 return;
839 while (*ops != NULL) {
840 int i;
841 bool found = False;
843 if (strequal(*ops, "all")) {
844 log_all = True;
845 break;
848 if (strequal(*ops, "none")) {
849 break;
852 for (i=0; i<SMB_VFS_OP_LAST; i++) {
853 if (vfs_op_names[i].name == NULL) {
854 smb_panic("vfs_full_audit.c: name table not "
855 "in sync with vfs.h\n");
858 if (strequal(*ops, vfs_op_names[i].name)) {
859 bitmap_set(*bm, i);
860 found = True;
863 if (!found) {
864 DEBUG(0, ("Could not find opname %s, logging all\n",
865 *ops));
866 log_all = True;
867 break;
869 ops += 1;
872 if (log_all) {
873 /* The query functions default to True */
874 bitmap_free(*bm);
875 *bm = NULL;
879 static const char *audit_opname(vfs_op_type op)
881 if (op >= SMB_VFS_OP_LAST)
882 return "INVALID VFS OP";
883 return vfs_op_names[op].name;
886 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
887 const char *format, ...)
889 fstring err_msg;
890 char *audit_pre = NULL;
891 va_list ap;
892 char *op_msg = NULL;
894 if (success && (!log_success(handle, op)))
895 return;
897 if (!success && (!log_failure(handle, op)))
898 return;
900 if (success)
901 fstrcpy(err_msg, "ok");
902 else
903 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
905 va_start(ap, format);
906 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
907 va_end(ap);
909 if (!op_msg) {
910 return;
913 audit_pre = audit_prefix(talloc_tos(), handle->conn);
914 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
915 audit_pre ? audit_pre : "",
916 audit_opname(op), err_msg, op_msg);
918 TALLOC_FREE(audit_pre);
919 TALLOC_FREE(op_msg);
921 return;
924 /* Free function for the private data. */
926 static void free_private_data(void **p_data)
928 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
930 if (pd->success_ops) {
931 bitmap_free(pd->success_ops);
933 if (pd->failure_ops) {
934 bitmap_free(pd->failure_ops);
936 SAFE_FREE(pd);
937 *p_data = NULL;
940 /* Implementation of vfs_ops. Pass everything on to the default
941 operation but log event first. */
943 static int smb_full_audit_connect(vfs_handle_struct *handle,
944 const char *svc, const char *user)
946 int result;
947 struct vfs_full_audit_private_data *pd = NULL;
948 const char *none[] = { NULL };
949 const char *all [] = { "all" };
951 if (!handle) {
952 return -1;
955 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
956 if (!pd) {
957 return -1;
959 ZERO_STRUCTP(pd);
961 openlog("smbd_audit", 0, audit_syslog_facility(handle));
963 init_bitmap(&pd->success_ops,
964 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
965 none));
966 init_bitmap(&pd->failure_ops,
967 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
968 all));
970 /* Store the private data. */
971 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
972 struct vfs_full_audit_private_data, return -1);
974 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
976 do_log(SMB_VFS_OP_CONNECT, True, handle,
977 "%s", svc);
979 return result;
982 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
984 SMB_VFS_NEXT_DISCONNECT(handle);
986 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
987 "%s", lp_servicename(SNUM(handle->conn)));
989 /* The bitmaps will be disconnected when the private
990 data is deleted. */
992 return;
995 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
996 const char *path,
997 bool small_query, uint64_t *bsize,
998 uint64_t *dfree, uint64_t *dsize)
1000 uint64_t result;
1002 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
1003 dfree, dsize);
1005 /* Don't have a reasonable notion of failure here */
1007 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
1009 return result;
1012 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
1013 enum SMB_QUOTA_TYPE qtype, unid_t id,
1014 SMB_DISK_QUOTA *qt)
1016 int result;
1018 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
1020 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
1022 return result;
1026 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
1027 enum SMB_QUOTA_TYPE qtype, unid_t id,
1028 SMB_DISK_QUOTA *qt)
1030 int result;
1032 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
1034 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
1036 return result;
1039 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1040 struct files_struct *fsp,
1041 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1043 int result;
1045 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1047 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1049 return result;
1052 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1053 const char *path,
1054 struct vfs_statvfs_struct *statbuf)
1056 int result;
1058 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1060 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1062 return result;
1065 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
1067 int result;
1069 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
1071 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
1073 return result;
1076 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1077 const char *fname, const char *mask, uint32 attr)
1079 SMB_STRUCT_DIR *result;
1081 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1083 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1085 return result;
1088 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1089 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1091 SMB_STRUCT_DIRENT *result;
1093 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1095 /* This operation has no reasonable error condition
1096 * (End of dir is also failure), so always succeed.
1098 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1100 return result;
1103 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1104 SMB_STRUCT_DIR *dirp, long offset)
1106 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1108 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1109 return;
1112 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1113 SMB_STRUCT_DIR *dirp)
1115 long result;
1117 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1119 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1121 return result;
1124 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1125 SMB_STRUCT_DIR *dirp)
1127 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1129 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1130 return;
1133 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1134 const char *path, mode_t mode)
1136 int result;
1138 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1140 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1142 return result;
1145 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1146 const char *path)
1148 int result;
1150 result = SMB_VFS_NEXT_RMDIR(handle, path);
1152 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1154 return result;
1157 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1158 SMB_STRUCT_DIR *dirp)
1160 int result;
1162 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1164 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1166 return result;
1169 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1170 SMB_STRUCT_DIR *dirp)
1172 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1174 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1175 return;
1178 static int smb_full_audit_open(vfs_handle_struct *handle,
1179 const char *fname, files_struct *fsp, int flags, mode_t mode)
1181 int result;
1183 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1185 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1186 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1187 fname);
1189 return result;
1192 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1193 struct smb_request *req,
1194 uint16_t root_dir_fid,
1195 const char *fname,
1196 uint32_t create_file_flags,
1197 uint32_t access_mask,
1198 uint32_t share_access,
1199 uint32_t create_disposition,
1200 uint32_t create_options,
1201 uint32_t file_attributes,
1202 uint32_t oplock_request,
1203 uint64_t allocation_size,
1204 struct security_descriptor *sd,
1205 struct ea_list *ea_list,
1206 files_struct **result_fsp,
1207 int *pinfo,
1208 SMB_STRUCT_STAT *psbuf)
1210 NTSTATUS result;
1212 result = SMB_VFS_NEXT_CREATE_FILE(
1213 handle, /* handle */
1214 req, /* req */
1215 root_dir_fid, /* root_dir_fid */
1216 fname, /* fname */
1217 create_file_flags, /* create_file_flags */
1218 access_mask, /* access_mask */
1219 share_access, /* share_access */
1220 create_disposition, /* create_disposition*/
1221 create_options, /* create_options */
1222 file_attributes, /* file_attributes */
1223 oplock_request, /* oplock_request */
1224 allocation_size, /* allocation_size */
1225 sd, /* sd */
1226 ea_list, /* ea_list */
1227 result_fsp, /* result */
1228 pinfo, /* pinfo */
1229 psbuf); /* psbuf */
1231 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1232 access_mask, fname);
1234 return result;
1237 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1239 int result;
1241 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1243 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1245 return result;
1248 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1249 void *data, size_t n)
1251 ssize_t result;
1253 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1255 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1257 return result;
1260 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1261 void *data, size_t n, SMB_OFF_T offset)
1263 ssize_t result;
1265 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1267 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1269 return result;
1272 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1273 const void *data, size_t n)
1275 ssize_t result;
1277 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1279 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1281 return result;
1284 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1285 const void *data, size_t n,
1286 SMB_OFF_T offset)
1288 ssize_t result;
1290 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1292 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1294 return result;
1297 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1298 SMB_OFF_T offset, int whence)
1300 ssize_t result;
1302 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1304 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1305 "%s", fsp->fsp_name);
1307 return result;
1310 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1311 files_struct *fromfsp,
1312 const DATA_BLOB *hdr, SMB_OFF_T offset,
1313 size_t n)
1315 ssize_t result;
1317 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1319 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1320 "%s", fromfsp->fsp_name);
1322 return result;
1325 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1326 files_struct *tofsp,
1327 SMB_OFF_T offset,
1328 size_t n)
1330 ssize_t result;
1332 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1334 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1335 "%s", tofsp->fsp_name);
1337 return result;
1340 static int smb_full_audit_rename(vfs_handle_struct *handle,
1341 const char *oldname, const char *newname)
1343 int result;
1345 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1347 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1349 return result;
1352 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1354 int result;
1356 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1358 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1360 return result;
1363 static int smb_full_audit_stat(vfs_handle_struct *handle,
1364 const char *fname, SMB_STRUCT_STAT *sbuf)
1366 int result;
1368 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1370 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1372 return result;
1375 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1376 SMB_STRUCT_STAT *sbuf)
1378 int result;
1380 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1382 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1384 return result;
1387 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1388 const char *path, SMB_STRUCT_STAT *sbuf)
1390 int result;
1392 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1394 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1396 return result;
1399 static uint64_t smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1400 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1402 uint64_t result;
1404 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1406 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result != (uint64_t)-1), handle, "%llu", result);
1408 return result;
1411 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1412 const char *path)
1414 int result;
1416 result = SMB_VFS_NEXT_UNLINK(handle, path);
1418 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1420 return result;
1423 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1424 const char *path, mode_t mode)
1426 int result;
1428 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1430 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1432 return result;
1435 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1436 mode_t mode)
1438 int result;
1440 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1442 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1443 "%s|%o", fsp->fsp_name, mode);
1445 return result;
1448 static int smb_full_audit_chown(vfs_handle_struct *handle,
1449 const char *path, uid_t uid, gid_t gid)
1451 int result;
1453 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1455 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1456 path, (long int)uid, (long int)gid);
1458 return result;
1461 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1462 uid_t uid, gid_t gid)
1464 int result;
1466 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1468 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1469 fsp->fsp_name, (long int)uid, (long int)gid);
1471 return result;
1474 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1475 const char *path, uid_t uid, gid_t gid)
1477 int result;
1479 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1481 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1482 path, (long int)uid, (long int)gid);
1484 return result;
1487 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1488 const char *path)
1490 int result;
1492 result = SMB_VFS_NEXT_CHDIR(handle, path);
1494 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1496 return result;
1499 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1500 char *path)
1502 char *result;
1504 result = SMB_VFS_NEXT_GETWD(handle, path);
1506 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1508 return result;
1511 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1512 const char *path, struct smb_file_time *ft)
1514 int result;
1516 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1518 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1520 return result;
1523 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1524 SMB_OFF_T len)
1526 int result;
1528 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1530 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1531 "%s", fsp->fsp_name);
1533 return result;
1536 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1537 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1539 bool result;
1541 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1543 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1545 return result;
1548 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1549 struct files_struct *fsp,
1550 uint32 share_mode)
1552 int result;
1554 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1556 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1557 fsp->fsp_name);
1559 return result;
1562 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1563 int leasetype)
1565 int result;
1567 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1569 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1570 fsp->fsp_name);
1572 return result;
1575 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1576 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1578 bool result;
1580 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1582 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1584 return result;
1587 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1588 const char *oldpath, const char *newpath)
1590 int result;
1592 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1594 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1595 "%s|%s", oldpath, newpath);
1597 return result;
1600 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1601 const char *path, char *buf, size_t bufsiz)
1603 int result;
1605 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1607 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1609 return result;
1612 static int smb_full_audit_link(vfs_handle_struct *handle,
1613 const char *oldpath, const char *newpath)
1615 int result;
1617 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1619 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1620 "%s|%s", oldpath, newpath);
1622 return result;
1625 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1626 const char *pathname, mode_t mode, SMB_DEV_T dev)
1628 int result;
1630 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1632 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1634 return result;
1637 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1638 const char *path, char *resolved_path)
1640 char *result;
1642 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1644 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1646 return result;
1649 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1650 struct sys_notify_context *ctx,
1651 struct notify_entry *e,
1652 void (*callback)(struct sys_notify_context *ctx,
1653 void *private_data,
1654 struct notify_event *ev),
1655 void *private_data, void *handle_p)
1657 NTSTATUS result;
1659 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1661 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1663 return result;
1666 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1667 const char *path, unsigned int flags)
1669 int result;
1671 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1673 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1675 return result;
1678 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1679 const SMB_STRUCT_STAT *sbuf)
1681 struct file_id id_zero;
1682 struct file_id result;
1684 ZERO_STRUCT(id_zero);
1686 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1688 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1689 !file_id_equal(&id_zero, &result),
1690 handle, "%s", file_id_string_tos(&result));
1692 return result;
1695 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1696 struct files_struct *fsp,
1697 const char *fname,
1698 TALLOC_CTX *mem_ctx,
1699 unsigned int *pnum_streams,
1700 struct stream_struct **pstreams)
1702 NTSTATUS result;
1704 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1705 pnum_streams, pstreams);
1707 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1708 "%s", fname);
1710 return result;
1713 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1714 const char *path,
1715 const char *name,
1716 TALLOC_CTX *mem_ctx,
1717 char **found_name)
1719 int result;
1721 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1722 found_name);
1724 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1725 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1727 return result;
1730 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1731 struct byte_range_lock *br_lck,
1732 struct lock_struct *plock,
1733 bool blocking_lock,
1734 struct blocking_lock_record *blr)
1736 NTSTATUS result;
1738 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1739 blocking_lock, blr);
1741 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1742 "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1743 plock->start, plock->size, plock->lock_type, blocking_lock );
1745 return result;
1748 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1749 struct messaging_context *msg_ctx,
1750 struct byte_range_lock *br_lck,
1751 const struct lock_struct *plock)
1753 bool result;
1755 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1756 plock);
1758 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1759 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1760 plock->size, plock->lock_type);
1762 return result;
1765 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1766 struct byte_range_lock *br_lck,
1767 struct lock_struct *plock,
1768 struct blocking_lock_record *blr)
1770 bool result;
1772 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1774 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1775 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1776 plock->size);
1778 return result;
1781 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1782 struct files_struct *fsp,
1783 struct lock_struct *plock)
1785 bool result;
1787 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1789 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1790 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1791 plock->size);
1793 return result;
1796 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1797 struct files_struct *fsp,
1798 struct lock_struct *plock)
1800 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1802 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1803 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1804 plock->size);
1806 return;
1809 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1810 uint32 security_info,
1811 SEC_DESC **ppdesc)
1813 NTSTATUS result;
1815 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1817 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1818 "%s", fsp->fsp_name);
1820 return result;
1823 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1824 const char *name,
1825 uint32 security_info,
1826 SEC_DESC **ppdesc)
1828 NTSTATUS result;
1830 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1832 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1833 "%s", name);
1835 return result;
1838 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1839 uint32 security_info_sent,
1840 const SEC_DESC *psd)
1842 NTSTATUS result;
1844 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1846 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1848 return result;
1851 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1852 const char *path, mode_t mode)
1854 int result;
1856 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1858 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1859 "%s|%o", path, mode);
1861 return result;
1864 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1865 mode_t mode)
1867 int result;
1869 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1871 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1872 "%s|%o", fsp->fsp_name, mode);
1874 return result;
1877 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1879 SMB_ACL_T theacl, int entry_id,
1880 SMB_ACL_ENTRY_T *entry_p)
1882 int result;
1884 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1885 entry_p);
1887 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1888 "");
1890 return result;
1893 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1895 SMB_ACL_ENTRY_T entry_d,
1896 SMB_ACL_TAG_T *tag_type_p)
1898 int result;
1900 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1901 tag_type_p);
1903 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1904 "");
1906 return result;
1909 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1911 SMB_ACL_ENTRY_T entry_d,
1912 SMB_ACL_PERMSET_T *permset_p)
1914 int result;
1916 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1917 permset_p);
1919 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1920 "");
1922 return result;
1925 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1927 SMB_ACL_ENTRY_T entry_d)
1929 void *result;
1931 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1933 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1934 "");
1936 return result;
1939 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1940 const char *path_p,
1941 SMB_ACL_TYPE_T type)
1943 SMB_ACL_T result;
1945 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1947 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1948 "%s", path_p);
1950 return result;
1953 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1954 files_struct *fsp)
1956 SMB_ACL_T result;
1958 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1960 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1961 "%s", fsp->fsp_name);
1963 return result;
1966 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1968 SMB_ACL_PERMSET_T permset)
1970 int result;
1972 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1974 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1975 "");
1977 return result;
1980 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1982 SMB_ACL_PERMSET_T permset,
1983 SMB_ACL_PERM_T perm)
1985 int result;
1987 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1989 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1990 "");
1992 return result;
1995 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1996 SMB_ACL_T theacl,
1997 ssize_t *plen)
1999 char * result;
2001 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
2003 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
2004 "");
2006 return result;
2009 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
2011 int count)
2013 SMB_ACL_T result;
2015 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
2017 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
2018 "");
2020 return result;
2023 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
2024 SMB_ACL_T *pacl,
2025 SMB_ACL_ENTRY_T *pentry)
2027 int result;
2029 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
2031 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
2032 "");
2034 return result;
2037 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
2039 SMB_ACL_ENTRY_T entry,
2040 SMB_ACL_TAG_T tagtype)
2042 int result;
2044 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2045 tagtype);
2047 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2048 "");
2050 return result;
2053 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2055 SMB_ACL_ENTRY_T entry,
2056 void *qual)
2058 int result;
2060 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2062 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2063 "");
2065 return result;
2068 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2070 SMB_ACL_ENTRY_T entry,
2071 SMB_ACL_PERMSET_T permset)
2073 int result;
2075 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2077 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2078 "");
2080 return result;
2083 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2085 SMB_ACL_T theacl )
2087 int result;
2089 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2091 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2092 "");
2094 return result;
2097 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2099 const char *name, SMB_ACL_TYPE_T acltype,
2100 SMB_ACL_T theacl)
2102 int result;
2104 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2105 theacl);
2107 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2108 "%s", name);
2110 return result;
2113 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2114 SMB_ACL_T theacl)
2116 int result;
2118 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2120 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2121 "%s", fsp->fsp_name);
2123 return result;
2126 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2128 const char *path)
2130 int result;
2132 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2134 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2135 "%s", path);
2137 return result;
2140 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2142 SMB_ACL_PERMSET_T permset,
2143 SMB_ACL_PERM_T perm)
2145 int result;
2147 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2149 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2150 "");
2152 return result;
2155 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2157 char *text)
2159 int result;
2161 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2163 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2164 "");
2166 return result;
2169 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2171 SMB_ACL_T posix_acl)
2173 int result;
2175 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2177 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2178 "");
2180 return result;
2183 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2184 void *qualifier,
2185 SMB_ACL_TAG_T tagtype)
2187 int result;
2189 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2190 tagtype);
2192 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2193 "");
2195 return result;
2198 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2199 const char *path,
2200 const char *name, void *value, size_t size)
2202 ssize_t result;
2204 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2206 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2207 "%s|%s", path, name);
2209 return result;
2212 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2213 const char *path, const char *name,
2214 void *value, size_t size)
2216 ssize_t result;
2218 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2220 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2221 "%s|%s", path, name);
2223 return result;
2226 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2227 struct files_struct *fsp,
2228 const char *name, void *value, size_t size)
2230 ssize_t result;
2232 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2234 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2235 "%s|%s", fsp->fsp_name, name);
2237 return result;
2240 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2241 const char *path, char *list, size_t size)
2243 ssize_t result;
2245 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2247 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2249 return result;
2252 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2253 const char *path, char *list, size_t size)
2255 ssize_t result;
2257 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2259 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2261 return result;
2264 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2265 struct files_struct *fsp, char *list,
2266 size_t size)
2268 ssize_t result;
2270 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2272 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2273 "%s", fsp->fsp_name);
2275 return result;
2278 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2279 const char *path,
2280 const char *name)
2282 int result;
2284 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2286 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2287 "%s|%s", path, name);
2289 return result;
2292 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2293 const char *path,
2294 const char *name)
2296 int result;
2298 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2300 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2301 "%s|%s", path, name);
2303 return result;
2306 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2307 struct files_struct *fsp,
2308 const char *name)
2310 int result;
2312 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2314 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2315 "%s|%s", fsp->fsp_name, name);
2317 return result;
2320 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2321 const char *path,
2322 const char *name, const void *value, size_t size,
2323 int flags)
2325 int result;
2327 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2328 flags);
2330 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2331 "%s|%s", path, name);
2333 return result;
2336 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2337 const char *path,
2338 const char *name, const void *value, size_t size,
2339 int flags)
2341 int result;
2343 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2344 flags);
2346 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2347 "%s|%s", path, name);
2349 return result;
2352 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2353 struct files_struct *fsp, const char *name,
2354 const void *value, size_t size, int flags)
2356 int result;
2358 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2360 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2361 "%s|%s", fsp->fsp_name, name);
2363 return result;
2366 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2368 int result;
2370 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2371 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2372 "%s", fsp->fsp_name);
2374 return result;
2377 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2379 int result;
2381 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2382 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2383 "%s", fsp->fsp_name);
2385 return result;
2388 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2390 int result;
2392 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2393 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2394 "%s", fsp->fsp_name);
2396 return result;
2399 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2401 int result;
2403 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2404 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2405 "%s", fsp->fsp_name);
2407 return result;
2410 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2412 int result;
2414 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2415 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2416 "%s", fsp->fsp_name);
2418 return result;
2421 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2423 int result;
2425 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2426 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2427 "%s", fsp->fsp_name);
2429 return result;
2432 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)
2434 int result;
2436 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2437 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2438 "%s", fsp->fsp_name);
2440 return result;
2443 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2444 struct files_struct *fsp)
2446 bool result;
2448 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2449 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2450 "%s", fsp->fsp_name);
2452 return result;
2455 NTSTATUS vfs_full_audit_init(void);
2456 NTSTATUS vfs_full_audit_init(void)
2458 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2459 "full_audit", audit_op_tuples);
2461 if (!NT_STATUS_IS_OK(ret))
2462 return ret;
2464 vfs_full_audit_debug_level = debug_add_class("full_audit");
2465 if (vfs_full_audit_debug_level == -1) {
2466 vfs_full_audit_debug_level = DBGC_VFS;
2467 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2468 "class!\n"));
2469 } else {
2470 DEBUG(10, ("vfs_full_audit: Debug class number of "
2471 "'full_audit': %d\n", vfs_full_audit_debug_level));
2474 return ret;