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 int smb_full_audit_symlink(vfs_handle_struct *handle, connection_struct *conn,
165 const char *oldpath, const char *newpath);
166 static int smb_full_audit_readlink(vfs_handle_struct *handle, connection_struct *conn,
167 const char *path, char *buf, size_t bufsiz);
168 static int smb_full_audit_link(vfs_handle_struct *handle, connection_struct *conn,
169 const char *oldpath, const char *newpath);
170 static int smb_full_audit_mknod(vfs_handle_struct *handle, connection_struct *conn,
171 const char *pathname, mode_t mode, SMB_DEV_T dev);
172 static char *smb_full_audit_realpath(vfs_handle_struct *handle, connection_struct *conn,
173 const char *path, char *resolved_path);
174 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
175 int fd, uint32 security_info,
177 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
178 const char *name, uint32 security_info,
180 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
181 int fd, uint32 security_info_sent,
183 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
184 const char *name, uint32 security_info_sent,
186 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, connection_struct *conn,
187 const char *path, mode_t mode);
188 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
189 int fd, mode_t mode);
190 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
191 connection_struct *conn,
192 SMB_ACL_T theacl, int entry_id,
193 SMB_ACL_ENTRY_T *entry_p);
194 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
195 connection_struct *conn,
196 SMB_ACL_ENTRY_T entry_d,
197 SMB_ACL_TAG_T *tag_type_p);
198 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
199 connection_struct *conn,
200 SMB_ACL_ENTRY_T entry_d,
201 SMB_ACL_PERMSET_T *permset_p);
202 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
203 connection_struct *conn,
204 SMB_ACL_ENTRY_T entry_d);
205 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
206 connection_struct *conn,
208 SMB_ACL_TYPE_T type);
209 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
212 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
213 connection_struct *conn,
214 SMB_ACL_PERMSET_T permset);
215 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
216 connection_struct *conn,
217 SMB_ACL_PERMSET_T permset,
218 SMB_ACL_PERM_T perm);
219 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
220 connection_struct *conn, SMB_ACL_T theacl,
222 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
223 connection_struct *conn,
225 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
226 connection_struct *conn, SMB_ACL_T *pacl,
227 SMB_ACL_ENTRY_T *pentry);
228 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
229 connection_struct *conn,
230 SMB_ACL_ENTRY_T entry,
231 SMB_ACL_TAG_T tagtype);
232 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
233 connection_struct *conn,
234 SMB_ACL_ENTRY_T entry,
236 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
237 connection_struct *conn,
238 SMB_ACL_ENTRY_T entry,
239 SMB_ACL_PERMSET_T permset);
240 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
241 connection_struct *conn,
243 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
244 connection_struct *conn,
245 const char *name, SMB_ACL_TYPE_T acltype,
247 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
248 int fd, SMB_ACL_T theacl);
249 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
250 connection_struct *conn,
252 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
253 connection_struct *conn,
254 SMB_ACL_PERMSET_T permset,
255 SMB_ACL_PERM_T perm);
256 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
257 connection_struct *conn,
259 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
260 connection_struct *conn,
261 SMB_ACL_T posix_acl);
262 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
263 connection_struct *conn,
265 SMB_ACL_TAG_T tagtype);
266 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
267 struct connection_struct *conn, const char *path,
268 const char *name, void *value, size_t size);
269 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
270 struct connection_struct *conn,
271 const char *path, const char *name,
272 void *value, size_t size);
273 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
274 struct files_struct *fsp, int fd,
275 const char *name, void *value, size_t size);
276 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
277 struct connection_struct *conn,
278 const char *path, char *list, size_t size);
279 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
280 struct connection_struct *conn,
281 const char *path, char *list, size_t size);
282 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
283 struct files_struct *fsp, int fd, char *list,
285 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
286 struct connection_struct *conn, const char *path,
288 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
289 struct connection_struct *conn, const char *path,
291 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
292 struct files_struct *fsp, int fd,
294 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
295 struct connection_struct *conn, const char *path,
296 const char *name, const void *value, size_t size,
298 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
299 struct connection_struct *conn, const char *path,
300 const char *name, const void *value, size_t size,
302 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
303 struct files_struct *fsp, int fd, const char *name,
304 const void *value, size_t size, int flags);
306 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
307 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
308 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
309 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb);
310 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
311 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
312 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);
316 static vfs_op_tuple audit_op_tuples[] = {
318 /* Disk operations */
320 {SMB_VFS_OP(smb_full_audit_connect), SMB_VFS_OP_CONNECT,
321 SMB_VFS_LAYER_LOGGER},
322 {SMB_VFS_OP(smb_full_audit_disconnect), SMB_VFS_OP_DISCONNECT,
323 SMB_VFS_LAYER_LOGGER},
324 {SMB_VFS_OP(smb_full_audit_disk_free), SMB_VFS_OP_DISK_FREE,
325 SMB_VFS_LAYER_LOGGER},
326 {SMB_VFS_OP(smb_full_audit_get_quota), SMB_VFS_OP_GET_QUOTA,
327 SMB_VFS_LAYER_LOGGER},
328 {SMB_VFS_OP(smb_full_audit_set_quota), SMB_VFS_OP_SET_QUOTA,
329 SMB_VFS_LAYER_LOGGER},
330 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
331 SMB_VFS_LAYER_LOGGER},
332 {SMB_VFS_OP(smb_full_audit_statvfs), SMB_VFS_OP_STATVFS,
333 SMB_VFS_LAYER_LOGGER},
335 /* Directory operations */
337 {SMB_VFS_OP(smb_full_audit_opendir), SMB_VFS_OP_OPENDIR,
338 SMB_VFS_LAYER_LOGGER},
339 {SMB_VFS_OP(smb_full_audit_readdir), SMB_VFS_OP_READDIR,
340 SMB_VFS_LAYER_LOGGER},
341 {SMB_VFS_OP(smb_full_audit_seekdir), SMB_VFS_OP_SEEKDIR,
342 SMB_VFS_LAYER_LOGGER},
343 {SMB_VFS_OP(smb_full_audit_telldir), SMB_VFS_OP_TELLDIR,
344 SMB_VFS_LAYER_LOGGER},
345 {SMB_VFS_OP(smb_full_audit_rewinddir), SMB_VFS_OP_REWINDDIR,
346 SMB_VFS_LAYER_LOGGER},
347 {SMB_VFS_OP(smb_full_audit_mkdir), SMB_VFS_OP_MKDIR,
348 SMB_VFS_LAYER_LOGGER},
349 {SMB_VFS_OP(smb_full_audit_rmdir), SMB_VFS_OP_RMDIR,
350 SMB_VFS_LAYER_LOGGER},
351 {SMB_VFS_OP(smb_full_audit_closedir), SMB_VFS_OP_CLOSEDIR,
352 SMB_VFS_LAYER_LOGGER},
354 /* File operations */
356 {SMB_VFS_OP(smb_full_audit_open), SMB_VFS_OP_OPEN,
357 SMB_VFS_LAYER_LOGGER},
358 {SMB_VFS_OP(smb_full_audit_close), SMB_VFS_OP_CLOSE,
359 SMB_VFS_LAYER_LOGGER},
360 {SMB_VFS_OP(smb_full_audit_read), SMB_VFS_OP_READ,
361 SMB_VFS_LAYER_LOGGER},
362 {SMB_VFS_OP(smb_full_audit_pread), SMB_VFS_OP_PREAD,
363 SMB_VFS_LAYER_LOGGER},
364 {SMB_VFS_OP(smb_full_audit_write), SMB_VFS_OP_WRITE,
365 SMB_VFS_LAYER_LOGGER},
366 {SMB_VFS_OP(smb_full_audit_pwrite), SMB_VFS_OP_PWRITE,
367 SMB_VFS_LAYER_LOGGER},
368 {SMB_VFS_OP(smb_full_audit_lseek), SMB_VFS_OP_LSEEK,
369 SMB_VFS_LAYER_LOGGER},
370 {SMB_VFS_OP(smb_full_audit_sendfile), SMB_VFS_OP_SENDFILE,
371 SMB_VFS_LAYER_LOGGER},
372 {SMB_VFS_OP(smb_full_audit_rename), SMB_VFS_OP_RENAME,
373 SMB_VFS_LAYER_LOGGER},
374 {SMB_VFS_OP(smb_full_audit_fsync), SMB_VFS_OP_FSYNC,
375 SMB_VFS_LAYER_LOGGER},
376 {SMB_VFS_OP(smb_full_audit_stat), SMB_VFS_OP_STAT,
377 SMB_VFS_LAYER_LOGGER},
378 {SMB_VFS_OP(smb_full_audit_fstat), SMB_VFS_OP_FSTAT,
379 SMB_VFS_LAYER_LOGGER},
380 {SMB_VFS_OP(smb_full_audit_lstat), SMB_VFS_OP_LSTAT,
381 SMB_VFS_LAYER_LOGGER},
382 {SMB_VFS_OP(smb_full_audit_unlink), SMB_VFS_OP_UNLINK,
383 SMB_VFS_LAYER_LOGGER},
384 {SMB_VFS_OP(smb_full_audit_chmod), SMB_VFS_OP_CHMOD,
385 SMB_VFS_LAYER_LOGGER},
386 {SMB_VFS_OP(smb_full_audit_fchmod), SMB_VFS_OP_FCHMOD,
387 SMB_VFS_LAYER_LOGGER},
388 {SMB_VFS_OP(smb_full_audit_chown), SMB_VFS_OP_CHOWN,
389 SMB_VFS_LAYER_LOGGER},
390 {SMB_VFS_OP(smb_full_audit_fchown), SMB_VFS_OP_FCHOWN,
391 SMB_VFS_LAYER_LOGGER},
392 {SMB_VFS_OP(smb_full_audit_chdir), SMB_VFS_OP_CHDIR,
393 SMB_VFS_LAYER_LOGGER},
394 {SMB_VFS_OP(smb_full_audit_getwd), SMB_VFS_OP_GETWD,
395 SMB_VFS_LAYER_LOGGER},
396 {SMB_VFS_OP(smb_full_audit_utime), SMB_VFS_OP_UTIME,
397 SMB_VFS_LAYER_LOGGER},
398 {SMB_VFS_OP(smb_full_audit_ftruncate), SMB_VFS_OP_FTRUNCATE,
399 SMB_VFS_LAYER_LOGGER},
400 {SMB_VFS_OP(smb_full_audit_lock), SMB_VFS_OP_LOCK,
401 SMB_VFS_LAYER_LOGGER},
402 {SMB_VFS_OP(smb_full_audit_symlink), SMB_VFS_OP_SYMLINK,
403 SMB_VFS_LAYER_LOGGER},
404 {SMB_VFS_OP(smb_full_audit_readlink), SMB_VFS_OP_READLINK,
405 SMB_VFS_LAYER_LOGGER},
406 {SMB_VFS_OP(smb_full_audit_link), SMB_VFS_OP_LINK,
407 SMB_VFS_LAYER_LOGGER},
408 {SMB_VFS_OP(smb_full_audit_mknod), SMB_VFS_OP_MKNOD,
409 SMB_VFS_LAYER_LOGGER},
410 {SMB_VFS_OP(smb_full_audit_realpath), SMB_VFS_OP_REALPATH,
411 SMB_VFS_LAYER_LOGGER},
413 /* NT ACL operations. */
415 {SMB_VFS_OP(smb_full_audit_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL,
416 SMB_VFS_LAYER_LOGGER},
417 {SMB_VFS_OP(smb_full_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
418 SMB_VFS_LAYER_LOGGER},
419 {SMB_VFS_OP(smb_full_audit_fset_nt_acl), SMB_VFS_OP_FSET_NT_ACL,
420 SMB_VFS_LAYER_LOGGER},
421 {SMB_VFS_OP(smb_full_audit_set_nt_acl), SMB_VFS_OP_SET_NT_ACL,
422 SMB_VFS_LAYER_LOGGER},
424 /* POSIX ACL operations. */
426 {SMB_VFS_OP(smb_full_audit_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
427 SMB_VFS_LAYER_LOGGER},
428 {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
429 SMB_VFS_LAYER_LOGGER},
430 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry), SMB_VFS_OP_SYS_ACL_GET_ENTRY,
431 SMB_VFS_LAYER_LOGGER},
432 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
433 SMB_VFS_LAYER_LOGGER},
434 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset), SMB_VFS_OP_SYS_ACL_GET_PERMSET,
435 SMB_VFS_LAYER_LOGGER},
436 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
437 SMB_VFS_LAYER_LOGGER},
438 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE,
439 SMB_VFS_LAYER_LOGGER},
440 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd), SMB_VFS_OP_SYS_ACL_GET_FD,
441 SMB_VFS_LAYER_LOGGER},
442 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
443 SMB_VFS_LAYER_LOGGER},
444 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm), SMB_VFS_OP_SYS_ACL_ADD_PERM,
445 SMB_VFS_LAYER_LOGGER},
446 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text), SMB_VFS_OP_SYS_ACL_TO_TEXT,
447 SMB_VFS_LAYER_LOGGER},
448 {SMB_VFS_OP(smb_full_audit_sys_acl_init), SMB_VFS_OP_SYS_ACL_INIT,
449 SMB_VFS_LAYER_LOGGER},
450 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
451 SMB_VFS_LAYER_LOGGER},
452 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
453 SMB_VFS_LAYER_LOGGER},
454 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
455 SMB_VFS_LAYER_LOGGER},
456 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset), SMB_VFS_OP_SYS_ACL_SET_PERMSET,
457 SMB_VFS_LAYER_LOGGER},
458 {SMB_VFS_OP(smb_full_audit_sys_acl_valid), SMB_VFS_OP_SYS_ACL_VALID,
459 SMB_VFS_LAYER_LOGGER},
460 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE,
461 SMB_VFS_LAYER_LOGGER},
462 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd), SMB_VFS_OP_SYS_ACL_SET_FD,
463 SMB_VFS_LAYER_LOGGER},
464 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
465 SMB_VFS_LAYER_LOGGER},
466 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm), SMB_VFS_OP_SYS_ACL_GET_PERM,
467 SMB_VFS_LAYER_LOGGER},
468 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT,
469 SMB_VFS_LAYER_LOGGER},
470 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL,
471 SMB_VFS_LAYER_LOGGER},
472 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
473 SMB_VFS_LAYER_LOGGER},
477 {SMB_VFS_OP(smb_full_audit_getxattr), SMB_VFS_OP_GETXATTR,
478 SMB_VFS_LAYER_LOGGER},
479 {SMB_VFS_OP(smb_full_audit_lgetxattr), SMB_VFS_OP_LGETXATTR,
480 SMB_VFS_LAYER_LOGGER},
481 {SMB_VFS_OP(smb_full_audit_fgetxattr), SMB_VFS_OP_FGETXATTR,
482 SMB_VFS_LAYER_LOGGER},
483 {SMB_VFS_OP(smb_full_audit_listxattr), SMB_VFS_OP_LISTXATTR,
484 SMB_VFS_LAYER_LOGGER},
485 {SMB_VFS_OP(smb_full_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
486 SMB_VFS_LAYER_LOGGER},
487 {SMB_VFS_OP(smb_full_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
488 SMB_VFS_LAYER_LOGGER},
489 {SMB_VFS_OP(smb_full_audit_removexattr), SMB_VFS_OP_REMOVEXATTR,
490 SMB_VFS_LAYER_LOGGER},
491 {SMB_VFS_OP(smb_full_audit_lremovexattr), SMB_VFS_OP_LREMOVEXATTR,
492 SMB_VFS_LAYER_LOGGER},
493 {SMB_VFS_OP(smb_full_audit_fremovexattr), SMB_VFS_OP_FREMOVEXATTR,
494 SMB_VFS_LAYER_LOGGER},
495 {SMB_VFS_OP(smb_full_audit_setxattr), SMB_VFS_OP_SETXATTR,
496 SMB_VFS_LAYER_LOGGER},
497 {SMB_VFS_OP(smb_full_audit_lsetxattr), SMB_VFS_OP_LSETXATTR,
498 SMB_VFS_LAYER_LOGGER},
499 {SMB_VFS_OP(smb_full_audit_fsetxattr), SMB_VFS_OP_FSETXATTR,
500 SMB_VFS_LAYER_LOGGER},
502 {SMB_VFS_OP(smb_full_audit_aio_read), SMB_VFS_OP_AIO_READ,
503 SMB_VFS_LAYER_LOGGER},
504 {SMB_VFS_OP(smb_full_audit_aio_write), SMB_VFS_OP_AIO_WRITE,
505 SMB_VFS_LAYER_LOGGER},
506 {SMB_VFS_OP(smb_full_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
507 SMB_VFS_LAYER_LOGGER},
508 {SMB_VFS_OP(smb_full_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
509 SMB_VFS_LAYER_LOGGER},
510 {SMB_VFS_OP(smb_full_audit_aio_error), SMB_VFS_OP_AIO_ERROR,
511 SMB_VFS_LAYER_LOGGER},
512 {SMB_VFS_OP(smb_full_audit_aio_fsync), SMB_VFS_OP_AIO_FSYNC,
513 SMB_VFS_LAYER_LOGGER},
514 {SMB_VFS_OP(smb_full_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
515 SMB_VFS_LAYER_LOGGER},
517 /* Finish VFS operations definition */
519 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP,
523 /* The following array *must* be in the same order as defined in vfs.h */
529 { SMB_VFS_OP_CONNECT, "connect" },
530 { SMB_VFS_OP_DISCONNECT, "disconnect" },
531 { SMB_VFS_OP_DISK_FREE, "disk_free" },
532 { SMB_VFS_OP_GET_QUOTA, "get_quota" },
533 { SMB_VFS_OP_SET_QUOTA, "set_quota" },
534 { SMB_VFS_OP_GET_SHADOW_COPY_DATA, "get_shadow_copy_data" },
535 { SMB_VFS_OP_STATVFS, "statvfs" },
536 { SMB_VFS_OP_OPENDIR, "opendir" },
537 { SMB_VFS_OP_READDIR, "readdir" },
538 { SMB_VFS_OP_SEEKDIR, "seekdir" },
539 { SMB_VFS_OP_TELLDIR, "telldir" },
540 { SMB_VFS_OP_REWINDDIR, "rewinddir" },
541 { SMB_VFS_OP_MKDIR, "mkdir" },
542 { SMB_VFS_OP_RMDIR, "rmdir" },
543 { SMB_VFS_OP_CLOSEDIR, "closedir" },
544 { SMB_VFS_OP_OPEN, "open" },
545 { SMB_VFS_OP_CLOSE, "close" },
546 { SMB_VFS_OP_READ, "read" },
547 { SMB_VFS_OP_PREAD, "pread" },
548 { SMB_VFS_OP_WRITE, "write" },
549 { SMB_VFS_OP_PWRITE, "pwrite" },
550 { SMB_VFS_OP_LSEEK, "lseek" },
551 { SMB_VFS_OP_SENDFILE, "sendfile" },
552 { SMB_VFS_OP_RENAME, "rename" },
553 { SMB_VFS_OP_FSYNC, "fsync" },
554 { SMB_VFS_OP_STAT, "stat" },
555 { SMB_VFS_OP_FSTAT, "fstat" },
556 { SMB_VFS_OP_LSTAT, "lstat" },
557 { SMB_VFS_OP_UNLINK, "unlink" },
558 { SMB_VFS_OP_CHMOD, "chmod" },
559 { SMB_VFS_OP_FCHMOD, "fchmod" },
560 { SMB_VFS_OP_CHOWN, "chown" },
561 { SMB_VFS_OP_FCHOWN, "fchown" },
562 { SMB_VFS_OP_CHDIR, "chdir" },
563 { SMB_VFS_OP_GETWD, "getwd" },
564 { SMB_VFS_OP_UTIME, "utime" },
565 { SMB_VFS_OP_FTRUNCATE, "ftruncate" },
566 { SMB_VFS_OP_LOCK, "lock" },
567 { SMB_VFS_OP_SYMLINK, "symlink" },
568 { SMB_VFS_OP_READLINK, "readlink" },
569 { SMB_VFS_OP_LINK, "link" },
570 { SMB_VFS_OP_MKNOD, "mknod" },
571 { SMB_VFS_OP_REALPATH, "realpath" },
572 { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" },
573 { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" },
574 { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" },
575 { SMB_VFS_OP_SET_NT_ACL, "set_nt_acl" },
576 { SMB_VFS_OP_CHMOD_ACL, "chmod_acl" },
577 { SMB_VFS_OP_FCHMOD_ACL, "fchmod_acl" },
578 { SMB_VFS_OP_SYS_ACL_GET_ENTRY, "sys_acl_get_entry" },
579 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, "sys_acl_get_tag_type" },
580 { SMB_VFS_OP_SYS_ACL_GET_PERMSET, "sys_acl_get_permset" },
581 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, "sys_acl_get_qualifier" },
582 { SMB_VFS_OP_SYS_ACL_GET_FILE, "sys_acl_get_file" },
583 { SMB_VFS_OP_SYS_ACL_GET_FD, "sys_acl_get_fd" },
584 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, "sys_acl_clear_perms" },
585 { SMB_VFS_OP_SYS_ACL_ADD_PERM, "sys_acl_add_perm" },
586 { SMB_VFS_OP_SYS_ACL_TO_TEXT, "sys_acl_to_text" },
587 { SMB_VFS_OP_SYS_ACL_INIT, "sys_acl_init" },
588 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, "sys_acl_create_entry" },
589 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, "sys_acl_set_tag_type" },
590 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, "sys_acl_set_qualifier" },
591 { SMB_VFS_OP_SYS_ACL_SET_PERMSET, "sys_acl_set_permset" },
592 { SMB_VFS_OP_SYS_ACL_VALID, "sys_acl_valid" },
593 { SMB_VFS_OP_SYS_ACL_SET_FILE, "sys_acl_set_file" },
594 { SMB_VFS_OP_SYS_ACL_SET_FD, "sys_acl_set_fd" },
595 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, "sys_acl_delete_def_file" },
596 { SMB_VFS_OP_SYS_ACL_GET_PERM, "sys_acl_get_perm" },
597 { SMB_VFS_OP_SYS_ACL_FREE_TEXT, "sys_acl_free_text" },
598 { SMB_VFS_OP_SYS_ACL_FREE_ACL, "sys_acl_free_acl" },
599 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, "sys_acl_free_qualifier" },
600 { SMB_VFS_OP_GETXATTR, "getxattr" },
601 { SMB_VFS_OP_LGETXATTR, "lgetxattr" },
602 { SMB_VFS_OP_FGETXATTR, "fgetxattr" },
603 { SMB_VFS_OP_LISTXATTR, "listxattr" },
604 { SMB_VFS_OP_LLISTXATTR, "llistxattr" },
605 { SMB_VFS_OP_FLISTXATTR, "flistxattr" },
606 { SMB_VFS_OP_REMOVEXATTR, "removexattr" },
607 { SMB_VFS_OP_LREMOVEXATTR, "lremovexattr" },
608 { SMB_VFS_OP_FREMOVEXATTR, "fremovexattr" },
609 { SMB_VFS_OP_SETXATTR, "setxattr" },
610 { SMB_VFS_OP_LSETXATTR, "lsetxattr" },
611 { SMB_VFS_OP_FSETXATTR, "fsetxattr" },
612 { SMB_VFS_OP_AIO_READ, "aio_read" },
613 { SMB_VFS_OP_AIO_WRITE, "aio_write" },
614 { SMB_VFS_OP_AIO_RETURN,"aio_return" },
615 { SMB_VFS_OP_AIO_CANCEL,"aio_cancel" },
616 { SMB_VFS_OP_AIO_ERROR, "aio_error" },
617 { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
618 { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
619 { SMB_VFS_OP_LAST, NULL }
622 static int audit_syslog_facility(vfs_handle_struct *handle)
624 static const struct enum_list enum_log_facilities[] = {
625 { LOG_USER, "USER" },
626 { LOG_LOCAL0, "LOCAL0" },
627 { LOG_LOCAL1, "LOCAL1" },
628 { LOG_LOCAL2, "LOCAL2" },
629 { LOG_LOCAL3, "LOCAL3" },
630 { LOG_LOCAL4, "LOCAL4" },
631 { LOG_LOCAL5, "LOCAL5" },
632 { LOG_LOCAL6, "LOCAL6" },
633 { LOG_LOCAL7, "LOCAL7" }
638 facility = lp_parm_enum(SNUM(handle->conn), "full_audit", "facility", enum_log_facilities, LOG_USER);
643 static int audit_syslog_priority(vfs_handle_struct *handle)
645 static const struct enum_list enum_log_priorities[] = {
646 { LOG_EMERG, "EMERG" },
647 { LOG_ALERT, "ALERT" },
648 { LOG_CRIT, "CRIT" },
650 { LOG_WARNING, "WARNING" },
651 { LOG_NOTICE, "NOTICE" },
652 { LOG_INFO, "INFO" },
653 { LOG_DEBUG, "DEBUG" }
658 priority = lp_parm_enum(SNUM(handle->conn), "full_audit", "priority", enum_log_priorities, LOG_NOTICE);
663 static char *audit_prefix(connection_struct *conn)
665 static pstring prefix;
667 pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit",
669 standard_sub_snum(SNUM(conn), prefix, sizeof(prefix)-1);
673 static BOOL log_success(vfs_handle_struct *handle, vfs_op_type op)
675 struct vfs_full_audit_private_data *pd = NULL;
677 SMB_VFS_HANDLE_GET_DATA(handle, pd,
678 struct vfs_full_audit_private_data,
681 if (pd->success_ops == NULL) {
685 return bitmap_query(pd->success_ops, op);
688 static BOOL log_failure(vfs_handle_struct *handle, vfs_op_type op)
690 struct vfs_full_audit_private_data *pd = NULL;
692 SMB_VFS_HANDLE_GET_DATA(handle, pd,
693 struct vfs_full_audit_private_data,
696 if (pd->failure_ops == NULL)
699 return bitmap_query(pd->failure_ops, op);
702 static void init_bitmap(struct bitmap **bm, const char **ops)
704 BOOL log_all = False;
709 *bm = bitmap_allocate(SMB_VFS_OP_LAST);
712 DEBUG(0, ("Could not alloc bitmap -- "
713 "defaulting to logging everything\n"));
717 while (*ops != NULL) {
721 if (strequal(*ops, "all")) {
726 if (strequal(*ops, "none")) {
730 for (i=0; i<SMB_VFS_OP_LAST; i++) {
731 if (vfs_op_names[i].name == NULL) {
732 smb_panic("vfs_full_audit.c: name table not "
733 "in sync with vfs.h\n");
736 if (strequal(*ops, vfs_op_names[i].name)) {
742 DEBUG(0, ("Could not find opname %s, logging all\n",
751 /* The query functions default to True */
757 static const char *audit_opname(vfs_op_type op)
759 if (op >= SMB_VFS_OP_LAST)
760 return "INVALID VFS OP";
761 return vfs_op_names[op].name;
764 static void do_log(vfs_op_type op, BOOL success, vfs_handle_struct *handle,
765 const char *format, ...)
771 if (success && (!log_success(handle, op)))
774 if (!success && (!log_failure(handle, op)))
778 fstrcpy(err_msg, "ok");
780 fstr_sprintf(err_msg, "fail (%s)", strerror(errno));
782 va_start(ap, format);
783 vsnprintf(op_msg, sizeof(op_msg), format, ap);
786 syslog(audit_syslog_priority(handle), "%s|%s|%s|%s\n",
787 audit_prefix(handle->conn), audit_opname(op), err_msg, op_msg);
792 /* Free function for the private data. */
794 static void free_private_data(void **p_data)
796 struct vfs_full_audit_private_data *pd = *(struct vfs_full_audit_private_data **)p_data;
798 if (pd->success_ops) {
799 bitmap_free(pd->success_ops);
801 if (pd->failure_ops) {
802 bitmap_free(pd->failure_ops);
808 /* Implementation of vfs_ops. Pass everything on to the default
809 operation but log event first. */
811 static int smb_full_audit_connect(vfs_handle_struct *handle, connection_struct *conn,
812 const char *svc, const char *user)
815 struct vfs_full_audit_private_data *pd = NULL;
816 const char *none[] = { NULL };
817 const char *all [] = { "all" };
819 pd = SMB_MALLOC_P(struct vfs_full_audit_private_data);
825 openlog("smbd_audit", 0, audit_syslog_facility(handle));
827 init_bitmap(&pd->success_ops,
828 lp_parm_string_list(SNUM(conn), "full_audit", "success",
830 init_bitmap(&pd->failure_ops,
831 lp_parm_string_list(SNUM(conn), "full_audit", "failure",
834 /* Store the private data. */
835 SMB_VFS_HANDLE_SET_DATA(handle, pd, free_private_data,
836 struct vfs_full_audit_private_data, return -1);
838 result = SMB_VFS_NEXT_CONNECT(handle, conn, svc, user);
840 do_log(SMB_VFS_OP_CONNECT, True, handle,
846 static void smb_full_audit_disconnect(vfs_handle_struct *handle,
847 connection_struct *conn)
849 SMB_VFS_NEXT_DISCONNECT(handle, conn);
851 do_log(SMB_VFS_OP_DISCONNECT, True, handle,
852 "%s", lp_servicename(SNUM(conn)));
854 /* The bitmaps will be disconnected when the private
860 static SMB_BIG_UINT smb_full_audit_disk_free(vfs_handle_struct *handle,
861 connection_struct *conn, const char *path,
862 BOOL small_query, SMB_BIG_UINT *bsize,
863 SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
867 result = SMB_VFS_NEXT_DISK_FREE(handle, conn, path, small_query, bsize,
870 /* Don't have a reasonable notion of failure here */
872 do_log(SMB_VFS_OP_DISK_FREE, True, handle, "%s", path);
877 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
878 struct connection_struct *conn,
879 enum SMB_QUOTA_TYPE qtype, unid_t id,
884 result = SMB_VFS_NEXT_GET_QUOTA(handle, conn, qtype, id, qt);
886 do_log(SMB_VFS_OP_GET_QUOTA, (result >= 0), handle, "");
892 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
893 struct connection_struct *conn,
894 enum SMB_QUOTA_TYPE qtype, unid_t id,
899 result = SMB_VFS_NEXT_SET_QUOTA(handle, conn, qtype, id, qt);
901 do_log(SMB_VFS_OP_SET_QUOTA, (result >= 0), handle, "");
906 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
907 struct files_struct *fsp,
908 SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
912 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
914 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
919 static int smb_full_audit_statvfs(struct vfs_handle_struct *handle,
920 struct connection_struct *conn,
922 struct vfs_statvfs_struct *statbuf)
926 result = SMB_VFS_NEXT_STATVFS(handle, conn, path, statbuf);
928 do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
933 static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
934 const char *fname, const char *mask, uint32 attr)
936 SMB_STRUCT_DIR *result;
938 result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);
940 do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
945 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
946 connection_struct *conn, SMB_STRUCT_DIR *dirp)
948 SMB_STRUCT_DIRENT *result;
950 result = SMB_VFS_NEXT_READDIR(handle, conn, dirp);
952 /* This operation has no reasonable error condition
953 * (End of dir is also failure), so always succeed.
955 do_log(SMB_VFS_OP_READDIR, True, handle, "");
960 static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
961 SMB_STRUCT_DIR *dirp, long offset)
963 SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset);
965 do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
969 static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn,
970 SMB_STRUCT_DIR *dirp)
974 result = SMB_VFS_NEXT_TELLDIR(handle, conn, dirp);
976 do_log(SMB_VFS_OP_TELLDIR, True, handle, "");
981 static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn,
982 SMB_STRUCT_DIR *dirp)
984 SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp);
986 do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
990 static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn,
991 const char *path, mode_t mode)
995 result = SMB_VFS_NEXT_MKDIR(handle, conn, path, mode);
997 do_log(SMB_VFS_OP_MKDIR, (result >= 0), handle, "%s", path);
1002 static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn,
1007 result = SMB_VFS_NEXT_RMDIR(handle, conn, path);
1009 do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
1014 static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn,
1015 SMB_STRUCT_DIR *dirp)
1019 result = SMB_VFS_NEXT_CLOSEDIR(handle, conn, dirp);
1021 do_log(SMB_VFS_OP_CLOSEDIR, (result >= 0), handle, "");
1026 static int smb_full_audit_open(vfs_handle_struct *handle, connection_struct *conn,
1027 const char *fname, int flags, mode_t mode)
1031 result = SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
1033 do_log(SMB_VFS_OP_OPEN, (result >= 0), handle, "%s|%s",
1034 ((flags & O_WRONLY) || (flags & O_RDWR))?"w":"r",
1040 static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
1044 result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
1046 do_log(SMB_VFS_OP_CLOSE, (result >= 0), handle, "%s", fsp->fsp_name);
1051 static ssize_t smb_full_audit_read(vfs_handle_struct *handle, files_struct *fsp,
1052 int fd, void *data, size_t n)
1056 result = SMB_VFS_NEXT_READ(handle, fsp, fd, data, n);
1058 do_log(SMB_VFS_OP_READ, (result >= 0), handle, "%s", fsp->fsp_name);
1063 static ssize_t smb_full_audit_pread(vfs_handle_struct *handle, files_struct *fsp,
1064 int fd, void *data, size_t n, SMB_OFF_T offset)
1068 result = SMB_VFS_NEXT_PREAD(handle, fsp, fd, data, n, offset);
1070 do_log(SMB_VFS_OP_PREAD, (result >= 0), handle, "%s", fsp->fsp_name);
1075 static ssize_t smb_full_audit_write(vfs_handle_struct *handle, files_struct *fsp,
1076 int fd, const void *data, size_t n)
1080 result = SMB_VFS_NEXT_WRITE(handle, fsp, fd, data, n);
1082 do_log(SMB_VFS_OP_WRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1087 static ssize_t smb_full_audit_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1088 int fd, const void *data, size_t n,
1093 result = SMB_VFS_NEXT_PWRITE(handle, fsp, fd, data, n, offset);
1095 do_log(SMB_VFS_OP_PWRITE, (result >= 0), handle, "%s", fsp->fsp_name);
1100 static SMB_OFF_T smb_full_audit_lseek(vfs_handle_struct *handle, files_struct *fsp,
1101 int filedes, SMB_OFF_T offset, int whence)
1105 result = SMB_VFS_NEXT_LSEEK(handle, fsp, filedes, offset, whence);
1107 do_log(SMB_VFS_OP_LSEEK, (result != (ssize_t)-1), handle,
1108 "%s", fsp->fsp_name);
1113 static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
1114 files_struct *fsp, int fromfd,
1115 const DATA_BLOB *hdr, SMB_OFF_T offset,
1120 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, fromfd, hdr,
1123 do_log(SMB_VFS_OP_SENDFILE, (result >= 0), handle,
1124 "%s", fsp->fsp_name);
1129 static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn,
1130 const char *oldname, const char *newname)
1134 result = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname);
1136 do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
1141 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
1145 result = SMB_VFS_NEXT_FSYNC(handle, fsp, fd);
1147 do_log(SMB_VFS_OP_FSYNC, (result >= 0), handle, "%s", fsp->fsp_name);
1152 static int smb_full_audit_stat(vfs_handle_struct *handle, connection_struct *conn,
1153 const char *fname, SMB_STRUCT_STAT *sbuf)
1157 result = SMB_VFS_NEXT_STAT(handle, conn, fname, sbuf);
1159 do_log(SMB_VFS_OP_STAT, (result >= 0), handle, "%s", fname);
1164 static int smb_full_audit_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd,
1165 SMB_STRUCT_STAT *sbuf)
1169 result = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf);
1171 do_log(SMB_VFS_OP_FSTAT, (result >= 0), handle, "%s", fsp->fsp_name);
1176 static int smb_full_audit_lstat(vfs_handle_struct *handle, connection_struct *conn,
1177 const char *path, SMB_STRUCT_STAT *sbuf)
1181 result = SMB_VFS_NEXT_LSTAT(handle, conn, path, sbuf);
1183 do_log(SMB_VFS_OP_LSTAT, (result >= 0), handle, "%s", path);
1188 static int smb_full_audit_unlink(vfs_handle_struct *handle, connection_struct *conn,
1193 result = SMB_VFS_NEXT_UNLINK(handle, conn, path);
1195 do_log(SMB_VFS_OP_UNLINK, (result >= 0), handle, "%s", path);
1200 static int smb_full_audit_chmod(vfs_handle_struct *handle, connection_struct *conn,
1201 const char *path, mode_t mode)
1205 result = SMB_VFS_NEXT_CHMOD(handle, conn, path, mode);
1207 do_log(SMB_VFS_OP_CHMOD, (result >= 0), handle, "%s|%o", path, mode);
1212 static int smb_full_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, int fd,
1217 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, fd, mode);
1219 do_log(SMB_VFS_OP_FCHMOD, (result >= 0), handle,
1220 "%s|%o", fsp->fsp_name, mode);
1225 static int smb_full_audit_chown(vfs_handle_struct *handle, connection_struct *conn,
1226 const char *path, uid_t uid, gid_t gid)
1230 result = SMB_VFS_NEXT_CHOWN(handle, conn, path, uid, gid);
1232 do_log(SMB_VFS_OP_CHOWN, (result >= 0), handle, "%s|%ld|%ld",
1233 path, (long int)uid, (long int)gid);
1238 static int smb_full_audit_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd,
1239 uid_t uid, gid_t gid)
1243 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid);
1245 do_log(SMB_VFS_OP_FCHOWN, (result >= 0), handle, "%s|%ld|%ld",
1246 fsp->fsp_name, (long int)uid, (long int)gid);
1251 static int smb_full_audit_chdir(vfs_handle_struct *handle, connection_struct *conn,
1256 result = SMB_VFS_NEXT_CHDIR(handle, conn, path);
1258 do_log(SMB_VFS_OP_CHDIR, (result >= 0), handle, "chdir|%s", path);
1263 static char *smb_full_audit_getwd(vfs_handle_struct *handle, connection_struct *conn,
1268 result = SMB_VFS_NEXT_GETWD(handle, conn, path);
1270 do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
1275 static int smb_full_audit_utime(vfs_handle_struct *handle, connection_struct *conn,
1276 const char *path, struct utimbuf *times)
1280 result = SMB_VFS_NEXT_UTIME(handle, conn, path, times);
1282 do_log(SMB_VFS_OP_UTIME, (result >= 0), handle, "%s", path);
1287 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1288 int fd, SMB_OFF_T len)
1292 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
1294 do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
1295 "%s", fsp->fsp_name);
1300 static BOOL smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
1301 int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
1305 result = SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type);
1307 do_log(SMB_VFS_OP_LOCK, (result >= 0), handle, "%s", fsp->fsp_name);
1312 static int smb_full_audit_symlink(vfs_handle_struct *handle, connection_struct *conn,
1313 const char *oldpath, const char *newpath)
1317 result = SMB_VFS_NEXT_SYMLINK(handle, conn, oldpath, newpath);
1319 do_log(SMB_VFS_OP_SYMLINK, (result >= 0), handle,
1320 "%s|%s", oldpath, newpath);
1325 static int smb_full_audit_readlink(vfs_handle_struct *handle, connection_struct *conn,
1326 const char *path, char *buf, size_t bufsiz)
1330 result = SMB_VFS_NEXT_READLINK(handle, conn, path, buf, bufsiz);
1332 do_log(SMB_VFS_OP_READLINK, (result >= 0), handle, "%s", path);
1337 static int smb_full_audit_link(vfs_handle_struct *handle, connection_struct *conn,
1338 const char *oldpath, const char *newpath)
1342 result = SMB_VFS_NEXT_LINK(handle, conn, oldpath, newpath);
1344 do_log(SMB_VFS_OP_LINK, (result >= 0), handle,
1345 "%s|%s", oldpath, newpath);
1350 static int smb_full_audit_mknod(vfs_handle_struct *handle, connection_struct *conn,
1351 const char *pathname, mode_t mode, SMB_DEV_T dev)
1355 result = SMB_VFS_NEXT_MKNOD(handle, conn, pathname, mode, dev);
1357 do_log(SMB_VFS_OP_MKNOD, (result >= 0), handle, "%s", pathname);
1362 static char *smb_full_audit_realpath(vfs_handle_struct *handle, connection_struct *conn,
1363 const char *path, char *resolved_path)
1367 result = SMB_VFS_NEXT_REALPATH(handle, conn, path, resolved_path);
1369 do_log(SMB_VFS_OP_REALPATH, (result != NULL), handle, "%s", path);
1374 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1375 int fd, uint32 security_info,
1380 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info,
1383 do_log(SMB_VFS_OP_FGET_NT_ACL, (result > 0), handle,
1384 "%s", fsp->fsp_name);
1389 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1390 const char *name, uint32 security_info,
1395 result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
1398 do_log(SMB_VFS_OP_GET_NT_ACL, (result > 0), handle,
1399 "%s", fsp->fsp_name);
1404 static BOOL smb_full_audit_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1405 int fd, uint32 security_info_sent,
1410 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent,
1413 do_log(SMB_VFS_OP_FSET_NT_ACL, result, handle, "%s", fsp->fsp_name);
1418 static BOOL smb_full_audit_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
1419 const char *name, uint32 security_info_sent,
1424 result = SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent,
1427 do_log(SMB_VFS_OP_SET_NT_ACL, result, handle, "%s", fsp->fsp_name);
1432 static int smb_full_audit_chmod_acl(vfs_handle_struct *handle, connection_struct *conn,
1433 const char *path, mode_t mode)
1437 result = SMB_VFS_NEXT_CHMOD_ACL(handle, conn, path, mode);
1439 do_log(SMB_VFS_OP_CHMOD_ACL, (result >= 0), handle,
1440 "%s|%o", path, mode);
1445 static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp,
1446 int fd, mode_t mode)
1450 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, fd, mode);
1452 do_log(SMB_VFS_OP_FCHMOD_ACL, (result >= 0), handle,
1453 "%s|%o", fsp->fsp_name, mode);
1458 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1459 connection_struct *conn,
1460 SMB_ACL_T theacl, int entry_id,
1461 SMB_ACL_ENTRY_T *entry_p)
1465 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, conn, theacl, entry_id,
1468 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY, (result >= 0), handle,
1474 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1475 connection_struct *conn,
1476 SMB_ACL_ENTRY_T entry_d,
1477 SMB_ACL_TAG_T *tag_type_p)
1481 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, conn, entry_d,
1484 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE, (result >= 0), handle,
1490 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1491 connection_struct *conn,
1492 SMB_ACL_ENTRY_T entry_d,
1493 SMB_ACL_PERMSET_T *permset_p)
1497 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, conn, entry_d,
1500 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET, (result >= 0), handle,
1506 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1507 connection_struct *conn,
1508 SMB_ACL_ENTRY_T entry_d)
1512 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, conn, entry_d);
1514 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER, (result != NULL), handle,
1520 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
1521 connection_struct *conn,
1523 SMB_ACL_TYPE_T type)
1527 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, conn, path_p, type);
1529 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
1535 static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1536 files_struct *fsp, int fd)
1540 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, fd);
1542 do_log(SMB_VFS_OP_SYS_ACL_GET_FD, (result != NULL), handle,
1543 "%s", fsp->fsp_name);
1548 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1549 connection_struct *conn,
1550 SMB_ACL_PERMSET_T permset)
1554 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, conn, permset);
1556 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS, (result >= 0), handle,
1562 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1563 connection_struct *conn,
1564 SMB_ACL_PERMSET_T permset,
1565 SMB_ACL_PERM_T perm)
1569 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, conn, permset, perm);
1571 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM, (result >= 0), handle,
1577 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct *handle,
1578 connection_struct *conn, SMB_ACL_T theacl,
1583 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, conn, theacl, plen);
1585 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT, (result != NULL), handle,
1591 static SMB_ACL_T smb_full_audit_sys_acl_init(vfs_handle_struct *handle,
1592 connection_struct *conn,
1597 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, conn, count);
1599 do_log(SMB_VFS_OP_SYS_ACL_INIT, (result != NULL), handle,
1605 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1606 connection_struct *conn, SMB_ACL_T *pacl,
1607 SMB_ACL_ENTRY_T *pentry)
1611 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, conn, pacl, pentry);
1613 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY, (result >= 0), handle,
1619 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1620 connection_struct *conn,
1621 SMB_ACL_ENTRY_T entry,
1622 SMB_ACL_TAG_T tagtype)
1626 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, conn, entry,
1629 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE, (result >= 0), handle,
1635 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1636 connection_struct *conn,
1637 SMB_ACL_ENTRY_T entry,
1642 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, conn, entry, qual);
1644 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER, (result >= 0), handle,
1650 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1651 connection_struct *conn,
1652 SMB_ACL_ENTRY_T entry,
1653 SMB_ACL_PERMSET_T permset)
1657 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, conn, entry, permset);
1659 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET, (result >= 0), handle,
1665 static int smb_full_audit_sys_acl_valid(vfs_handle_struct *handle,
1666 connection_struct *conn,
1671 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, conn, theacl);
1673 do_log(SMB_VFS_OP_SYS_ACL_VALID, (result >= 0), handle,
1679 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct *handle,
1680 connection_struct *conn,
1681 const char *name, SMB_ACL_TYPE_T acltype,
1686 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, conn, name, acltype,
1689 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE, (result >= 0), handle,
1695 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
1696 int fd, SMB_ACL_T theacl)
1700 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, fd, theacl);
1702 do_log(SMB_VFS_OP_SYS_ACL_SET_FD, (result >= 0), handle,
1703 "%s", fsp->fsp_name);
1708 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1709 connection_struct *conn,
1714 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, conn, path);
1716 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
1722 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1723 connection_struct *conn,
1724 SMB_ACL_PERMSET_T permset,
1725 SMB_ACL_PERM_T perm)
1729 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, conn, permset, perm);
1731 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM, (result >= 0), handle,
1737 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct *handle,
1738 connection_struct *conn,
1743 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, conn, text);
1745 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT, (result >= 0), handle,
1751 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1752 connection_struct *conn,
1753 SMB_ACL_T posix_acl)
1757 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, conn, posix_acl);
1759 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL, (result >= 0), handle,
1765 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1766 connection_struct *conn,
1768 SMB_ACL_TAG_T tagtype)
1772 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, conn, qualifier,
1775 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, (result >= 0), handle,
1781 static ssize_t smb_full_audit_getxattr(struct vfs_handle_struct *handle,
1782 struct connection_struct *conn, const char *path,
1783 const char *name, void *value, size_t size)
1787 result = SMB_VFS_NEXT_GETXATTR(handle, conn, path, name, value, size);
1789 do_log(SMB_VFS_OP_GETXATTR, (result >= 0), handle,
1790 "%s|%s", path, name);
1795 static ssize_t smb_full_audit_lgetxattr(struct vfs_handle_struct *handle,
1796 struct connection_struct *conn,
1797 const char *path, const char *name,
1798 void *value, size_t size)
1802 result = SMB_VFS_NEXT_LGETXATTR(handle, conn, path, name, value, size);
1804 do_log(SMB_VFS_OP_LGETXATTR, (result >= 0), handle,
1805 "%s|%s", path, name);
1810 static ssize_t smb_full_audit_fgetxattr(struct vfs_handle_struct *handle,
1811 struct files_struct *fsp, int fd,
1812 const char *name, void *value, size_t size)
1816 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, name, value, size);
1818 do_log(SMB_VFS_OP_FGETXATTR, (result >= 0), handle,
1819 "%s|%s", fsp->fsp_name, name);
1824 static ssize_t smb_full_audit_listxattr(struct vfs_handle_struct *handle,
1825 struct connection_struct *conn,
1826 const char *path, char *list, size_t size)
1830 result = SMB_VFS_NEXT_LISTXATTR(handle, conn, path, list, size);
1832 do_log(SMB_VFS_OP_LISTXATTR, (result >= 0), handle, "%s", path);
1837 static ssize_t smb_full_audit_llistxattr(struct vfs_handle_struct *handle,
1838 struct connection_struct *conn,
1839 const char *path, char *list, size_t size)
1843 result = SMB_VFS_NEXT_LLISTXATTR(handle, conn, path, list, size);
1845 do_log(SMB_VFS_OP_LLISTXATTR, (result >= 0), handle, "%s", path);
1850 static ssize_t smb_full_audit_flistxattr(struct vfs_handle_struct *handle,
1851 struct files_struct *fsp, int fd, char *list,
1856 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, fd, list, size);
1858 do_log(SMB_VFS_OP_FLISTXATTR, (result >= 0), handle,
1859 "%s", fsp->fsp_name);
1864 static int smb_full_audit_removexattr(struct vfs_handle_struct *handle,
1865 struct connection_struct *conn, const char *path,
1870 result = SMB_VFS_NEXT_REMOVEXATTR(handle, conn, path, name);
1872 do_log(SMB_VFS_OP_REMOVEXATTR, (result >= 0), handle,
1873 "%s|%s", path, name);
1878 static int smb_full_audit_lremovexattr(struct vfs_handle_struct *handle,
1879 struct connection_struct *conn, const char *path,
1884 result = SMB_VFS_NEXT_LREMOVEXATTR(handle, conn, path, name);
1886 do_log(SMB_VFS_OP_LREMOVEXATTR, (result >= 0), handle,
1887 "%s|%s", path, name);
1892 static int smb_full_audit_fremovexattr(struct vfs_handle_struct *handle,
1893 struct files_struct *fsp, int fd,
1898 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, name);
1900 do_log(SMB_VFS_OP_FREMOVEXATTR, (result >= 0), handle,
1901 "%s|%s", fsp->fsp_name, name);
1906 static int smb_full_audit_setxattr(struct vfs_handle_struct *handle,
1907 struct connection_struct *conn, const char *path,
1908 const char *name, const void *value, size_t size,
1913 result = SMB_VFS_NEXT_SETXATTR(handle, conn, path, name, value, size,
1916 do_log(SMB_VFS_OP_SETXATTR, (result >= 0), handle,
1917 "%s|%s", path, name);
1922 static int smb_full_audit_lsetxattr(struct vfs_handle_struct *handle,
1923 struct connection_struct *conn, const char *path,
1924 const char *name, const void *value, size_t size,
1929 result = SMB_VFS_NEXT_LSETXATTR(handle, conn, path, name, value, size,
1932 do_log(SMB_VFS_OP_LSETXATTR, (result >= 0), handle,
1933 "%s|%s", path, name);
1938 static int smb_full_audit_fsetxattr(struct vfs_handle_struct *handle,
1939 struct files_struct *fsp, int fd, const char *name,
1940 const void *value, size_t size, int flags)
1944 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, name, value, size,
1947 do_log(SMB_VFS_OP_FSETXATTR, (result >= 0), handle,
1948 "%s|%s", fsp->fsp_name, name);
1953 static int smb_full_audit_aio_read(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1957 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
1958 do_log(SMB_VFS_OP_AIO_READ, (result >= 0), handle,
1959 "%s", fsp->fsp_name);
1964 static int smb_full_audit_aio_write(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1968 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
1969 do_log(SMB_VFS_OP_AIO_WRITE, (result >= 0), handle,
1970 "%s", fsp->fsp_name);
1975 static ssize_t smb_full_audit_aio_return(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
1979 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
1980 do_log(SMB_VFS_OP_AIO_RETURN, (result >= 0), handle,
1981 "%s", fsp->fsp_name);
1986 static int smb_full_audit_aio_cancel(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb)
1990 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, fd, aiocb);
1991 do_log(SMB_VFS_OP_AIO_CANCEL, (result >= 0), handle,
1992 "%s", fsp->fsp_name);
1997 static int smb_full_audit_aio_error(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb)
2001 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2002 do_log(SMB_VFS_OP_AIO_ERROR, (result >= 0), handle,
2003 "%s", fsp->fsp_name);
2008 static int smb_full_audit_aio_fsync(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb)
2012 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2013 do_log(SMB_VFS_OP_AIO_FSYNC, (result >= 0), handle,
2014 "%s", fsp->fsp_name);
2019 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)
2023 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2024 do_log(SMB_VFS_OP_AIO_SUSPEND, (result >= 0), handle,
2025 "%s", fsp->fsp_name);
2031 NTSTATUS vfs_full_audit_init(void)
2033 NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
2034 "full_audit", audit_op_tuples);
2036 if (!NT_STATUS_IS_OK(ret))
2039 vfs_full_audit_debug_level = debug_add_class("full_audit");
2040 if (vfs_full_audit_debug_level == -1) {
2041 vfs_full_audit_debug_level = DBGC_VFS;
2042 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2045 DEBUG(10, ("vfs_full_audit: Debug class number of "
2046 "'full_audit': %d\n", vfs_full_audit_debug_level));