2 * Auditing VFS module for samba. Log selected file operations to syslog
5 * Copyright (C) Tim Potter, 1999-2000
6 * Copyright (C) Alexander Bokovoy, 2002
7 * Copyright (C) John H Terpstra, 2003
8 * Copyright (C) Stefan (metze) Metzmacher, 2003
9 * Copyright (C) Volker Lendecke, 2004
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 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, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * This module implements parseable logging for all Samba VFS operations.
29 * You use it as follows:
33 * vfs objects = full_audit
34 * full_audit:prefix = %u|%I
35 * full_audit:success = open opendir
36 * full_audit:failure = all
38 * vfs op can be "all" which means log all operations.
39 * vfs op can be "none" which means no logging.
41 * This leads to syslog entries of the form:
42 * smbd_audit: nobody|192.168.234.1|opendir|ok|.
43 * smbd_audit: nobody|192.168.234.1|open|fail (File not found)|r|x.txt
45 * where "nobody" is the connected username and "192.168.234.1" is the
46 * client's IP address.
50 * prefix: A macro expansion template prepended to the syslog entry.
52 * success: A list of VFS operations for which a successful completion should
53 * be logged. Defaults to no logging at all. The special operation "all" logs
54 * - you guessed it - everything.
56 * failure: A list of VFS operations for which failure to complete should be
57 * logged. Defaults to logging everything.
63 extern struct current_user current_user;
65 static int vfs_full_audit_debug_level = DBGC_VFS;
67 struct vfs_full_audit_private_data {
68 struct bitmap *success_ops;
69 struct bitmap *failure_ops;
73 #define DBGC_CLASS vfs_full_audit_debug_level
75 /* Function prototypes */
77 static int smb_full_audit_connect(vfs_handle_struct *handle, connection_struct *conn,
78 const char *svc, const char *user);
79 static void smb_full_audit_disconnect(vfs_handle_struct *handle,
80 connection_struct *conn);
81 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
82 connection_struct *conn, const char *path,
83 BOOL small_query, SMB_BIG_UINT *bsize,
84 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
85 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
86 struct connection_struct *conn,
87 enum SMB_QUOTA_TYPE qtype, unid_t id,
89 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
90 struct connection_struct *conn,
91 enum SMB_QUOTA_TYPE qtype, unid_t id,
93 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
94 struct files_struct *fsp,
95 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
96 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
97 struct connection_struct *conn,
99 struct vfs_statvfs_struct *statbuf);
101 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
102 const char *fname, const char *mask, uint32 attr);
103 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
104 connection_struct *conn, SMB_STRUCT_DIR *dirp);
105 static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
106 SMB_STRUCT_DIR *dirp, long offset);
107 static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn,
108 SMB_STRUCT_DIR *dirp);
109 static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn,
110 SMB_STRUCT_DIR *dirp);
111 static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn,
112 const char *path, mode_t mode);
113 static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn,
115 static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn,
116 SMB_STRUCT_DIR *dirp);
117 static int smb_full_audit_open(vfs_handle_struct *handle, connection_struct *conn,
118 const char *fname, int flags, mode_t mode);
119 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd);
120 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
121 int fd, void *data, size_t n);
122 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
123 int fd, void *data, size_t n, SMB_OFF_T offset);
124 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
125 int fd, const void *data, size_t n);
126 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
127 int fd, const void *data, size_t n,
129 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
130 int filedes, SMB_OFF_T offset, int whence);
131 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
132 files_struct *fsp, int fromfd,
133 const DATA_BLOB *hdr, SMB_OFF_T offset,
135 static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn,
136 const char *oldname, const char *newname);
137 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd);
138 static int smb_full_audit_stat(vfs_handle_struct *handle, connection_struct *conn,
139 const char *fname, SMB_STRUCT_STAT *sbuf);
140 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
141 SMB_STRUCT_STAT *sbuf);
142 static int smb_full_audit_lstat(vfs_handle_struct *handle, connection_struct *conn,
143 const char *path, SMB_STRUCT_STAT *sbuf);
144 static int smb_full_audit_unlink(vfs_handle_struct *handle, connection_struct *conn,
146 static int smb_full_audit_chmod(vfs_handle_struct *handle, connection_struct *conn,
147 const char *path, mode_t mode);
148 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
150 static int smb_full_audit_chown(vfs_handle_struct *handle, connection_struct *conn,
151 const char *path, uid_t uid, gid_t gid);
152 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
153 uid_t uid, gid_t gid);
154 static int smb_full_audit_chdir(vfs_handle_struct *handle, connection_struct *conn,
156 static char *smb_full_audit_getwd(vfs_handle_struct *handle, connection_struct *conn,
158 static int smb_full_audit_utime(vfs_handle_struct *handle, connection_struct *conn,
159 const char *path, struct utimbuf *times);
160 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
161 int fd, SMB_OFF_T len);
162 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
163 int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
164 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
165 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
166 static int smb_full_audit_symlink(vfs_handle_struct *handle, connection_struct *conn,
167 const char *oldpath, const char *newpath);
168 static int smb_full_audit_readlink(vfs_handle_struct *handle, connection_struct *conn,
169 const char *path, char *buf, size_t bufsiz);
170 static int smb_full_audit_link(vfs_handle_struct *handle, connection_struct *conn,
171 const char *oldpath, const char *newpath);
172 static int smb_full_audit_mknod(vfs_handle_struct *handle, connection_struct *conn,
173 const char *pathname, mode_t mode, SMB_DEV_T dev);
174 static char *smb_full_audit_realpath(vfs_handle_struct *handle, connection_struct *conn,
175 const char *path, char *resolved_path);
176 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
177 int fd, uint32 security_info,
179 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
180 const char *name, uint32 security_info,
182 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
183 int fd, uint32 security_info_sent,
185 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
186 const char *name, uint32 security_info_sent,
188 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, connection_struct *conn,
189 const char *path, mode_t mode);
190 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
191 int fd, mode_t mode);
192 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
193 connection_struct *conn,
194 SMB_ACL_T theacl, int entry_id,
195 SMB_ACL_ENTRY_T *entry_p);
196 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
197 connection_struct *conn,
198 SMB_ACL_ENTRY_T entry_d,
199 SMB_ACL_TAG_T *tag_type_p);
200 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
201 connection_struct *conn,
202 SMB_ACL_ENTRY_T entry_d,
203 SMB_ACL_PERMSET_T *permset_p);
204 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
205 connection_struct *conn,
206 SMB_ACL_ENTRY_T entry_d);
207 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
208 connection_struct *conn,
210 SMB_ACL_TYPE_T type);
211 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
214 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
215 connection_struct *conn,
216 SMB_ACL_PERMSET_T permset);
217 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
218 connection_struct *conn,
219 SMB_ACL_PERMSET_T permset,
220 SMB_ACL_PERM_T perm);
221 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
222 connection_struct *conn, SMB_ACL_T theacl,
224 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
225 connection_struct *conn,
227 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
228 connection_struct *conn, SMB_ACL_T *pacl,
229 SMB_ACL_ENTRY_T *pentry);
230 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
231 connection_struct *conn,
232 SMB_ACL_ENTRY_T entry,
233 SMB_ACL_TAG_T tagtype);
234 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
235 connection_struct *conn,
236 SMB_ACL_ENTRY_T entry,
238 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
239 connection_struct *conn,
240 SMB_ACL_ENTRY_T entry,
241 SMB_ACL_PERMSET_T permset);
242 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
243 connection_struct *conn,
245 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
246 connection_struct *conn,
247 const char *name, SMB_ACL_TYPE_T acltype,
249 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
250 int fd, SMB_ACL_T theacl);
251 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
252 connection_struct *conn,
254 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
255 connection_struct *conn,
256 SMB_ACL_PERMSET_T permset,
257 SMB_ACL_PERM_T perm);
258 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
259 connection_struct *conn,
261 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
262 connection_struct *conn,
263 SMB_ACL_T posix_acl);
264 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
265 connection_struct *conn,
267 SMB_ACL_TAG_T tagtype);
268 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
269 struct connection_struct *conn, const char *path,
270 const char *name, void *value, size_t size);
271 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
272 struct connection_struct *conn,
273 const char *path, const char *name,
274 void *value, size_t size);
275 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
276 struct files_struct *fsp, int fd,
277 const char *name, void *value, size_t size);
278 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
279 struct connection_struct *conn,
280 const char *path, char *list, size_t size);
281 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
282 struct connection_struct *conn,
283 const char *path, char *list, size_t size);
284 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
285 struct files_struct *fsp, int fd, char *list,
287 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
288 struct connection_struct *conn, const char *path,
290 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
291 struct connection_struct *conn, const char *path,
293 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
294 struct files_struct *fsp, int fd,
296 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
297 struct connection_struct *conn, const char *path,
298 const char *name, const void *value, size_t size,
300 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
301 struct connection_struct *conn, const char *path,
302 const char *name, const void *value, size_t size,
304 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
305 struct files_struct *fsp, int fd, const char *name,
306 const void *value, size_t size, int flags);
308 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
309 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
310 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
311 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb);
312 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
313 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
314 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);
318 static vfs_op_tuple audit_op_tuples[] = {
320 /* Disk operations */
322 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
323 SMB_VFS_LAYER_LOGGER},
324 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
325 SMB_VFS_LAYER_LOGGER},
326 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
327 SMB_VFS_LAYER_LOGGER},
328 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
329 SMB_VFS_LAYER_LOGGER},
330 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
331 SMB_VFS_LAYER_LOGGER},
332 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
333 SMB_VFS_LAYER_LOGGER},
334 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
335 SMB_VFS_LAYER_LOGGER},
337 /* Directory operations */
339 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
340 SMB_VFS_LAYER_LOGGER},
341 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
342 SMB_VFS_LAYER_LOGGER},
343 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
344 SMB_VFS_LAYER_LOGGER},
345 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
346 SMB_VFS_LAYER_LOGGER},
347 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
348 SMB_VFS_LAYER_LOGGER},
349 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
350 SMB_VFS_LAYER_LOGGER},
351 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
352 SMB_VFS_LAYER_LOGGER},
353 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
354 SMB_VFS_LAYER_LOGGER},
356 /* File operations */
358 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
359 SMB_VFS_LAYER_LOGGER},
360 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
361 SMB_VFS_LAYER_LOGGER},
362 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
381 SMB_VFS_LAYER_LOGGER},
382 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
383 SMB_VFS_LAYER_LOGGER},
384 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
385 SMB_VFS_LAYER_LOGGER},
386 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
387 SMB_VFS_LAYER_LOGGER},
388 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
389 SMB_VFS_LAYER_LOGGER},
390 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
391 SMB_VFS_LAYER_LOGGER},
392 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
393 SMB_VFS_LAYER_LOGGER},
394 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
395 SMB_VFS_LAYER_LOGGER},
396 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
397 SMB_VFS_LAYER_LOGGER},
398 {SMB_VFS_OP(smb_full_audit_utime), SMB_VFS_OP_UTIME,
399 SMB_VFS_LAYER_LOGGER},
400 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
401 SMB_VFS_LAYER_LOGGER},
402 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
403 SMB_VFS_LAYER_LOGGER},
404 {SMB_VFS_OP(smb_full_audit_getlock), SMB_VFS_OP_GETLOCK,
405 SMB_VFS_LAYER_LOGGER},
406 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
411 SMB_VFS_LAYER_LOGGER},
412 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
413 SMB_VFS_LAYER_LOGGER},
414 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
415 SMB_VFS_LAYER_LOGGER},
417 /* NT ACL operations. */
419 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
420 SMB_VFS_LAYER_LOGGER},
421 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
422 SMB_VFS_LAYER_LOGGER},
423 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
424 SMB_VFS_LAYER_LOGGER},
425 {SMB_VFS_OP(smb_full_audit_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
426 SMB_VFS_LAYER_LOGGER},
428 /* POSIX ACL operations. */
430 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
473 SMB_VFS_LAYER_LOGGER},
474 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
475 SMB_VFS_LAYER_LOGGER},
476 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
477 SMB_VFS_LAYER_LOGGER},
481 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
482 SMB_VFS_LAYER_LOGGER},
483 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
484 SMB_VFS_LAYER_LOGGER},
485 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
486 SMB_VFS_LAYER_LOGGER},
487 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
488 SMB_VFS_LAYER_LOGGER},
489 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
494 SMB_VFS_LAYER_LOGGER},
495 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
496 SMB_VFS_LAYER_LOGGER},
497 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
498 SMB_VFS_LAYER_LOGGER},
499 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
500 SMB_VFS_LAYER_LOGGER},
501 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
502 SMB_VFS_LAYER_LOGGER},
503 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
504 SMB_VFS_LAYER_LOGGER},
506 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
507 SMB_VFS_LAYER_LOGGER},
508 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
509 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
515 SMB_VFS_LAYER_LOGGER},
516 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
517 SMB_VFS_LAYER_LOGGER},
518 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
519 SMB_VFS_LAYER_LOGGER},
521 /* Finish VFS operations definition */
523 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
527 /* The following array *must* be in the same order as defined in vfs.h */
533 { SMB_VFS_OP_CONNECT, "connect" },
534 { SMB_VFS_OP_DISCONNECT, "disconnect" },
535 { SMB_VFS_OP_DISK_FREE, "disk_free" },
536 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
537 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
538 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
539 { SMB_VFS_OP_STATVFS, "statvfs" },
540 { SMB_VFS_OP_OPENDIR, "opendir" },
541 { SMB_VFS_OP_READDIR, "readdir" },
542 { SMB_VFS_OP_SEEKDIR, "seekdir" },
543 { SMB_VFS_OP_TELLDIR, "telldir" },
544 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
545 { SMB_VFS_OP_MKDIR, "mkdir" },
546 { SMB_VFS_OP_RMDIR, "rmdir" },
547 { SMB_VFS_OP_CLOSEDIR, "closedir" },
548 { SMB_VFS_OP_OPEN, "open" },
549 { SMB_VFS_OP_CLOSE, "close" },
550 { SMB_VFS_OP_READ, "read" },
551 { SMB_VFS_OP_PREAD, "pread" },
552 { SMB_VFS_OP_WRITE, "write" },
553 { SMB_VFS_OP_PWRITE, "pwrite" },
554 { SMB_VFS_OP_LSEEK, "lseek" },
555 { SMB_VFS_OP_SENDFILE, "sendfile" },
556 { SMB_VFS_OP_RENAME, "rename" },
557 { SMB_VFS_OP_FSYNC, "fsync" },
558 { SMB_VFS_OP_STAT, "stat" },
559 { SMB_VFS_OP_FSTAT, "fstat" },
560 { SMB_VFS_OP_LSTAT, "lstat" },
561 { SMB_VFS_OP_UNLINK, "unlink" },
562 { SMB_VFS_OP_CHMOD, "chmod" },
563 { SMB_VFS_OP_FCHMOD, "fchmod" },
564 { SMB_VFS_OP_CHOWN, "chown" },
565 { SMB_VFS_OP_FCHOWN, "fchown" },
566 { SMB_VFS_OP_CHDIR, "chdir" },
567 { SMB_VFS_OP_GETWD, "getwd" },
568 { SMB_VFS_OP_UTIME, "utime" },
569 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
570 { SMB_VFS_OP_LOCK, "lock" },
571 { SMB_VFS_OP_GETLOCK, "getlock" },
572 { SMB_VFS_OP_SYMLINK, "symlink" },
573 { SMB_VFS_OP_READLINK, "readlink" },
574 { SMB_VFS_OP_LINK, "link" },
575 { SMB_VFS_OP_MKNOD, "mknod" },
576 { SMB_VFS_OP_REALPATH, "realpath" },
577 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
578 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
579 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
580 { SMB_VFS_OP_SET_NT_ACL, "set_nt_acl" },
581 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
582 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
583 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
584 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
585 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
586 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
587 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
588 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
589 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
590 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
591 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
592 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
593 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
594 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
595 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
596 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
597 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
598 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
599 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
600 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
601 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
602 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
603 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
604 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
605 { SMB_VFS_OP_GETXATTR, "getxattr" },
606 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
607 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
608 { SMB_VFS_OP_LISTXATTR, "listxattr" },
609 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
610 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
611 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
612 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
613 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
614 { SMB_VFS_OP_SETXATTR, "setxattr" },
615 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
616 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
617 { SMB_VFS_OP_AIO_READ, "aio_read" },
618 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
619 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
620 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
621 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
622 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
623 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
624 { SMB_VFS_OP_LAST, NULL }
627 static int audit_syslog_facility(vfs_handle_struct *handle)
629 static const struct enum_list enum_log_facilities[] = {
630 { LOG_USER, "USER" },
631 { LOG_LOCAL0, "LOCAL0" },
632 { LOG_LOCAL1, "LOCAL1" },
633 { LOG_LOCAL2, "LOCAL2" },
634 { LOG_LOCAL3, "LOCAL3" },
635 { LOG_LOCAL4, "LOCAL4" },
636 { LOG_LOCAL5, "LOCAL5" },
637 { LOG_LOCAL6, "LOCAL6" },
638 { LOG_LOCAL7, "LOCAL7" }
643 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
648 static int audit_syslog_priority(vfs_handle_struct *handle)
650 static const struct enum_list enum_log_priorities[] = {
651 { LOG_EMERG, "EMERG" },
652 { LOG_ALERT, "ALERT" },
653 { LOG_CRIT, "CRIT" },
655 { LOG_WARNING, "WARNING" },
656 { LOG_NOTICE, "NOTICE" },
657 { LOG_INFO, "INFO" },
658 { LOG_DEBUG, "DEBUG" }
663 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority", enum_log_priorities, LOG_NOTICE);
668 static char *audit_prefix(connection_struct *conn)
670 static pstring prefix;
672 pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
674 standard_sub_snum(SNUM(conn), prefix, sizeof(prefix)-1);
678 static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op)
680 struct vfs_full_audit_private_data *pd = NULL;
682 SMB_VFS_HANDLE_GET_DATA(handle, pd,
683 struct vfs_full_audit_private_data,
686 if (pd->success_ops == NULL) {
690 return bitmap_query(pd->success_ops, op);
693 static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op)
695 struct vfs_full_audit_private_data *pd = NULL;
697 SMB_VFS_HANDLE_GET_DATA(handle, pd,
698 struct vfs_full_audit_private_data,
701 if (pd->failure_ops == NULL)
704 return bitmap_query(pd->failure_ops, op);
707 static void init_bitmap(struct bitmap **bm, const char **ops)
709 BOOL log_all = False;
714 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
717 DEBUG(0, ("Could not alloc bitmap -- "
718 "defaulting to logging everything\n"));
722 while (*ops != NULL) {
726 if (strequal(*ops, "all")) {
731 if (strequal(*ops, "none")) {
735 for (i=0; i<SMB_VFS_OP_LAST; i++) {
736 if (vfs_op_names[i].name == NULL) {
737 smb_panic("vfs_full_audit.c: name table not "
738 "in sync with vfs.h\n");
741 if (strequal(*ops, vfs_op_names[i].name)) {
747 DEBUG(0, ("Could not find opname %s, logging all\n",
756 /* The query functions default to True */
762 static const char *audit_opname(vfs_op_type op)
764 if (op >= SMB_VFS_OP_LAST)
765 return "INVALID VFS OP";
766 return vfs_op_names[op].name;
769 static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle,
770 const char *format, ...)
776 if (success && (!log_success(handle, op)))
779 if (!success && (!log_failure(handle, op)))
783 fstrcpy(err_msg, "ok");
785 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
787 va_start(ap, format);
788 vsnprintf(op_msg, sizeof(op_msg), format, ap);
791 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
792 audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
797 /* Free function for the private data. */
799 static void free_private_data(void **p_data)
801 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
803 if (pd->success_ops) {
804 bitmap_free(pd->success_ops);
806 if (pd->failure_ops) {
807 bitmap_free(pd->failure_ops);
813 /* Implementation of vfs_ops. Pass everything on to the default
814 operation but log event first. */
816 static int smb_full_audit_connect(vfs_handle_struct *handle, connection_struct *conn,
817 const char *svc, const char *user)
820 struct vfs_full_audit_private_data *pd = NULL;
821 const char *none[] = { NULL };
822 const char *all [] = { "all" };
828 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
834 openlog("smbd_audit", 0, audit_syslog_facility(handle));
836 init_bitmap(&pd->success_ops,
837 lp_parm_string_list(SNUM(conn), "full_audit", "success",
839 init_bitmap(&pd->failure_ops,
840 lp_parm_string_list(SNUM(conn), "full_audit", "failure",
843 /* Store the private data. */
844 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
845 struct vfs_full_audit_private_data, return -1);
847 result = SMB_VFS_NEXT_CONNECT(handle, conn, svc, user);
849 do_log(SMB_VFS_OP_CONNECT, True, handle,
855 static void smb_full_audit_disconnect(vfs_handle_struct *handle,
856 connection_struct *conn)
858 SMB_VFS_NEXT_DISCONNECT(handle, conn);
860 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
861 "%s", lp_servicename(SNUM(conn)));
863 /* The bitmaps will be disconnected when the private
869 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
870 connection_struct *conn, const char *path,
871 BOOL small_query, SMB_BIG_UINT *bsize,
872 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
876 result = SMB_VFS_NEXT_DISK_FREE(handle, conn, path, small_query, bsize,
879 /* Don't have a reasonable notion of failure here */
881 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
886 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
887 struct connection_struct *conn,
888 enum SMB_QUOTA_TYPE qtype, unid_t id,
893 result = SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, qt);
895 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
901 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
902 struct connection_struct *conn,
903 enum SMB_QUOTA_TYPE qtype, unid_t id,
908 result = SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, qt);
910 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
915 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
916 struct files_struct *fsp,
917 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
921 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
923 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
928 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
929 struct connection_struct *conn,
931 struct vfs_statvfs_struct *statbuf)
935 result = SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf);
937 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
942 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
943 const char *fname, const char *mask, uint32 attr)
945 SMB_STRUCT_DIR *result;
947 result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
949 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
954 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
955 connection_struct *conn, SMB_STRUCT_DIR *dirp)
957 SMB_STRUCT_DIRENT *result;
959 result = SMB_VFS_NEXT_READDIR(handle, conn, dirp);
961 /* This operation has no reasonable error condition
962 * (End of dir is also failure), so always succeed.
964 do_log(SMB_VFS_OP_READDIR, True, handle, "");
969 static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
970 SMB_STRUCT_DIR *dirp, long offset)
972 SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset);
974 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
978 static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn,
979 SMB_STRUCT_DIR *dirp)
983 result = SMB_VFS_NEXT_TELLDIR(handle, conn, dirp);
985 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
990 static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn,
991 SMB_STRUCT_DIR *dirp)
993 SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp);
995 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
999 static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn,
1000 const char *path, mode_t mode)
1004 result = SMB_VFS_NEXT_MKDIR(handle, conn, path, mode);
1006 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1011 static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn,
1016 result = SMB_VFS_NEXT_RMDIR(handle, conn, path);
1018 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1023 static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn,
1024 SMB_STRUCT_DIR *dirp)
1028 result = SMB_VFS_NEXT_CLOSEDIR(handle, conn, dirp);
1030 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1035 static int smb_full_audit_open(vfs_handle_struct *handle, connection_struct *conn,
1036 const char *fname, int flags, mode_t mode)
1040 result = SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
1042 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1043 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1049 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
1053 result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
1055 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1060 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1061 int fd, void *data, size_t n)
1065 result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
1067 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1072 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1073 int fd, void *data, size_t n, SMB_OFF_T offset)
1077 result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
1079 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1084 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1085 int fd, const void *data, size_t n)
1089 result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
1091 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1096 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1097 int fd, const void *data, size_t n,
1102 result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
1104 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1109 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1110 int filedes, SMB_OFF_T offset, int whence)
1114 result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
1116 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1117 "%s", fsp->fsp_name);
1122 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1123 files_struct *fsp, int fromfd,
1124 const DATA_BLOB *hdr, SMB_OFF_T offset,
1129 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr,
1132 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1133 "%s", fsp->fsp_name);
1138 static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn,
1139 const char *oldname, const char *newname)
1143 result = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname);
1145 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1150 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
1154 result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd);
1156 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1161 static int smb_full_audit_stat(vfs_handle_struct *handle, connection_struct *conn,
1162 const char *fname, SMB_STRUCT_STAT *sbuf)
1166 result = SMB_VFS_NEXT_STAT(handle, conn, fname, sbuf);
1168 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1173 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
1174 SMB_STRUCT_STAT *sbuf)
1178 result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf);
1180 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1185 static int smb_full_audit_lstat(vfs_handle_struct *handle, connection_struct *conn,
1186 const char *path, SMB_STRUCT_STAT *sbuf)
1190 result = SMB_VFS_NEXT_LSTAT(handle, conn, path, sbuf);
1192 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1197 static int smb_full_audit_unlink(vfs_handle_struct *handle, connection_struct *conn,
1202 result = SMB_VFS_NEXT_UNLINK(handle, conn, path);
1204 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1209 static int smb_full_audit_chmod(vfs_handle_struct *handle, connection_struct *conn,
1210 const char *path, mode_t mode)
1214 result = SMB_VFS_NEXT_CHMOD(handle, conn, path, mode);
1216 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1221 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
1226 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode);
1228 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1229 "%s|%o", fsp->fsp_name, mode);
1234 static int smb_full_audit_chown(vfs_handle_struct *handle, connection_struct *conn,
1235 const char *path, uid_t uid, gid_t gid)
1239 result = SMB_VFS_NEXT_CHOWN(handle, conn, path, uid, gid);
1241 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1242 path, (long int)uid, (long int)gid);
1247 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
1248 uid_t uid, gid_t gid)
1252 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid);
1254 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1255 fsp->fsp_name, (long int)uid, (long int)gid);
1260 static int smb_full_audit_chdir(vfs_handle_struct *handle, connection_struct *conn,
1265 result = SMB_VFS_NEXT_CHDIR(handle, conn, path);
1267 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1272 static char *smb_full_audit_getwd(vfs_handle_struct *handle, connection_struct *conn,
1277 result = SMB_VFS_NEXT_GETWD(handle, conn, path);
1279 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1284 static int smb_full_audit_utime(vfs_handle_struct *handle, connection_struct *conn,
1285 const char *path, struct utimbuf *times)
1289 result = SMB_VFS_NEXT_UTIME(handle, conn, path, times);
1291 do_log(SMB_VFS_OP_UTIME, (result >= 0), handle, "%s", path);
1296 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1297 int fd, SMB_OFF_T len)
1301 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
1303 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1304 "%s", fsp->fsp_name);
1309 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
1310 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1314 result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
1316 do_log(SMB_VFS_OP_LOCK, (result >= 0), handle, "%s", fsp->fsp_name);
1321 static BOOL smb_full_audit_getlock(vfs_handle_struct *handle, files_struct *fsp, int fd,
1322 SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid)
1326 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, fd, poffset, pcount, ptype, ppid);
1328 do_log(SMB_VFS_OP_GETLOCK, (result >= 0), handle, "%s", fsp->fsp_name);
1333 static int smb_full_audit_symlink(vfs_handle_struct *handle, connection_struct *conn,
1334 const char *oldpath, const char *newpath)
1338 result = SMB_VFS_NEXT_SYMLINK(handle, conn, oldpath, newpath);
1340 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1341 "%s|%s", oldpath, newpath);
1346 static int smb_full_audit_readlink(vfs_handle_struct *handle, connection_struct *conn,
1347 const char *path, char *buf, size_t bufsiz)
1351 result = SMB_VFS_NEXT_READLINK(handle, conn, path, buf, bufsiz);
1353 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1358 static int smb_full_audit_link(vfs_handle_struct *handle, connection_struct *conn,
1359 const char *oldpath, const char *newpath)
1363 result = SMB_VFS_NEXT_LINK(handle, conn, oldpath, newpath);
1365 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1366 "%s|%s", oldpath, newpath);
1371 static int smb_full_audit_mknod(vfs_handle_struct *handle, connection_struct *conn,
1372 const char *pathname, mode_t mode, SMB_DEV_T dev)
1376 result = SMB_VFS_NEXT_MKNOD(handle, conn, pathname, mode, dev);
1378 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1383 static char *smb_full_audit_realpath(vfs_handle_struct *handle, connection_struct *conn,
1384 const char *path, char *resolved_path)
1388 result = SMB_VFS_NEXT_REALPATH(handle, conn, path, resolved_path);
1390 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1395 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1396 int fd, uint32 security_info,
1401 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info,
1404 do_log(SMB_VFS_OP_FGET_NT_ACL, (result > 0), handle,
1405 "%s", fsp->fsp_name);
1410 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1411 const char *name, uint32 security_info,
1416 result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
1419 do_log(SMB_VFS_OP_GET_NT_ACL, (result > 0), handle,
1420 "%s", fsp->fsp_name);
1425 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1426 int fd, uint32 security_info_sent,
1431 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent,
1434 do_log(SMB_VFS_OP_FSET_NT_ACL, result, handle, "%s", fsp->fsp_name);
1439 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1440 const char *name, uint32 security_info_sent,
1445 result = SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent,
1448 do_log(SMB_VFS_OP_SET_NT_ACL, result, handle, "%s", fsp->fsp_name);
1453 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, connection_struct *conn,
1454 const char *path, mode_t mode)
1458 result = SMB_VFS_NEXT_CHMOD_ACL(handle, conn, path, mode);
1460 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1461 "%s|%o", path, mode);
1466 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1467 int fd, mode_t mode)
1471 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode);
1473 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1474 "%s|%o", fsp->fsp_name, mode);
1479 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1480 connection_struct *conn,
1481 SMB_ACL_T theacl, int entry_id,
1482 SMB_ACL_ENTRY_T *entry_p)
1486 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, conn, theacl, entry_id,
1489 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1495 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1496 connection_struct *conn,
1497 SMB_ACL_ENTRY_T entry_d,
1498 SMB_ACL_TAG_T *tag_type_p)
1502 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, conn, entry_d,
1505 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1511 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1512 connection_struct *conn,
1513 SMB_ACL_ENTRY_T entry_d,
1514 SMB_ACL_PERMSET_T *permset_p)
1518 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, conn, entry_d,
1521 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1527 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1528 connection_struct *conn,
1529 SMB_ACL_ENTRY_T entry_d)
1533 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, conn, entry_d);
1535 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1541 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1542 connection_struct *conn,
1544 SMB_ACL_TYPE_T type)
1548 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, conn, path_p, type);
1550 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1556 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1557 files_struct *fsp, int fd)
1561 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd);
1563 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1564 "%s", fsp->fsp_name);
1569 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1570 connection_struct *conn,
1571 SMB_ACL_PERMSET_T permset)
1575 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, conn, permset);
1577 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1583 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1584 connection_struct *conn,
1585 SMB_ACL_PERMSET_T permset,
1586 SMB_ACL_PERM_T perm)
1590 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, conn, permset, perm);
1592 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1598 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1599 connection_struct *conn, SMB_ACL_T theacl,
1604 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, conn, theacl, plen);
1606 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1612 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1613 connection_struct *conn,
1618 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, conn, count);
1620 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1626 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1627 connection_struct *conn, SMB_ACL_T *pacl,
1628 SMB_ACL_ENTRY_T *pentry)
1632 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, conn, pacl, pentry);
1634 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1640 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1641 connection_struct *conn,
1642 SMB_ACL_ENTRY_T entry,
1643 SMB_ACL_TAG_T tagtype)
1647 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, conn, entry,
1650 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1656 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1657 connection_struct *conn,
1658 SMB_ACL_ENTRY_T entry,
1663 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, conn, entry, qual);
1665 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1671 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1672 connection_struct *conn,
1673 SMB_ACL_ENTRY_T entry,
1674 SMB_ACL_PERMSET_T permset)
1678 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, conn, entry, permset);
1680 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1686 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1687 connection_struct *conn,
1692 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, conn, theacl);
1694 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1700 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1701 connection_struct *conn,
1702 const char *name, SMB_ACL_TYPE_T acltype,
1707 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, conn, name, acltype,
1710 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1716 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1717 int fd, SMB_ACL_T theacl)
1721 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl);
1723 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1724 "%s", fsp->fsp_name);
1729 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1730 connection_struct *conn,
1735 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, conn, path);
1737 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1743 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1744 connection_struct *conn,
1745 SMB_ACL_PERMSET_T permset,
1746 SMB_ACL_PERM_T perm)
1750 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, conn, permset, perm);
1752 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1758 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1759 connection_struct *conn,
1764 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, conn, text);
1766 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1772 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1773 connection_struct *conn,
1774 SMB_ACL_T posix_acl)
1778 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, conn, posix_acl);
1780 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1786 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1787 connection_struct *conn,
1789 SMB_ACL_TAG_T tagtype)
1793 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, conn, qualifier,
1796 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1802 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1803 struct connection_struct *conn, const char *path,
1804 const char *name, void *value, size_t size)
1808 result = SMB_VFS_NEXT_GETXATTR(handle, conn, path, name, value, size);
1810 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1811 "%s|%s", path, name);
1816 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1817 struct connection_struct *conn,
1818 const char *path, const char *name,
1819 void *value, size_t size)
1823 result = SMB_VFS_NEXT_LGETXATTR(handle, conn, path, name, value, size);
1825 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1826 "%s|%s", path, name);
1831 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1832 struct files_struct *fsp, int fd,
1833 const char *name, void *value, size_t size)
1837 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size);
1839 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1840 "%s|%s", fsp->fsp_name, name);
1845 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1846 struct connection_struct *conn,
1847 const char *path, char *list, size_t size)
1851 result = SMB_VFS_NEXT_LISTXATTR(handle, conn, path, list, size);
1853 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1858 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1859 struct connection_struct *conn,
1860 const char *path, char *list, size_t size)
1864 result = SMB_VFS_NEXT_LLISTXATTR(handle, conn, path, list, size);
1866 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1871 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1872 struct files_struct *fsp, int fd, char *list,
1877 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size);
1879 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1880 "%s", fsp->fsp_name);
1885 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1886 struct connection_struct *conn, const char *path,
1891 result = SMB_VFS_NEXT_REMOVEXATTR(handle, conn, path, name);
1893 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1894 "%s|%s", path, name);
1899 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1900 struct connection_struct *conn, const char *path,
1905 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, conn, path, name);
1907 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1908 "%s|%s", path, name);
1913 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1914 struct files_struct *fsp, int fd,
1919 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name);
1921 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1922 "%s|%s", fsp->fsp_name, name);
1927 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1928 struct connection_struct *conn, const char *path,
1929 const char *name, const void *value, size_t size,
1934 result = SMB_VFS_NEXT_SETXATTR(handle, conn, path, name, value, size,
1937 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
1938 "%s|%s", path, name);
1943 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
1944 struct connection_struct *conn, const char *path,
1945 const char *name, const void *value, size_t size,
1950 result = SMB_VFS_NEXT_LSETXATTR(handle, conn, path, name, value, size,
1953 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
1954 "%s|%s", path, name);
1959 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
1960 struct files_struct *fsp, int fd, const char *name,
1961 const void *value, size_t size, int flags)
1965 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size,
1968 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
1969 "%s|%s", fsp->fsp_name, name);
1974 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1978 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
1979 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
1980 "%s", fsp->fsp_name);
1985 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1989 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
1990 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
1991 "%s", fsp->fsp_name);
1996 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2000 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2001 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
2002 "%s", fsp->fsp_name);
2007 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
2011 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb);
2012 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
2013 "%s", fsp->fsp_name);
2018 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2022 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2023 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2024 "%s", fsp->fsp_name);
2029 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2033 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2034 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2035 "%s", fsp->fsp_name);
2040 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)
2044 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2045 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2046 "%s", fsp->fsp_name);
2052 NTSTATUS vfs_full_audit_init(void)
2054 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2055 "full_audit", audit_op_tuples);
2057 if (!NT_STATUS_IS_OK(ret))
2060 vfs_full_audit_debug_level = debug_add_class("full_audit");
2061 if (vfs_full_audit_debug_level == -1) {
2062 vfs_full_audit_debug_level = DBGC_VFS;
2063 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2066 DEBUG(10, ("vfs_full_audit: Debug class number of "
2067 "'full_audit': %d\n", vfs_full_audit_debug_level));