s3/packaging: pam_winbind has been moved to section 8.
[Samba/gebeck_regimport.git] / source3 / modules / vfs_full_audit.c
blobe2d08b440fba54a70405f516c1ac5204725e346a
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 struct smb_filename *smb_fname,
119 uint32_t access_mask,
120 uint32_t share_access,
121 uint32_t create_disposition,
122 uint32_t create_options,
123 uint32_t file_attributes,
124 uint32_t oplock_request,
125 uint64_t allocation_size,
126 struct security_descriptor *sd,
127 struct ea_list *ea_list,
128 files_struct **result,
129 int *pinfo);
130 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp);
131 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
132 void *data, size_t n);
133 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
134 void *data, size_t n, SMB_OFF_T offset);
135 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
136 const void *data, size_t n);
137 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
138 const void *data, size_t n,
139 SMB_OFF_T offset);
140 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
141 SMB_OFF_T offset, int whence);
142 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
143 files_struct *fromfsp,
144 const DATA_BLOB *hdr, SMB_OFF_T offset,
145 size_t n);
146 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
147 files_struct *tofsp,
148 SMB_OFF_T offset,
149 size_t n);
150 static int smb_full_audit_rename(vfs_handle_struct *handle,
151 const char *oldname, const char *newname);
152 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp);
153 static int smb_full_audit_stat(vfs_handle_struct *handle,
154 const char *fname, SMB_STRUCT_STAT *sbuf);
155 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
156 SMB_STRUCT_STAT *sbuf);
157 static int smb_full_audit_lstat(vfs_handle_struct *handle,
158 const char *path, SMB_STRUCT_STAT *sbuf);
159 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
160 files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
161 static int smb_full_audit_unlink(vfs_handle_struct *handle,
162 const char *path);
163 static int smb_full_audit_chmod(vfs_handle_struct *handle,
164 const char *path, mode_t mode);
165 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
166 mode_t mode);
167 static int smb_full_audit_chown(vfs_handle_struct *handle,
168 const char *path, uid_t uid, gid_t gid);
169 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
170 uid_t uid, gid_t gid);
171 static int smb_full_audit_lchown(vfs_handle_struct *handle,
172 const char *path, uid_t uid, gid_t gid);
173 static int smb_full_audit_chdir(vfs_handle_struct *handle,
174 const char *path);
175 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
176 char *path);
177 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
178 const char *path, struct smb_file_time *ft);
179 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
180 SMB_OFF_T len);
181 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
182 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
183 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
184 struct files_struct *fsp,
185 uint32 share_mode);
186 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
187 int leasetype);
188 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
189 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
190 static int smb_full_audit_symlink(vfs_handle_struct *handle,
191 const char *oldpath, const char *newpath);
192 static int smb_full_audit_readlink(vfs_handle_struct *handle,
193 const char *path, char *buf, size_t bufsiz);
194 static int smb_full_audit_link(vfs_handle_struct *handle,
195 const char *oldpath, const char *newpath);
196 static int smb_full_audit_mknod(vfs_handle_struct *handle,
197 const char *pathname, mode_t mode, SMB_DEV_T dev);
198 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
199 const char *path, char *resolved_path);
200 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
201 struct sys_notify_context *ctx,
202 struct notify_entry *e,
203 void (*callback)(struct sys_notify_context *ctx,
204 void *private_data,
205 struct notify_event *ev),
206 void *private_data, void *handle_p);
207 static int smb_full_audit_chflags(vfs_handle_struct *handle,
208 const char *path, unsigned int flags);
209 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
210 const SMB_STRUCT_STAT *sbuf);
211 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
212 struct files_struct *fsp,
213 const char *fname,
214 TALLOC_CTX *mem_ctx,
215 unsigned int *pnum_streams,
216 struct stream_struct **pstreams);
217 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
218 const char *path,
219 const char *name,
220 TALLOC_CTX *mem_ctx,
221 char **found_name);
222 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
223 const char *fname);
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_connectpath), SMB_VFS_OP_CONNECTPATH,
487 SMB_VFS_LAYER_LOGGER},
488 {SMB_VFS_OP(smb_full_audit_brl_lock_windows), SMB_VFS_OP_BRL_LOCK_WINDOWS,
489 SMB_VFS_LAYER_LOGGER},
490 {SMB_VFS_OP(smb_full_audit_brl_unlock_windows), SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
491 SMB_VFS_LAYER_LOGGER},
492 {SMB_VFS_OP(smb_full_audit_brl_cancel_windows), SMB_VFS_OP_BRL_CANCEL_WINDOWS,
493 SMB_VFS_LAYER_LOGGER},
494 {SMB_VFS_OP(smb_full_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
495 SMB_VFS_LAYER_LOGGER},
496 {SMB_VFS_OP(smb_full_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
497 SMB_VFS_LAYER_LOGGER},
499 /* NT ACL operations. */
501 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
504 SMB_VFS_LAYER_LOGGER},
505 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
506 SMB_VFS_LAYER_LOGGER},
508 /* POSIX ACL operations. */
510 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
519 SMB_VFS_LAYER_LOGGER},
520 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
521 SMB_VFS_LAYER_LOGGER},
522 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
523 SMB_VFS_LAYER_LOGGER},
524 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
525 SMB_VFS_LAYER_LOGGER},
526 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
527 SMB_VFS_LAYER_LOGGER},
528 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
529 SMB_VFS_LAYER_LOGGER},
530 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
531 SMB_VFS_LAYER_LOGGER},
532 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
533 SMB_VFS_LAYER_LOGGER},
534 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
535 SMB_VFS_LAYER_LOGGER},
536 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
537 SMB_VFS_LAYER_LOGGER},
538 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
539 SMB_VFS_LAYER_LOGGER},
540 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
541 SMB_VFS_LAYER_LOGGER},
542 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
543 SMB_VFS_LAYER_LOGGER},
544 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
545 SMB_VFS_LAYER_LOGGER},
546 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
547 SMB_VFS_LAYER_LOGGER},
548 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
549 SMB_VFS_LAYER_LOGGER},
550 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
551 SMB_VFS_LAYER_LOGGER},
552 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
553 SMB_VFS_LAYER_LOGGER},
554 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
555 SMB_VFS_LAYER_LOGGER},
556 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
557 SMB_VFS_LAYER_LOGGER},
559 /* EA operations. */
561 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
562 SMB_VFS_LAYER_LOGGER},
563 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
564 SMB_VFS_LAYER_LOGGER},
565 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
566 SMB_VFS_LAYER_LOGGER},
567 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
568 SMB_VFS_LAYER_LOGGER},
569 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
570 SMB_VFS_LAYER_LOGGER},
571 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
572 SMB_VFS_LAYER_LOGGER},
573 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
574 SMB_VFS_LAYER_LOGGER},
575 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
576 SMB_VFS_LAYER_LOGGER},
577 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
578 SMB_VFS_LAYER_LOGGER},
579 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
580 SMB_VFS_LAYER_LOGGER},
581 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
582 SMB_VFS_LAYER_LOGGER},
583 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
584 SMB_VFS_LAYER_LOGGER},
586 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
587 SMB_VFS_LAYER_LOGGER},
588 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
589 SMB_VFS_LAYER_LOGGER},
590 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
591 SMB_VFS_LAYER_LOGGER},
592 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
593 SMB_VFS_LAYER_LOGGER},
594 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
595 SMB_VFS_LAYER_LOGGER},
596 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
597 SMB_VFS_LAYER_LOGGER},
598 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
599 SMB_VFS_LAYER_LOGGER},
600 {SMB_VFS_OP(smb_full_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
601 SMB_VFS_LAYER_LOGGER},
603 /* Finish VFS operations definition */
605 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
606 SMB_VFS_LAYER_NOOP}
609 /* The following array *must* be in the same order as defined in vfs.h */
611 static struct {
612 vfs_op_type type;
613 const char *name;
614 } vfs_op_names[] = {
615 { SMB_VFS_OP_CONNECT, "connect" },
616 { SMB_VFS_OP_DISCONNECT, "disconnect" },
617 { SMB_VFS_OP_DISK_FREE, "disk_free" },
618 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
619 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
620 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
621 { SMB_VFS_OP_STATVFS, "statvfs" },
622 { SMB_VFS_OP_FS_CAPABILITIES, "fs_capabilities" },
623 { SMB_VFS_OP_OPENDIR, "opendir" },
624 { SMB_VFS_OP_READDIR, "readdir" },
625 { SMB_VFS_OP_SEEKDIR, "seekdir" },
626 { SMB_VFS_OP_TELLDIR, "telldir" },
627 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
628 { SMB_VFS_OP_MKDIR, "mkdir" },
629 { SMB_VFS_OP_RMDIR, "rmdir" },
630 { SMB_VFS_OP_CLOSEDIR, "closedir" },
631 { SMB_VFS_OP_INIT_SEARCH_OP, "init_search_op" },
632 { SMB_VFS_OP_OPEN, "open" },
633 { SMB_VFS_OP_CREATE_FILE, "create_file" },
634 { SMB_VFS_OP_CLOSE, "close" },
635 { SMB_VFS_OP_READ, "read" },
636 { SMB_VFS_OP_PREAD, "pread" },
637 { SMB_VFS_OP_WRITE, "write" },
638 { SMB_VFS_OP_PWRITE, "pwrite" },
639 { SMB_VFS_OP_LSEEK, "lseek" },
640 { SMB_VFS_OP_SENDFILE, "sendfile" },
641 { SMB_VFS_OP_RECVFILE, "recvfile" },
642 { SMB_VFS_OP_RENAME, "rename" },
643 { SMB_VFS_OP_FSYNC, "fsync" },
644 { SMB_VFS_OP_STAT, "stat" },
645 { SMB_VFS_OP_FSTAT, "fstat" },
646 { SMB_VFS_OP_LSTAT, "lstat" },
647 { SMB_VFS_OP_GET_ALLOC_SIZE, "get_alloc_size" },
648 { SMB_VFS_OP_UNLINK, "unlink" },
649 { SMB_VFS_OP_CHMOD, "chmod" },
650 { SMB_VFS_OP_FCHMOD, "fchmod" },
651 { SMB_VFS_OP_CHOWN, "chown" },
652 { SMB_VFS_OP_FCHOWN, "fchown" },
653 { SMB_VFS_OP_LCHOWN, "lchown" },
654 { SMB_VFS_OP_CHDIR, "chdir" },
655 { SMB_VFS_OP_GETWD, "getwd" },
656 { SMB_VFS_OP_NTIMES, "ntimes" },
657 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
658 { SMB_VFS_OP_LOCK, "lock" },
659 { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" },
660 { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" },
661 { SMB_VFS_OP_GETLOCK, "getlock" },
662 { SMB_VFS_OP_SYMLINK, "symlink" },
663 { SMB_VFS_OP_READLINK, "readlink" },
664 { SMB_VFS_OP_LINK, "link" },
665 { SMB_VFS_OP_MKNOD, "mknod" },
666 { SMB_VFS_OP_REALPATH, "realpath" },
667 { SMB_VFS_OP_NOTIFY_WATCH, "notify_watch" },
668 { SMB_VFS_OP_CHFLAGS, "chflags" },
669 { SMB_VFS_OP_FILE_ID_CREATE, "file_id_create" },
670 { SMB_VFS_OP_STREAMINFO, "streaminfo" },
671 { SMB_VFS_OP_GET_REAL_FILENAME, "get_real_filename" },
672 { SMB_VFS_OP_CONNECTPATH, "connectpath" },
673 { SMB_VFS_OP_BRL_LOCK_WINDOWS, "brl_lock_windows" },
674 { SMB_VFS_OP_BRL_UNLOCK_WINDOWS, "brl_unlock_windows" },
675 { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" },
676 { SMB_VFS_OP_STRICT_LOCK, "strict_lock" },
677 { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" },
678 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
679 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
680 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
681 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
682 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
683 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
684 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
685 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
686 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
687 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
688 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
689 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
690 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
691 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
692 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
693 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
694 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
695 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
696 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
697 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
698 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
699 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
700 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
701 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
702 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
703 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
704 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
705 { SMB_VFS_OP_GETXATTR, "getxattr" },
706 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
707 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
708 { SMB_VFS_OP_LISTXATTR, "listxattr" },
709 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
710 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
711 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
712 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
713 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
714 { SMB_VFS_OP_SETXATTR, "setxattr" },
715 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
716 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
717 { SMB_VFS_OP_AIO_READ, "aio_read" },
718 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
719 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
720 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
721 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
722 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
723 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
724 { SMB_VFS_OP_AIO_FORCE, "aio_force" },
725 { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
726 { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
727 { SMB_VFS_OP_LAST, NULL }
730 static int audit_syslog_facility(vfs_handle_struct *handle)
732 static const struct enum_list enum_log_facilities[] = {
733 { LOG_USER, "USER" },
734 { LOG_LOCAL0, "LOCAL0" },
735 { LOG_LOCAL1, "LOCAL1" },
736 { LOG_LOCAL2, "LOCAL2" },
737 { LOG_LOCAL3, "LOCAL3" },
738 { LOG_LOCAL4, "LOCAL4" },
739 { LOG_LOCAL5, "LOCAL5" },
740 { LOG_LOCAL6, "LOCAL6" },
741 { LOG_LOCAL7, "LOCAL7" }
744 int facility;
746 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
748 return facility;
751 static int audit_syslog_priority(vfs_handle_struct *handle)
753 static const struct enum_list enum_log_priorities[] = {
754 { LOG_EMERG, "EMERG" },
755 { LOG_ALERT, "ALERT" },
756 { LOG_CRIT, "CRIT" },
757 { LOG_ERR, "ERR" },
758 { LOG_WARNING, "WARNING" },
759 { LOG_NOTICE, "NOTICE" },
760 { LOG_INFO, "INFO" },
761 { LOG_DEBUG, "DEBUG" }
764 int priority;
766 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority",
767 enum_log_priorities, LOG_NOTICE);
768 if (priority == -1) {
769 priority = LOG_WARNING;
772 return priority;
775 static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
777 char *prefix = NULL;
778 char *result;
780 prefix = talloc_strdup(ctx,
781 lp_parm_const_string(SNUM(conn), "full_audit",
782 "prefix", "%u|%I"));
783 if (!prefix) {
784 return NULL;
786 result = talloc_sub_advanced(ctx,
787 lp_servicename(SNUM(conn)),
788 conn->server_info->unix_name,
789 conn->connectpath,
790 conn->server_info->utok.gid,
791 conn->server_info->sanitized_username,
792 pdb_get_domain(conn->server_info->sam_account),
793 prefix);
794 TALLOC_FREE(prefix);
795 return result;
798 static bool log_success(vfs_handle_struct *handle, vfs_op_type op)
800 struct vfs_full_audit_private_data *pd = NULL;
802 SMB_VFS_HANDLE_GET_DATA(handle, pd,
803 struct vfs_full_audit_private_data,
804 return True);
806 if (pd->success_ops == NULL) {
807 return True;
810 return bitmap_query(pd->success_ops, op);
813 static bool log_failure(vfs_handle_struct *handle, vfs_op_type op)
815 struct vfs_full_audit_private_data *pd = NULL;
817 SMB_VFS_HANDLE_GET_DATA(handle, pd,
818 struct vfs_full_audit_private_data,
819 return True);
821 if (pd->failure_ops == NULL)
822 return True;
824 return bitmap_query(pd->failure_ops, op);
827 static void init_bitmap(struct bitmap **bm, const char **ops)
829 bool log_all = False;
831 if (*bm != NULL)
832 return;
834 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
836 if (*bm == NULL) {
837 DEBUG(0, ("Could not alloc bitmap -- "
838 "defaulting to logging everything\n"));
839 return;
842 while (*ops != NULL) {
843 int i;
844 bool found = False;
846 if (strequal(*ops, "all")) {
847 log_all = True;
848 break;
851 if (strequal(*ops, "none")) {
852 break;
855 for (i=0; i<SMB_VFS_OP_LAST; i++) {
856 if (vfs_op_names[i].name == NULL) {
857 smb_panic("vfs_full_audit.c: name table not "
858 "in sync with vfs.h\n");
861 if (strequal(*ops, vfs_op_names[i].name)) {
862 bitmap_set(*bm, i);
863 found = True;
866 if (!found) {
867 DEBUG(0, ("Could not find opname %s, logging all\n",
868 *ops));
869 log_all = True;
870 break;
872 ops += 1;
875 if (log_all) {
876 /* The query functions default to True */
877 bitmap_free(*bm);
878 *bm = NULL;
882 static const char *audit_opname(vfs_op_type op)
884 if (op >= SMB_VFS_OP_LAST)
885 return "INVALID VFS OP";
886 return vfs_op_names[op].name;
889 static void do_log(vfs_op_type op, bool success, vfs_handle_struct *handle,
890 const char *format, ...)
892 fstring err_msg;
893 char *audit_pre = NULL;
894 va_list ap;
895 char *op_msg = NULL;
897 if (success && (!log_success(handle, op)))
898 return;
900 if (!success && (!log_failure(handle, op)))
901 return;
903 if (success)
904 fstrcpy(err_msg, "ok");
905 else
906 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
908 va_start(ap, format);
909 op_msg = talloc_vasprintf(talloc_tos(), format, ap);
910 va_end(ap);
912 if (!op_msg) {
913 return;
916 audit_pre = audit_prefix(talloc_tos(), handle->conn);
917 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
918 audit_pre ? audit_pre : "",
919 audit_opname(op), err_msg, op_msg);
921 TALLOC_FREE(audit_pre);
922 TALLOC_FREE(op_msg);
924 return;
927 /* Free function for the private data. */
929 static void free_private_data(void **p_data)
931 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
933 if (pd->success_ops) {
934 bitmap_free(pd->success_ops);
936 if (pd->failure_ops) {
937 bitmap_free(pd->failure_ops);
939 SAFE_FREE(pd);
940 *p_data = NULL;
943 /* Implementation of vfs_ops. Pass everything on to the default
944 operation but log event first. */
946 static int smb_full_audit_connect(vfs_handle_struct *handle,
947 const char *svc, const char *user)
949 int result;
950 struct vfs_full_audit_private_data *pd = NULL;
951 const char *none[] = { NULL };
952 const char *all [] = { "all" };
954 if (!handle) {
955 return -1;
958 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
959 if (!pd) {
960 return -1;
962 ZERO_STRUCTP(pd);
964 openlog("smbd_audit", 0, audit_syslog_facility(handle));
966 init_bitmap(&pd->success_ops,
967 lp_parm_string_list(SNUM(handle->conn), "full_audit", "success",
968 none));
969 init_bitmap(&pd->failure_ops,
970 lp_parm_string_list(SNUM(handle->conn), "full_audit", "failure",
971 all));
973 /* Store the private data. */
974 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
975 struct vfs_full_audit_private_data, return -1);
977 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
979 do_log(SMB_VFS_OP_CONNECT, True, handle,
980 "%s", svc);
982 return result;
985 static void smb_full_audit_disconnect(vfs_handle_struct *handle)
987 SMB_VFS_NEXT_DISCONNECT(handle);
989 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
990 "%s", lp_servicename(SNUM(handle->conn)));
992 /* The bitmaps will be disconnected when the private
993 data is deleted. */
995 return;
998 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
999 const char *path,
1000 bool small_query, uint64_t *bsize,
1001 uint64_t *dfree, uint64_t *dsize)
1003 uint64_t result;
1005 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
1006 dfree, dsize);
1008 /* Don't have a reasonable notion of failure here */
1010 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
1012 return result;
1015 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
1016 enum SMB_QUOTA_TYPE qtype, unid_t id,
1017 SMB_DISK_QUOTA *qt)
1019 int result;
1021 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
1023 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
1025 return result;
1029 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
1030 enum SMB_QUOTA_TYPE qtype, unid_t id,
1031 SMB_DISK_QUOTA *qt)
1033 int result;
1035 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
1037 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
1039 return result;
1042 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
1043 struct files_struct *fsp,
1044 SHADOW_COPY_DATA *shadow_copy_data, bool labels)
1046 int result;
1048 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
1050 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
1052 return result;
1055 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
1056 const char *path,
1057 struct vfs_statvfs_struct *statbuf)
1059 int result;
1061 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
1063 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
1065 return result;
1068 static int smb_full_audit_fs_capabilities(struct vfs_handle_struct *handle)
1070 int result;
1072 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
1074 do_log(SMB_VFS_OP_FS_CAPABILITIES, true, handle, "");
1076 return result;
1079 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
1080 const char *fname, const char *mask, uint32 attr)
1082 SMB_STRUCT_DIR *result;
1084 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
1086 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
1088 return result;
1091 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
1092 SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
1094 SMB_STRUCT_DIRENT *result;
1096 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
1098 /* This operation has no reasonable error condition
1099 * (End of dir is also failure), so always succeed.
1101 do_log(SMB_VFS_OP_READDIR, True, handle, "");
1103 return result;
1106 static void smb_full_audit_seekdir(vfs_handle_struct *handle,
1107 SMB_STRUCT_DIR *dirp, long offset)
1109 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
1111 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
1112 return;
1115 static long smb_full_audit_telldir(vfs_handle_struct *handle,
1116 SMB_STRUCT_DIR *dirp)
1118 long result;
1120 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
1122 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
1124 return result;
1127 static void smb_full_audit_rewinddir(vfs_handle_struct *handle,
1128 SMB_STRUCT_DIR *dirp)
1130 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
1132 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
1133 return;
1136 static int smb_full_audit_mkdir(vfs_handle_struct *handle,
1137 const char *path, mode_t mode)
1139 int result;
1141 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
1143 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1145 return result;
1148 static int smb_full_audit_rmdir(vfs_handle_struct *handle,
1149 const char *path)
1151 int result;
1153 result = SMB_VFS_NEXT_RMDIR(handle, path);
1155 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1157 return result;
1160 static int smb_full_audit_closedir(vfs_handle_struct *handle,
1161 SMB_STRUCT_DIR *dirp)
1163 int result;
1165 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
1167 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1169 return result;
1172 static void smb_full_audit_init_search_op(vfs_handle_struct *handle,
1173 SMB_STRUCT_DIR *dirp)
1175 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
1177 do_log(SMB_VFS_OP_INIT_SEARCH_OP, True, handle, "");
1178 return;
1181 static int smb_full_audit_open(vfs_handle_struct *handle,
1182 const char *fname, files_struct *fsp, int flags, mode_t mode)
1184 int result;
1186 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
1188 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1189 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1190 fname);
1192 return result;
1195 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
1196 struct smb_request *req,
1197 uint16_t root_dir_fid,
1198 struct smb_filename *smb_fname,
1199 uint32_t access_mask,
1200 uint32_t share_access,
1201 uint32_t create_disposition,
1202 uint32_t create_options,
1203 uint32_t file_attributes,
1204 uint32_t oplock_request,
1205 uint64_t allocation_size,
1206 struct security_descriptor *sd,
1207 struct ea_list *ea_list,
1208 files_struct **result_fsp,
1209 int *pinfo)
1211 NTSTATUS result;
1213 result = SMB_VFS_NEXT_CREATE_FILE(
1214 handle, /* handle */
1215 req, /* req */
1216 root_dir_fid, /* root_dir_fid */
1217 smb_fname, /* fname */
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 */
1230 do_log(SMB_VFS_OP_CREATE_FILE, (NT_STATUS_IS_OK(result)), handle, "0x%x|%s",
1231 access_mask, smb_fname_str_dbg(smb_fname));
1233 return result;
1236 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp)
1238 int result;
1240 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
1242 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1244 return result;
1247 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1248 void *data, size_t n)
1250 ssize_t result;
1252 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
1254 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1256 return result;
1259 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1260 void *data, size_t n, SMB_OFF_T offset)
1262 ssize_t result;
1264 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1266 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1268 return result;
1271 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1272 const void *data, size_t n)
1274 ssize_t result;
1276 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
1278 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1280 return result;
1283 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1284 const void *data, size_t n,
1285 SMB_OFF_T offset)
1287 ssize_t result;
1289 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1291 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1293 return result;
1296 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1297 SMB_OFF_T offset, int whence)
1299 ssize_t result;
1301 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
1303 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1304 "%s", fsp->fsp_name);
1306 return result;
1309 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1310 files_struct *fromfsp,
1311 const DATA_BLOB *hdr, SMB_OFF_T offset,
1312 size_t n)
1314 ssize_t result;
1316 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
1318 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1319 "%s", fromfsp->fsp_name);
1321 return result;
1324 static ssize_t smb_full_audit_recvfile(vfs_handle_struct *handle, int fromfd,
1325 files_struct *tofsp,
1326 SMB_OFF_T offset,
1327 size_t n)
1329 ssize_t result;
1331 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
1333 do_log(SMB_VFS_OP_RECVFILE, (result >= 0), handle,
1334 "%s", tofsp->fsp_name);
1336 return result;
1339 static int smb_full_audit_rename(vfs_handle_struct *handle,
1340 const char *oldname, const char *newname)
1342 int result;
1344 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
1346 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1348 return result;
1351 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
1353 int result;
1355 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
1357 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1359 return result;
1362 static int smb_full_audit_stat(vfs_handle_struct *handle,
1363 const char *fname, SMB_STRUCT_STAT *sbuf)
1365 int result;
1367 result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
1369 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1371 return result;
1374 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1375 SMB_STRUCT_STAT *sbuf)
1377 int result;
1379 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1381 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1383 return result;
1386 static int smb_full_audit_lstat(vfs_handle_struct *handle,
1387 const char *path, SMB_STRUCT_STAT *sbuf)
1389 int result;
1391 result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
1393 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1395 return result;
1398 static int smb_full_audit_get_alloc_size(vfs_handle_struct *handle,
1399 files_struct *fsp, const SMB_STRUCT_STAT *sbuf)
1401 int result;
1403 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1405 do_log(SMB_VFS_OP_GET_ALLOC_SIZE, (result >= 0), handle, "%d", result);
1407 return result;
1410 static int smb_full_audit_unlink(vfs_handle_struct *handle,
1411 const char *path)
1413 int result;
1415 result = SMB_VFS_NEXT_UNLINK(handle, path);
1417 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1419 return result;
1422 static int smb_full_audit_chmod(vfs_handle_struct *handle,
1423 const char *path, mode_t mode)
1425 int result;
1427 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1429 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1431 return result;
1434 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1435 mode_t mode)
1437 int result;
1439 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1441 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1442 "%s|%o", fsp->fsp_name, mode);
1444 return result;
1447 static int smb_full_audit_chown(vfs_handle_struct *handle,
1448 const char *path, uid_t uid, gid_t gid)
1450 int result;
1452 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1454 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1455 path, (long int)uid, (long int)gid);
1457 return result;
1460 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1461 uid_t uid, gid_t gid)
1463 int result;
1465 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1467 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1468 fsp->fsp_name, (long int)uid, (long int)gid);
1470 return result;
1473 static int smb_full_audit_lchown(vfs_handle_struct *handle,
1474 const char *path, uid_t uid, gid_t gid)
1476 int result;
1478 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1480 do_log(SMB_VFS_OP_LCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1481 path, (long int)uid, (long int)gid);
1483 return result;
1486 static int smb_full_audit_chdir(vfs_handle_struct *handle,
1487 const char *path)
1489 int result;
1491 result = SMB_VFS_NEXT_CHDIR(handle, path);
1493 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1495 return result;
1498 static char *smb_full_audit_getwd(vfs_handle_struct *handle,
1499 char *path)
1501 char *result;
1503 result = SMB_VFS_NEXT_GETWD(handle, path);
1505 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1507 return result;
1510 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
1511 const char *path, struct smb_file_time *ft)
1513 int result;
1515 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1517 do_log(SMB_VFS_OP_NTIMES, (result >= 0), handle, "%s", path);
1519 return result;
1522 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1523 SMB_OFF_T len)
1525 int result;
1527 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1529 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1530 "%s", fsp->fsp_name);
1532 return result;
1535 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1536 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1538 bool result;
1540 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1542 do_log(SMB_VFS_OP_LOCK, result, handle, "%s", fsp->fsp_name);
1544 return result;
1547 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
1548 struct files_struct *fsp,
1549 uint32 share_mode)
1551 int result;
1553 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode);
1555 do_log(SMB_VFS_OP_KERNEL_FLOCK, (result >= 0), handle, "%s",
1556 fsp->fsp_name);
1558 return result;
1561 static int smb_full_audit_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
1562 int leasetype)
1564 int result;
1566 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1568 do_log(SMB_VFS_OP_LINUX_SETLEASE, (result >= 0), handle, "%s",
1569 fsp->fsp_name);
1571 return result;
1574 static bool smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp,
1575 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1577 bool result;
1579 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype, ppid);
1581 do_log(SMB_VFS_OP_GETLOCK, result, handle, "%s", fsp->fsp_name);
1583 return result;
1586 static int smb_full_audit_symlink(vfs_handle_struct *handle,
1587 const char *oldpath, const char *newpath)
1589 int result;
1591 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1593 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1594 "%s|%s", oldpath, newpath);
1596 return result;
1599 static int smb_full_audit_readlink(vfs_handle_struct *handle,
1600 const char *path, char *buf, size_t bufsiz)
1602 int result;
1604 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1606 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1608 return result;
1611 static int smb_full_audit_link(vfs_handle_struct *handle,
1612 const char *oldpath, const char *newpath)
1614 int result;
1616 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1618 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1619 "%s|%s", oldpath, newpath);
1621 return result;
1624 static int smb_full_audit_mknod(vfs_handle_struct *handle,
1625 const char *pathname, mode_t mode, SMB_DEV_T dev)
1627 int result;
1629 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1631 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1633 return result;
1636 static char *smb_full_audit_realpath(vfs_handle_struct *handle,
1637 const char *path, char *resolved_path)
1639 char *result;
1641 result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1643 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1645 return result;
1648 static NTSTATUS smb_full_audit_notify_watch(struct vfs_handle_struct *handle,
1649 struct sys_notify_context *ctx,
1650 struct notify_entry *e,
1651 void (*callback)(struct sys_notify_context *ctx,
1652 void *private_data,
1653 struct notify_event *ev),
1654 void *private_data, void *handle_p)
1656 NTSTATUS result;
1658 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback, private_data, handle_p);
1660 do_log(SMB_VFS_OP_NOTIFY_WATCH, NT_STATUS_IS_OK(result), handle, "");
1662 return result;
1665 static int smb_full_audit_chflags(vfs_handle_struct *handle,
1666 const char *path, unsigned int flags)
1668 int result;
1670 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1672 do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
1674 return result;
1677 static struct file_id smb_full_audit_file_id_create(struct vfs_handle_struct *handle,
1678 const SMB_STRUCT_STAT *sbuf)
1680 struct file_id id_zero;
1681 struct file_id result;
1683 ZERO_STRUCT(id_zero);
1685 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1687 do_log(SMB_VFS_OP_FILE_ID_CREATE,
1688 !file_id_equal(&id_zero, &result),
1689 handle, "%s", file_id_string_tos(&result));
1691 return result;
1694 static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
1695 struct files_struct *fsp,
1696 const char *fname,
1697 TALLOC_CTX *mem_ctx,
1698 unsigned int *pnum_streams,
1699 struct stream_struct **pstreams)
1701 NTSTATUS result;
1703 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1704 pnum_streams, pstreams);
1706 do_log(SMB_VFS_OP_STREAMINFO, NT_STATUS_IS_OK(result), handle,
1707 "%s", fname);
1709 return result;
1712 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
1713 const char *path,
1714 const char *name,
1715 TALLOC_CTX *mem_ctx,
1716 char **found_name)
1718 int result;
1720 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1721 found_name);
1723 do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
1724 "%s/%s->%s", path, name, (result == 0) ? "" : *found_name);
1726 return result;
1729 static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
1730 const char *fname)
1732 const char *result;
1734 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1736 do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle,
1737 "%s", fname);
1739 return result;
1742 static NTSTATUS smb_full_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1743 struct byte_range_lock *br_lck,
1744 struct lock_struct *plock,
1745 bool blocking_lock,
1746 struct blocking_lock_record *blr)
1748 NTSTATUS result;
1750 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1751 blocking_lock, blr);
1753 do_log(SMB_VFS_OP_BRL_LOCK_WINDOWS, NT_STATUS_IS_OK(result), handle,
1754 "%s:%llu-%llu. type=%d. blocking=%d", br_lck->fsp->fsp_name,
1755 plock->start, plock->size, plock->lock_type, blocking_lock );
1757 return result;
1760 static bool smb_full_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1761 struct messaging_context *msg_ctx,
1762 struct byte_range_lock *br_lck,
1763 const struct lock_struct *plock)
1765 bool result;
1767 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1768 plock);
1770 do_log(SMB_VFS_OP_BRL_UNLOCK_WINDOWS, (result == 0), handle,
1771 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1772 plock->size, plock->lock_type);
1774 return result;
1777 static bool smb_full_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1778 struct byte_range_lock *br_lck,
1779 struct lock_struct *plock,
1780 struct blocking_lock_record *blr)
1782 bool result;
1784 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1786 do_log(SMB_VFS_OP_BRL_CANCEL_WINDOWS, (result == 0), handle,
1787 "%s:%llu-%llu:%d", br_lck->fsp->fsp_name, plock->start,
1788 plock->size);
1790 return result;
1793 static bool smb_full_audit_strict_lock(struct vfs_handle_struct *handle,
1794 struct files_struct *fsp,
1795 struct lock_struct *plock)
1797 bool result;
1799 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1801 do_log(SMB_VFS_OP_STRICT_LOCK, result, handle,
1802 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1803 plock->size);
1805 return result;
1808 static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle,
1809 struct files_struct *fsp,
1810 struct lock_struct *plock)
1812 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1814 do_log(SMB_VFS_OP_STRICT_UNLOCK, true, handle,
1815 "%s:%llu-%llu:%d", fsp->fsp_name, plock->start,
1816 plock->size);
1818 return;
1821 static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1822 uint32 security_info,
1823 SEC_DESC **ppdesc)
1825 NTSTATUS result;
1827 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1829 do_log(SMB_VFS_OP_FGET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1830 "%s", fsp->fsp_name);
1832 return result;
1835 static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
1836 const char *name,
1837 uint32 security_info,
1838 SEC_DESC **ppdesc)
1840 NTSTATUS result;
1842 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1844 do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
1845 "%s", name);
1847 return result;
1850 static NTSTATUS smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1851 uint32 security_info_sent,
1852 const SEC_DESC *psd)
1854 NTSTATUS result;
1856 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
1858 do_log(SMB_VFS_OP_FSET_NT_ACL, NT_STATUS_IS_OK(result), handle, "%s", fsp->fsp_name);
1860 return result;
1863 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle,
1864 const char *path, mode_t mode)
1866 int result;
1868 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1870 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1871 "%s|%o", path, mode);
1873 return result;
1876 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1877 mode_t mode)
1879 int result;
1881 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1883 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1884 "%s|%o", fsp->fsp_name, mode);
1886 return result;
1889 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1891 SMB_ACL_T theacl, int entry_id,
1892 SMB_ACL_ENTRY_T *entry_p)
1894 int result;
1896 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1897 entry_p);
1899 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1900 "");
1902 return result;
1905 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1907 SMB_ACL_ENTRY_T entry_d,
1908 SMB_ACL_TAG_T *tag_type_p)
1910 int result;
1912 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1913 tag_type_p);
1915 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1916 "");
1918 return result;
1921 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1923 SMB_ACL_ENTRY_T entry_d,
1924 SMB_ACL_PERMSET_T *permset_p)
1926 int result;
1928 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1929 permset_p);
1931 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1932 "");
1934 return result;
1937 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1939 SMB_ACL_ENTRY_T entry_d)
1941 void *result;
1943 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1945 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1946 "");
1948 return result;
1951 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1952 const char *path_p,
1953 SMB_ACL_TYPE_T type)
1955 SMB_ACL_T result;
1957 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1959 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1960 "%s", path_p);
1962 return result;
1965 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1966 files_struct *fsp)
1968 SMB_ACL_T result;
1970 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1972 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1973 "%s", fsp->fsp_name);
1975 return result;
1978 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1980 SMB_ACL_PERMSET_T permset)
1982 int result;
1984 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1986 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1987 "");
1989 return result;
1992 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1994 SMB_ACL_PERMSET_T permset,
1995 SMB_ACL_PERM_T perm)
1997 int result;
1999 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
2001 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
2002 "");
2004 return result;
2007 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
2008 SMB_ACL_T theacl,
2009 ssize_t *plen)
2011 char * result;
2013 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
2015 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
2016 "");
2018 return result;
2021 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
2023 int count)
2025 SMB_ACL_T result;
2027 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
2029 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
2030 "");
2032 return result;
2035 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
2036 SMB_ACL_T *pacl,
2037 SMB_ACL_ENTRY_T *pentry)
2039 int result;
2041 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
2043 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
2044 "");
2046 return result;
2049 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
2051 SMB_ACL_ENTRY_T entry,
2052 SMB_ACL_TAG_T tagtype)
2054 int result;
2056 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
2057 tagtype);
2059 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
2060 "");
2062 return result;
2065 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
2067 SMB_ACL_ENTRY_T entry,
2068 void *qual)
2070 int result;
2072 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
2074 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
2075 "");
2077 return result;
2080 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
2082 SMB_ACL_ENTRY_T entry,
2083 SMB_ACL_PERMSET_T permset)
2085 int result;
2087 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
2089 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
2090 "");
2092 return result;
2095 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
2097 SMB_ACL_T theacl )
2099 int result;
2101 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
2103 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
2104 "");
2106 return result;
2109 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
2111 const char *name, SMB_ACL_TYPE_T acltype,
2112 SMB_ACL_T theacl)
2114 int result;
2116 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
2117 theacl);
2119 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
2120 "%s", name);
2122 return result;
2125 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
2126 SMB_ACL_T theacl)
2128 int result;
2130 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2132 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
2133 "%s", fsp->fsp_name);
2135 return result;
2138 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2140 const char *path)
2142 int result;
2144 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
2146 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
2147 "%s", path);
2149 return result;
2152 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
2154 SMB_ACL_PERMSET_T permset,
2155 SMB_ACL_PERM_T perm)
2157 int result;
2159 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
2161 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
2162 "");
2164 return result;
2167 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
2169 char *text)
2171 int result;
2173 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
2175 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
2176 "");
2178 return result;
2181 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
2183 SMB_ACL_T posix_acl)
2185 int result;
2187 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
2189 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
2190 "");
2192 return result;
2195 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
2196 void *qualifier,
2197 SMB_ACL_TAG_T tagtype)
2199 int result;
2201 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
2202 tagtype);
2204 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
2205 "");
2207 return result;
2210 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
2211 const char *path,
2212 const char *name, void *value, size_t size)
2214 ssize_t result;
2216 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2218 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
2219 "%s|%s", path, name);
2221 return result;
2224 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
2225 const char *path, const char *name,
2226 void *value, size_t size)
2228 ssize_t result;
2230 result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
2232 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
2233 "%s|%s", path, name);
2235 return result;
2238 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
2239 struct files_struct *fsp,
2240 const char *name, void *value, size_t size)
2242 ssize_t result;
2244 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2246 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
2247 "%s|%s", fsp->fsp_name, name);
2249 return result;
2252 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
2253 const char *path, char *list, size_t size)
2255 ssize_t result;
2257 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2259 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
2261 return result;
2264 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
2265 const char *path, char *list, size_t size)
2267 ssize_t result;
2269 result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
2271 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
2273 return result;
2276 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
2277 struct files_struct *fsp, char *list,
2278 size_t size)
2280 ssize_t result;
2282 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2284 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
2285 "%s", fsp->fsp_name);
2287 return result;
2290 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
2291 const char *path,
2292 const char *name)
2294 int result;
2296 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2298 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
2299 "%s|%s", path, name);
2301 return result;
2304 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
2305 const char *path,
2306 const char *name)
2308 int result;
2310 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
2312 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
2313 "%s|%s", path, name);
2315 return result;
2318 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
2319 struct files_struct *fsp,
2320 const char *name)
2322 int result;
2324 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2326 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
2327 "%s|%s", fsp->fsp_name, name);
2329 return result;
2332 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
2333 const char *path,
2334 const char *name, const void *value, size_t size,
2335 int flags)
2337 int result;
2339 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2340 flags);
2342 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
2343 "%s|%s", path, name);
2345 return result;
2348 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
2349 const char *path,
2350 const char *name, const void *value, size_t size,
2351 int flags)
2353 int result;
2355 result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
2356 flags);
2358 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
2359 "%s|%s", path, name);
2361 return result;
2364 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
2365 struct files_struct *fsp, const char *name,
2366 const void *value, size_t size, int flags)
2368 int result;
2370 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2372 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
2373 "%s|%s", fsp->fsp_name, name);
2375 return result;
2378 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2380 int result;
2382 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2383 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
2384 "%s", fsp->fsp_name);
2386 return result;
2389 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2391 int result;
2393 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2394 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
2395 "%s", fsp->fsp_name);
2397 return result;
2400 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2402 int result;
2404 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2405 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2406 "%s", fsp->fsp_name);
2408 return result;
2411 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2413 int result;
2415 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2416 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2417 "%s", fsp->fsp_name);
2419 return result;
2422 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2424 int result;
2426 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2427 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2428 "%s", fsp->fsp_name);
2430 return result;
2433 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2435 int result;
2437 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2438 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2439 "%s", fsp->fsp_name);
2441 return result;
2444 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)
2446 int result;
2448 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2449 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2450 "%s", fsp->fsp_name);
2452 return result;
2455 static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
2456 struct files_struct *fsp)
2458 bool result;
2460 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2461 do_log(SMB_VFS_OP_AIO_FORCE, result, handle,
2462 "%s", fsp->fsp_name);
2464 return result;
2467 NTSTATUS vfs_full_audit_init(void);
2468 NTSTATUS vfs_full_audit_init(void)
2470 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2471 "full_audit", audit_op_tuples);
2473 if (!NT_STATUS_IS_OK(ret))
2474 return ret;
2476 vfs_full_audit_debug_level = debug_add_class("full_audit");
2477 if (vfs_full_audit_debug_level == -1) {
2478 vfs_full_audit_debug_level = DBGC_VFS;
2479 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2480 "class!\n"));
2481 } else {
2482 DEBUG(10, ("vfs_full_audit: Debug class number of "
2483 "'full_audit': %d\n", vfs_full_audit_debug_level));
2486 return ret;