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 userdom_struct current_user_info
;
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
,
78 const char *svc
, const char *user
);
79 static void smb_full_audit_disconnect(vfs_handle_struct
*handle
);
80 static SMB_BIG_UINT
smb_full_audit_disk_free(vfs_handle_struct
*handle
,
82 BOOL small_query
, SMB_BIG_UINT
*bsize
,
83 SMB_BIG_UINT
*dfree
, SMB_BIG_UINT
*dsize
);
84 static int smb_full_audit_get_quota(struct vfs_handle_struct
*handle
,
85 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
87 static int smb_full_audit_set_quota(struct vfs_handle_struct
*handle
,
88 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
90 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
91 struct files_struct
*fsp
,
92 SHADOW_COPY_DATA
*shadow_copy_data
, BOOL labels
);
93 static int smb_full_audit_statvfs(struct vfs_handle_struct
*handle
,
95 struct vfs_statvfs_struct
*statbuf
);
97 static SMB_STRUCT_DIR
*smb_full_audit_opendir(vfs_handle_struct
*handle
,
98 const char *fname
, const char *mask
, uint32 attr
);
99 static SMB_STRUCT_DIRENT
*smb_full_audit_readdir(vfs_handle_struct
*handle
,
100 SMB_STRUCT_DIR
*dirp
);
101 static void smb_full_audit_seekdir(vfs_handle_struct
*handle
,
102 SMB_STRUCT_DIR
*dirp
, long offset
);
103 static long smb_full_audit_telldir(vfs_handle_struct
*handle
,
104 SMB_STRUCT_DIR
*dirp
);
105 static void smb_full_audit_rewinddir(vfs_handle_struct
*handle
,
106 SMB_STRUCT_DIR
*dirp
);
107 static int smb_full_audit_mkdir(vfs_handle_struct
*handle
,
108 const char *path
, mode_t mode
);
109 static int smb_full_audit_rmdir(vfs_handle_struct
*handle
,
111 static int smb_full_audit_closedir(vfs_handle_struct
*handle
,
112 SMB_STRUCT_DIR
*dirp
);
113 static int smb_full_audit_open(vfs_handle_struct
*handle
,
114 const char *fname
, files_struct
*fsp
, int flags
, mode_t mode
);
115 static int smb_full_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
);
116 static ssize_t
smb_full_audit_read(vfs_handle_struct
*handle
, files_struct
*fsp
,
117 int fd
, void *data
, size_t n
);
118 static ssize_t
smb_full_audit_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
119 int fd
, void *data
, size_t n
, SMB_OFF_T offset
);
120 static ssize_t
smb_full_audit_write(vfs_handle_struct
*handle
, files_struct
*fsp
,
121 int fd
, const void *data
, size_t n
);
122 static ssize_t
smb_full_audit_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
123 int fd
, const void *data
, size_t n
,
125 static SMB_OFF_T
smb_full_audit_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
126 int filedes
, SMB_OFF_T offset
, int whence
);
127 static ssize_t
smb_full_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
128 files_struct
*fsp
, int fromfd
,
129 const DATA_BLOB
*hdr
, SMB_OFF_T offset
,
131 static int smb_full_audit_rename(vfs_handle_struct
*handle
,
132 const char *oldname
, const char *newname
);
133 static int smb_full_audit_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
);
134 static int smb_full_audit_stat(vfs_handle_struct
*handle
,
135 const char *fname
, SMB_STRUCT_STAT
*sbuf
);
136 static int smb_full_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
137 SMB_STRUCT_STAT
*sbuf
);
138 static int smb_full_audit_lstat(vfs_handle_struct
*handle
,
139 const char *path
, SMB_STRUCT_STAT
*sbuf
);
140 static int smb_full_audit_unlink(vfs_handle_struct
*handle
,
142 static int smb_full_audit_chmod(vfs_handle_struct
*handle
,
143 const char *path
, mode_t mode
);
144 static int smb_full_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
146 static int smb_full_audit_chown(vfs_handle_struct
*handle
,
147 const char *path
, uid_t uid
, gid_t gid
);
148 static int smb_full_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
149 uid_t uid
, gid_t gid
);
150 static int smb_full_audit_chdir(vfs_handle_struct
*handle
,
152 static char *smb_full_audit_getwd(vfs_handle_struct
*handle
,
154 static int smb_full_audit_utime(vfs_handle_struct
*handle
,
155 const char *path
, struct utimbuf
*times
);
156 static int smb_full_audit_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
157 int fd
, SMB_OFF_T len
);
158 static BOOL
smb_full_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
159 int op
, SMB_OFF_T offset
, SMB_OFF_T count
, int type
);
160 static int smb_full_audit_kernel_flock(struct vfs_handle_struct
*handle
,
161 struct files_struct
*fsp
, int fd
,
163 static BOOL
smb_full_audit_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
164 SMB_OFF_T
*poffset
, SMB_OFF_T
*pcount
, int *ptype
, pid_t
*ppid
);
165 static int smb_full_audit_symlink(vfs_handle_struct
*handle
,
166 const char *oldpath
, const char *newpath
);
167 static int smb_full_audit_readlink(vfs_handle_struct
*handle
,
168 const char *path
, char *buf
, size_t bufsiz
);
169 static int smb_full_audit_link(vfs_handle_struct
*handle
,
170 const char *oldpath
, const char *newpath
);
171 static int smb_full_audit_mknod(vfs_handle_struct
*handle
,
172 const char *pathname
, mode_t mode
, SMB_DEV_T dev
);
173 static char *smb_full_audit_realpath(vfs_handle_struct
*handle
,
174 const char *path
, char *resolved_path
);
175 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
176 int fd
, uint32 security_info
,
178 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
179 const char *name
, uint32 security_info
,
181 static BOOL
smb_full_audit_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
182 int fd
, uint32 security_info_sent
,
184 static BOOL
smb_full_audit_set_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
185 const char *name
, uint32 security_info_sent
,
187 static int smb_full_audit_chmod_acl(vfs_handle_struct
*handle
,
188 const char *path
, mode_t mode
);
189 static int smb_full_audit_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
190 int fd
, mode_t mode
);
191 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct
*handle
,
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 SMB_ACL_ENTRY_T entry_d
,
196 SMB_ACL_TAG_T
*tag_type_p
);
197 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct
*handle
,
198 SMB_ACL_ENTRY_T entry_d
,
199 SMB_ACL_PERMSET_T
*permset_p
);
200 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct
*handle
,
201 SMB_ACL_ENTRY_T entry_d
);
202 static SMB_ACL_T
smb_full_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
204 SMB_ACL_TYPE_T type
);
205 static SMB_ACL_T
smb_full_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
208 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct
*handle
,
209 SMB_ACL_PERMSET_T permset
);
210 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct
*handle
,
211 SMB_ACL_PERMSET_T permset
,
212 SMB_ACL_PERM_T perm
);
213 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct
*handle
,
216 static SMB_ACL_T
smb_full_audit_sys_acl_init(vfs_handle_struct
*handle
,
218 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct
*handle
,
220 SMB_ACL_ENTRY_T
*pentry
);
221 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct
*handle
,
222 SMB_ACL_ENTRY_T entry
,
223 SMB_ACL_TAG_T tagtype
);
224 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct
*handle
,
225 SMB_ACL_ENTRY_T entry
,
227 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct
*handle
,
228 SMB_ACL_ENTRY_T entry
,
229 SMB_ACL_PERMSET_T permset
);
230 static int smb_full_audit_sys_acl_valid(vfs_handle_struct
*handle
,
232 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
233 const char *name
, SMB_ACL_TYPE_T acltype
,
235 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
236 int fd
, SMB_ACL_T theacl
);
237 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
239 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct
*handle
,
240 SMB_ACL_PERMSET_T permset
,
241 SMB_ACL_PERM_T perm
);
242 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct
*handle
,
244 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct
*handle
,
245 SMB_ACL_T posix_acl
);
246 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct
*handle
,
248 SMB_ACL_TAG_T tagtype
);
249 static ssize_t
smb_full_audit_getxattr(struct vfs_handle_struct
*handle
,
251 const char *name
, void *value
, size_t size
);
252 static ssize_t
smb_full_audit_lgetxattr(struct vfs_handle_struct
*handle
,
253 const char *path
, const char *name
,
254 void *value
, size_t size
);
255 static ssize_t
smb_full_audit_fgetxattr(struct vfs_handle_struct
*handle
,
256 struct files_struct
*fsp
, int fd
,
257 const char *name
, void *value
, size_t size
);
258 static ssize_t
smb_full_audit_listxattr(struct vfs_handle_struct
*handle
,
259 const char *path
, char *list
, size_t size
);
260 static ssize_t
smb_full_audit_llistxattr(struct vfs_handle_struct
*handle
,
261 const char *path
, char *list
, size_t size
);
262 static ssize_t
smb_full_audit_flistxattr(struct vfs_handle_struct
*handle
,
263 struct files_struct
*fsp
, int fd
, char *list
,
265 static int smb_full_audit_removexattr(struct vfs_handle_struct
*handle
,
268 static int smb_full_audit_lremovexattr(struct vfs_handle_struct
*handle
,
271 static int smb_full_audit_fremovexattr(struct vfs_handle_struct
*handle
,
272 struct files_struct
*fsp
, int fd
,
274 static int smb_full_audit_setxattr(struct vfs_handle_struct
*handle
,
276 const char *name
, const void *value
, size_t size
,
278 static int smb_full_audit_lsetxattr(struct vfs_handle_struct
*handle
,
280 const char *name
, const void *value
, size_t size
,
282 static int smb_full_audit_fsetxattr(struct vfs_handle_struct
*handle
,
283 struct files_struct
*fsp
, int fd
, const char *name
,
284 const void *value
, size_t size
, int flags
);
286 static int smb_full_audit_aio_read(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
);
287 static int smb_full_audit_aio_write(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
);
288 static ssize_t
smb_full_audit_aio_return(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
);
289 static int smb_full_audit_aio_cancel(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int fd
, SMB_STRUCT_AIOCB
*aiocb
);
290 static int smb_full_audit_aio_error(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
);
291 static int smb_full_audit_aio_fsync(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int op
, SMB_STRUCT_AIOCB
*aiocb
);
292 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
);
296 static vfs_op_tuple audit_op_tuples
[] = {
298 /* Disk operations */
300 {SMB_VFS_OP(smb_full_audit_connect
), SMB_VFS_OP_CONNECT
,
301 SMB_VFS_LAYER_LOGGER
},
302 {SMB_VFS_OP(smb_full_audit_disconnect
), SMB_VFS_OP_DISCONNECT
,
303 SMB_VFS_LAYER_LOGGER
},
304 {SMB_VFS_OP(smb_full_audit_disk_free
), SMB_VFS_OP_DISK_FREE
,
305 SMB_VFS_LAYER_LOGGER
},
306 {SMB_VFS_OP(smb_full_audit_get_quota
), SMB_VFS_OP_GET_QUOTA
,
307 SMB_VFS_LAYER_LOGGER
},
308 {SMB_VFS_OP(smb_full_audit_set_quota
), SMB_VFS_OP_SET_QUOTA
,
309 SMB_VFS_LAYER_LOGGER
},
310 {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data
), SMB_VFS_OP_GET_SHADOW_COPY_DATA
,
311 SMB_VFS_LAYER_LOGGER
},
312 {SMB_VFS_OP(smb_full_audit_statvfs
), SMB_VFS_OP_STATVFS
,
313 SMB_VFS_LAYER_LOGGER
},
315 /* Directory operations */
317 {SMB_VFS_OP(smb_full_audit_opendir
), SMB_VFS_OP_OPENDIR
,
318 SMB_VFS_LAYER_LOGGER
},
319 {SMB_VFS_OP(smb_full_audit_readdir
), SMB_VFS_OP_READDIR
,
320 SMB_VFS_LAYER_LOGGER
},
321 {SMB_VFS_OP(smb_full_audit_seekdir
), SMB_VFS_OP_SEEKDIR
,
322 SMB_VFS_LAYER_LOGGER
},
323 {SMB_VFS_OP(smb_full_audit_telldir
), SMB_VFS_OP_TELLDIR
,
324 SMB_VFS_LAYER_LOGGER
},
325 {SMB_VFS_OP(smb_full_audit_rewinddir
), SMB_VFS_OP_REWINDDIR
,
326 SMB_VFS_LAYER_LOGGER
},
327 {SMB_VFS_OP(smb_full_audit_mkdir
), SMB_VFS_OP_MKDIR
,
328 SMB_VFS_LAYER_LOGGER
},
329 {SMB_VFS_OP(smb_full_audit_rmdir
), SMB_VFS_OP_RMDIR
,
330 SMB_VFS_LAYER_LOGGER
},
331 {SMB_VFS_OP(smb_full_audit_closedir
), SMB_VFS_OP_CLOSEDIR
,
332 SMB_VFS_LAYER_LOGGER
},
334 /* File operations */
336 {SMB_VFS_OP(smb_full_audit_open
), SMB_VFS_OP_OPEN
,
337 SMB_VFS_LAYER_LOGGER
},
338 {SMB_VFS_OP(smb_full_audit_close
), SMB_VFS_OP_CLOSE
,
339 SMB_VFS_LAYER_LOGGER
},
340 {SMB_VFS_OP(smb_full_audit_read
), SMB_VFS_OP_READ
,
341 SMB_VFS_LAYER_LOGGER
},
342 {SMB_VFS_OP(smb_full_audit_pread
), SMB_VFS_OP_PREAD
,
343 SMB_VFS_LAYER_LOGGER
},
344 {SMB_VFS_OP(smb_full_audit_write
), SMB_VFS_OP_WRITE
,
345 SMB_VFS_LAYER_LOGGER
},
346 {SMB_VFS_OP(smb_full_audit_pwrite
), SMB_VFS_OP_PWRITE
,
347 SMB_VFS_LAYER_LOGGER
},
348 {SMB_VFS_OP(smb_full_audit_lseek
), SMB_VFS_OP_LSEEK
,
349 SMB_VFS_LAYER_LOGGER
},
350 {SMB_VFS_OP(smb_full_audit_sendfile
), SMB_VFS_OP_SENDFILE
,
351 SMB_VFS_LAYER_LOGGER
},
352 {SMB_VFS_OP(smb_full_audit_rename
), SMB_VFS_OP_RENAME
,
353 SMB_VFS_LAYER_LOGGER
},
354 {SMB_VFS_OP(smb_full_audit_fsync
), SMB_VFS_OP_FSYNC
,
355 SMB_VFS_LAYER_LOGGER
},
356 {SMB_VFS_OP(smb_full_audit_stat
), SMB_VFS_OP_STAT
,
357 SMB_VFS_LAYER_LOGGER
},
358 {SMB_VFS_OP(smb_full_audit_fstat
), SMB_VFS_OP_FSTAT
,
359 SMB_VFS_LAYER_LOGGER
},
360 {SMB_VFS_OP(smb_full_audit_lstat
), SMB_VFS_OP_LSTAT
,
361 SMB_VFS_LAYER_LOGGER
},
362 {SMB_VFS_OP(smb_full_audit_unlink
), SMB_VFS_OP_UNLINK
,
363 SMB_VFS_LAYER_LOGGER
},
364 {SMB_VFS_OP(smb_full_audit_chmod
), SMB_VFS_OP_CHMOD
,
365 SMB_VFS_LAYER_LOGGER
},
366 {SMB_VFS_OP(smb_full_audit_fchmod
), SMB_VFS_OP_FCHMOD
,
367 SMB_VFS_LAYER_LOGGER
},
368 {SMB_VFS_OP(smb_full_audit_chown
), SMB_VFS_OP_CHOWN
,
369 SMB_VFS_LAYER_LOGGER
},
370 {SMB_VFS_OP(smb_full_audit_fchown
), SMB_VFS_OP_FCHOWN
,
371 SMB_VFS_LAYER_LOGGER
},
372 {SMB_VFS_OP(smb_full_audit_chdir
), SMB_VFS_OP_CHDIR
,
373 SMB_VFS_LAYER_LOGGER
},
374 {SMB_VFS_OP(smb_full_audit_getwd
), SMB_VFS_OP_GETWD
,
375 SMB_VFS_LAYER_LOGGER
},
376 {SMB_VFS_OP(smb_full_audit_utime
), SMB_VFS_OP_UTIME
,
377 SMB_VFS_LAYER_LOGGER
},
378 {SMB_VFS_OP(smb_full_audit_ftruncate
), SMB_VFS_OP_FTRUNCATE
,
379 SMB_VFS_LAYER_LOGGER
},
380 {SMB_VFS_OP(smb_full_audit_lock
), SMB_VFS_OP_LOCK
,
381 SMB_VFS_LAYER_LOGGER
},
382 {SMB_VFS_OP(smb_full_audit_kernel_flock
), SMB_VFS_OP_KERNEL_FLOCK
,
383 SMB_VFS_LAYER_LOGGER
},
384 {SMB_VFS_OP(smb_full_audit_getlock
), SMB_VFS_OP_GETLOCK
,
385 SMB_VFS_LAYER_LOGGER
},
386 {SMB_VFS_OP(smb_full_audit_symlink
), SMB_VFS_OP_SYMLINK
,
387 SMB_VFS_LAYER_LOGGER
},
388 {SMB_VFS_OP(smb_full_audit_readlink
), SMB_VFS_OP_READLINK
,
389 SMB_VFS_LAYER_LOGGER
},
390 {SMB_VFS_OP(smb_full_audit_link
), SMB_VFS_OP_LINK
,
391 SMB_VFS_LAYER_LOGGER
},
392 {SMB_VFS_OP(smb_full_audit_mknod
), SMB_VFS_OP_MKNOD
,
393 SMB_VFS_LAYER_LOGGER
},
394 {SMB_VFS_OP(smb_full_audit_realpath
), SMB_VFS_OP_REALPATH
,
395 SMB_VFS_LAYER_LOGGER
},
397 /* NT ACL operations. */
399 {SMB_VFS_OP(smb_full_audit_fget_nt_acl
), SMB_VFS_OP_FGET_NT_ACL
,
400 SMB_VFS_LAYER_LOGGER
},
401 {SMB_VFS_OP(smb_full_audit_get_nt_acl
), SMB_VFS_OP_GET_NT_ACL
,
402 SMB_VFS_LAYER_LOGGER
},
403 {SMB_VFS_OP(smb_full_audit_fset_nt_acl
), SMB_VFS_OP_FSET_NT_ACL
,
404 SMB_VFS_LAYER_LOGGER
},
405 {SMB_VFS_OP(smb_full_audit_set_nt_acl
), SMB_VFS_OP_SET_NT_ACL
,
406 SMB_VFS_LAYER_LOGGER
},
408 /* POSIX ACL operations. */
410 {SMB_VFS_OP(smb_full_audit_chmod_acl
), SMB_VFS_OP_CHMOD_ACL
,
411 SMB_VFS_LAYER_LOGGER
},
412 {SMB_VFS_OP(smb_full_audit_fchmod_acl
), SMB_VFS_OP_FCHMOD_ACL
,
413 SMB_VFS_LAYER_LOGGER
},
414 {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry
), SMB_VFS_OP_SYS_ACL_GET_ENTRY
,
415 SMB_VFS_LAYER_LOGGER
},
416 {SMB_VFS_OP(smb_full_audit_sys_acl_get_tag_type
), SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
,
417 SMB_VFS_LAYER_LOGGER
},
418 {SMB_VFS_OP(smb_full_audit_sys_acl_get_permset
), SMB_VFS_OP_SYS_ACL_GET_PERMSET
,
419 SMB_VFS_LAYER_LOGGER
},
420 {SMB_VFS_OP(smb_full_audit_sys_acl_get_qualifier
), SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
,
421 SMB_VFS_LAYER_LOGGER
},
422 {SMB_VFS_OP(smb_full_audit_sys_acl_get_file
), SMB_VFS_OP_SYS_ACL_GET_FILE
,
423 SMB_VFS_LAYER_LOGGER
},
424 {SMB_VFS_OP(smb_full_audit_sys_acl_get_fd
), SMB_VFS_OP_SYS_ACL_GET_FD
,
425 SMB_VFS_LAYER_LOGGER
},
426 {SMB_VFS_OP(smb_full_audit_sys_acl_clear_perms
), SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
,
427 SMB_VFS_LAYER_LOGGER
},
428 {SMB_VFS_OP(smb_full_audit_sys_acl_add_perm
), SMB_VFS_OP_SYS_ACL_ADD_PERM
,
429 SMB_VFS_LAYER_LOGGER
},
430 {SMB_VFS_OP(smb_full_audit_sys_acl_to_text
), SMB_VFS_OP_SYS_ACL_TO_TEXT
,
431 SMB_VFS_LAYER_LOGGER
},
432 {SMB_VFS_OP(smb_full_audit_sys_acl_init
), SMB_VFS_OP_SYS_ACL_INIT
,
433 SMB_VFS_LAYER_LOGGER
},
434 {SMB_VFS_OP(smb_full_audit_sys_acl_create_entry
), SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
,
435 SMB_VFS_LAYER_LOGGER
},
436 {SMB_VFS_OP(smb_full_audit_sys_acl_set_tag_type
), SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
,
437 SMB_VFS_LAYER_LOGGER
},
438 {SMB_VFS_OP(smb_full_audit_sys_acl_set_qualifier
), SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
,
439 SMB_VFS_LAYER_LOGGER
},
440 {SMB_VFS_OP(smb_full_audit_sys_acl_set_permset
), SMB_VFS_OP_SYS_ACL_SET_PERMSET
,
441 SMB_VFS_LAYER_LOGGER
},
442 {SMB_VFS_OP(smb_full_audit_sys_acl_valid
), SMB_VFS_OP_SYS_ACL_VALID
,
443 SMB_VFS_LAYER_LOGGER
},
444 {SMB_VFS_OP(smb_full_audit_sys_acl_set_file
), SMB_VFS_OP_SYS_ACL_SET_FILE
,
445 SMB_VFS_LAYER_LOGGER
},
446 {SMB_VFS_OP(smb_full_audit_sys_acl_set_fd
), SMB_VFS_OP_SYS_ACL_SET_FD
,
447 SMB_VFS_LAYER_LOGGER
},
448 {SMB_VFS_OP(smb_full_audit_sys_acl_delete_def_file
), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
,
449 SMB_VFS_LAYER_LOGGER
},
450 {SMB_VFS_OP(smb_full_audit_sys_acl_get_perm
), SMB_VFS_OP_SYS_ACL_GET_PERM
,
451 SMB_VFS_LAYER_LOGGER
},
452 {SMB_VFS_OP(smb_full_audit_sys_acl_free_text
), SMB_VFS_OP_SYS_ACL_FREE_TEXT
,
453 SMB_VFS_LAYER_LOGGER
},
454 {SMB_VFS_OP(smb_full_audit_sys_acl_free_acl
), SMB_VFS_OP_SYS_ACL_FREE_ACL
,
455 SMB_VFS_LAYER_LOGGER
},
456 {SMB_VFS_OP(smb_full_audit_sys_acl_free_qualifier
), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
,
457 SMB_VFS_LAYER_LOGGER
},
461 {SMB_VFS_OP(smb_full_audit_getxattr
), SMB_VFS_OP_GETXATTR
,
462 SMB_VFS_LAYER_LOGGER
},
463 {SMB_VFS_OP(smb_full_audit_lgetxattr
), SMB_VFS_OP_LGETXATTR
,
464 SMB_VFS_LAYER_LOGGER
},
465 {SMB_VFS_OP(smb_full_audit_fgetxattr
), SMB_VFS_OP_FGETXATTR
,
466 SMB_VFS_LAYER_LOGGER
},
467 {SMB_VFS_OP(smb_full_audit_listxattr
), SMB_VFS_OP_LISTXATTR
,
468 SMB_VFS_LAYER_LOGGER
},
469 {SMB_VFS_OP(smb_full_audit_llistxattr
), SMB_VFS_OP_LLISTXATTR
,
470 SMB_VFS_LAYER_LOGGER
},
471 {SMB_VFS_OP(smb_full_audit_flistxattr
), SMB_VFS_OP_FLISTXATTR
,
472 SMB_VFS_LAYER_LOGGER
},
473 {SMB_VFS_OP(smb_full_audit_removexattr
), SMB_VFS_OP_REMOVEXATTR
,
474 SMB_VFS_LAYER_LOGGER
},
475 {SMB_VFS_OP(smb_full_audit_lremovexattr
), SMB_VFS_OP_LREMOVEXATTR
,
476 SMB_VFS_LAYER_LOGGER
},
477 {SMB_VFS_OP(smb_full_audit_fremovexattr
), SMB_VFS_OP_FREMOVEXATTR
,
478 SMB_VFS_LAYER_LOGGER
},
479 {SMB_VFS_OP(smb_full_audit_setxattr
), SMB_VFS_OP_SETXATTR
,
480 SMB_VFS_LAYER_LOGGER
},
481 {SMB_VFS_OP(smb_full_audit_lsetxattr
), SMB_VFS_OP_LSETXATTR
,
482 SMB_VFS_LAYER_LOGGER
},
483 {SMB_VFS_OP(smb_full_audit_fsetxattr
), SMB_VFS_OP_FSETXATTR
,
484 SMB_VFS_LAYER_LOGGER
},
486 {SMB_VFS_OP(smb_full_audit_aio_read
), SMB_VFS_OP_AIO_READ
,
487 SMB_VFS_LAYER_LOGGER
},
488 {SMB_VFS_OP(smb_full_audit_aio_write
), SMB_VFS_OP_AIO_WRITE
,
489 SMB_VFS_LAYER_LOGGER
},
490 {SMB_VFS_OP(smb_full_audit_aio_return
), SMB_VFS_OP_AIO_RETURN
,
491 SMB_VFS_LAYER_LOGGER
},
492 {SMB_VFS_OP(smb_full_audit_aio_cancel
), SMB_VFS_OP_AIO_CANCEL
,
493 SMB_VFS_LAYER_LOGGER
},
494 {SMB_VFS_OP(smb_full_audit_aio_error
), SMB_VFS_OP_AIO_ERROR
,
495 SMB_VFS_LAYER_LOGGER
},
496 {SMB_VFS_OP(smb_full_audit_aio_fsync
), SMB_VFS_OP_AIO_FSYNC
,
497 SMB_VFS_LAYER_LOGGER
},
498 {SMB_VFS_OP(smb_full_audit_aio_suspend
),SMB_VFS_OP_AIO_SUSPEND
,
499 SMB_VFS_LAYER_LOGGER
},
501 /* Finish VFS operations definition */
503 {SMB_VFS_OP(NULL
), SMB_VFS_OP_NOOP
,
507 /* The following array *must* be in the same order as defined in vfs.h */
513 { SMB_VFS_OP_CONNECT
, "connect" },
514 { SMB_VFS_OP_DISCONNECT
, "disconnect" },
515 { SMB_VFS_OP_DISK_FREE
, "disk_free" },
516 { SMB_VFS_OP_GET_QUOTA
, "get_quota" },
517 { SMB_VFS_OP_SET_QUOTA
, "set_quota" },
518 { SMB_VFS_OP_GET_SHADOW_COPY_DATA
, "get_shadow_copy_data" },
519 { SMB_VFS_OP_STATVFS
, "statvfs" },
520 { SMB_VFS_OP_OPENDIR
, "opendir" },
521 { SMB_VFS_OP_READDIR
, "readdir" },
522 { SMB_VFS_OP_SEEKDIR
, "seekdir" },
523 { SMB_VFS_OP_TELLDIR
, "telldir" },
524 { SMB_VFS_OP_REWINDDIR
, "rewinddir" },
525 { SMB_VFS_OP_MKDIR
, "mkdir" },
526 { SMB_VFS_OP_RMDIR
, "rmdir" },
527 { SMB_VFS_OP_CLOSEDIR
, "closedir" },
528 { SMB_VFS_OP_OPEN
, "open" },
529 { SMB_VFS_OP_CLOSE
, "close" },
530 { SMB_VFS_OP_READ
, "read" },
531 { SMB_VFS_OP_PREAD
, "pread" },
532 { SMB_VFS_OP_WRITE
, "write" },
533 { SMB_VFS_OP_PWRITE
, "pwrite" },
534 { SMB_VFS_OP_LSEEK
, "lseek" },
535 { SMB_VFS_OP_SENDFILE
, "sendfile" },
536 { SMB_VFS_OP_RENAME
, "rename" },
537 { SMB_VFS_OP_FSYNC
, "fsync" },
538 { SMB_VFS_OP_STAT
, "stat" },
539 { SMB_VFS_OP_FSTAT
, "fstat" },
540 { SMB_VFS_OP_LSTAT
, "lstat" },
541 { SMB_VFS_OP_UNLINK
, "unlink" },
542 { SMB_VFS_OP_CHMOD
, "chmod" },
543 { SMB_VFS_OP_FCHMOD
, "fchmod" },
544 { SMB_VFS_OP_CHOWN
, "chown" },
545 { SMB_VFS_OP_FCHOWN
, "fchown" },
546 { SMB_VFS_OP_CHDIR
, "chdir" },
547 { SMB_VFS_OP_GETWD
, "getwd" },
548 { SMB_VFS_OP_UTIME
, "utime" },
549 { SMB_VFS_OP_FTRUNCATE
, "ftruncate" },
550 { SMB_VFS_OP_LOCK
, "lock" },
551 { SMB_VFS_OP_KERNEL_FLOCK
, "kernel_flock" },
552 { SMB_VFS_OP_GETLOCK
, "getlock" },
553 { SMB_VFS_OP_SYMLINK
, "symlink" },
554 { SMB_VFS_OP_READLINK
, "readlink" },
555 { SMB_VFS_OP_LINK
, "link" },
556 { SMB_VFS_OP_MKNOD
, "mknod" },
557 { SMB_VFS_OP_REALPATH
, "realpath" },
558 { SMB_VFS_OP_FGET_NT_ACL
, "fget_nt_acl" },
559 { SMB_VFS_OP_GET_NT_ACL
, "get_nt_acl" },
560 { SMB_VFS_OP_FSET_NT_ACL
, "fset_nt_acl" },
561 { SMB_VFS_OP_SET_NT_ACL
, "set_nt_acl" },
562 { SMB_VFS_OP_CHMOD_ACL
, "chmod_acl" },
563 { SMB_VFS_OP_FCHMOD_ACL
, "fchmod_acl" },
564 { SMB_VFS_OP_SYS_ACL_GET_ENTRY
, "sys_acl_get_entry" },
565 { SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
, "sys_acl_get_tag_type" },
566 { SMB_VFS_OP_SYS_ACL_GET_PERMSET
, "sys_acl_get_permset" },
567 { SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
, "sys_acl_get_qualifier" },
568 { SMB_VFS_OP_SYS_ACL_GET_FILE
, "sys_acl_get_file" },
569 { SMB_VFS_OP_SYS_ACL_GET_FD
, "sys_acl_get_fd" },
570 { SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
, "sys_acl_clear_perms" },
571 { SMB_VFS_OP_SYS_ACL_ADD_PERM
, "sys_acl_add_perm" },
572 { SMB_VFS_OP_SYS_ACL_TO_TEXT
, "sys_acl_to_text" },
573 { SMB_VFS_OP_SYS_ACL_INIT
, "sys_acl_init" },
574 { SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
, "sys_acl_create_entry" },
575 { SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
, "sys_acl_set_tag_type" },
576 { SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
, "sys_acl_set_qualifier" },
577 { SMB_VFS_OP_SYS_ACL_SET_PERMSET
, "sys_acl_set_permset" },
578 { SMB_VFS_OP_SYS_ACL_VALID
, "sys_acl_valid" },
579 { SMB_VFS_OP_SYS_ACL_SET_FILE
, "sys_acl_set_file" },
580 { SMB_VFS_OP_SYS_ACL_SET_FD
, "sys_acl_set_fd" },
581 { SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, "sys_acl_delete_def_file" },
582 { SMB_VFS_OP_SYS_ACL_GET_PERM
, "sys_acl_get_perm" },
583 { SMB_VFS_OP_SYS_ACL_FREE_TEXT
, "sys_acl_free_text" },
584 { SMB_VFS_OP_SYS_ACL_FREE_ACL
, "sys_acl_free_acl" },
585 { SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
, "sys_acl_free_qualifier" },
586 { SMB_VFS_OP_GETXATTR
, "getxattr" },
587 { SMB_VFS_OP_LGETXATTR
, "lgetxattr" },
588 { SMB_VFS_OP_FGETXATTR
, "fgetxattr" },
589 { SMB_VFS_OP_LISTXATTR
, "listxattr" },
590 { SMB_VFS_OP_LLISTXATTR
, "llistxattr" },
591 { SMB_VFS_OP_FLISTXATTR
, "flistxattr" },
592 { SMB_VFS_OP_REMOVEXATTR
, "removexattr" },
593 { SMB_VFS_OP_LREMOVEXATTR
, "lremovexattr" },
594 { SMB_VFS_OP_FREMOVEXATTR
, "fremovexattr" },
595 { SMB_VFS_OP_SETXATTR
, "setxattr" },
596 { SMB_VFS_OP_LSETXATTR
, "lsetxattr" },
597 { SMB_VFS_OP_FSETXATTR
, "fsetxattr" },
598 { SMB_VFS_OP_AIO_READ
, "aio_read" },
599 { SMB_VFS_OP_AIO_WRITE
, "aio_write" },
600 { SMB_VFS_OP_AIO_RETURN
,"aio_return" },
601 { SMB_VFS_OP_AIO_CANCEL
,"aio_cancel" },
602 { SMB_VFS_OP_AIO_ERROR
, "aio_error" },
603 { SMB_VFS_OP_AIO_FSYNC
, "aio_fsync" },
604 { SMB_VFS_OP_AIO_SUSPEND
,"aio_suspend" },
605 { SMB_VFS_OP_LAST
, NULL
}
608 static int audit_syslog_facility(vfs_handle_struct
*handle
)
610 static const struct enum_list enum_log_facilities
[] = {
611 { LOG_USER
, "USER" },
612 { LOG_LOCAL0
, "LOCAL0" },
613 { LOG_LOCAL1
, "LOCAL1" },
614 { LOG_LOCAL2
, "LOCAL2" },
615 { LOG_LOCAL3
, "LOCAL3" },
616 { LOG_LOCAL4
, "LOCAL4" },
617 { LOG_LOCAL5
, "LOCAL5" },
618 { LOG_LOCAL6
, "LOCAL6" },
619 { LOG_LOCAL7
, "LOCAL7" }
624 facility
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "facility", enum_log_facilities
, LOG_USER
);
629 static int audit_syslog_priority(vfs_handle_struct
*handle
)
631 static const struct enum_list enum_log_priorities
[] = {
632 { LOG_EMERG
, "EMERG" },
633 { LOG_ALERT
, "ALERT" },
634 { LOG_CRIT
, "CRIT" },
636 { LOG_WARNING
, "WARNING" },
637 { LOG_NOTICE
, "NOTICE" },
638 { LOG_INFO
, "INFO" },
639 { LOG_DEBUG
, "DEBUG" }
644 priority
= lp_parm_enum(SNUM(handle
->conn
), "full_audit", "priority", enum_log_priorities
, LOG_NOTICE
);
649 static char *audit_prefix(connection_struct
*conn
)
651 static pstring prefix
;
653 pstrcpy(prefix
, lp_parm_const_string(SNUM(conn
), "full_audit",
655 standard_sub_advanced(lp_servicename(SNUM(conn
)), conn
->user
,
656 conn
->connectpath
, conn
->gid
,
657 get_current_username(),
658 current_user_info
.domain
,
659 prefix
, sizeof(prefix
));
663 static BOOL
log_success(vfs_handle_struct
*handle
, vfs_op_type op
)
665 struct vfs_full_audit_private_data
*pd
= NULL
;
667 SMB_VFS_HANDLE_GET_DATA(handle
, pd
,
668 struct vfs_full_audit_private_data
,
671 if (pd
->success_ops
== NULL
) {
675 return bitmap_query(pd
->success_ops
, op
);
678 static BOOL
log_failure(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
->failure_ops
== NULL
)
689 return bitmap_query(pd
->failure_ops
, op
);
692 static void init_bitmap(struct bitmap
**bm
, const char **ops
)
694 BOOL log_all
= False
;
699 *bm
= bitmap_allocate(SMB_VFS_OP_LAST
);
702 DEBUG(0, ("Could not alloc bitmap -- "
703 "defaulting to logging everything\n"));
707 while (*ops
!= NULL
) {
711 if (strequal(*ops
, "all")) {
716 if (strequal(*ops
, "none")) {
720 for (i
=0; i
<SMB_VFS_OP_LAST
; i
++) {
721 if (vfs_op_names
[i
].name
== NULL
) {
722 smb_panic("vfs_full_audit.c: name table not "
723 "in sync with vfs.h\n");
726 if (strequal(*ops
, vfs_op_names
[i
].name
)) {
732 DEBUG(0, ("Could not find opname %s, logging all\n",
741 /* The query functions default to True */
747 static const char *audit_opname(vfs_op_type op
)
749 if (op
>= SMB_VFS_OP_LAST
)
750 return "INVALID VFS OP";
751 return vfs_op_names
[op
].name
;
754 static void do_log(vfs_op_type op
, BOOL success
, vfs_handle_struct
*handle
,
755 const char *format
, ...)
761 if (success
&& (!log_success(handle
, op
)))
764 if (!success
&& (!log_failure(handle
, op
)))
768 fstrcpy(err_msg
, "ok");
770 fstr_sprintf(err_msg
, "fail (%s)", strerror(errno
));
772 va_start(ap
, format
);
773 vsnprintf(op_msg
, sizeof(op_msg
), format
, ap
);
776 syslog(audit_syslog_priority(handle
), "%s|%s|%s|%s\n",
777 audit_prefix(handle
->conn
), audit_opname(op
), err_msg
, op_msg
);
782 /* Free function for the private data. */
784 static void free_private_data(void **p_data
)
786 struct vfs_full_audit_private_data
*pd
= *(struct vfs_full_audit_private_data
**)p_data
;
788 if (pd
->success_ops
) {
789 bitmap_free(pd
->success_ops
);
791 if (pd
->failure_ops
) {
792 bitmap_free(pd
->failure_ops
);
798 /* Implementation of vfs_ops. Pass everything on to the default
799 operation but log event first. */
801 static int smb_full_audit_connect(vfs_handle_struct
*handle
,
802 const char *svc
, const char *user
)
805 struct vfs_full_audit_private_data
*pd
= NULL
;
806 const char *none
[] = { NULL
};
807 const char *all
[] = { "all" };
813 pd
= SMB_MALLOC_P(struct vfs_full_audit_private_data
);
819 openlog("smbd_audit", 0, audit_syslog_facility(handle
));
821 init_bitmap(&pd
->success_ops
,
822 lp_parm_string_list(SNUM(handle
->conn
), "full_audit", "success",
824 init_bitmap(&pd
->failure_ops
,
825 lp_parm_string_list(SNUM(handle
->conn
), "full_audit", "failure",
828 /* Store the private data. */
829 SMB_VFS_HANDLE_SET_DATA(handle
, pd
, free_private_data
,
830 struct vfs_full_audit_private_data
, return -1);
832 result
= SMB_VFS_NEXT_CONNECT(handle
, svc
, user
);
834 do_log(SMB_VFS_OP_CONNECT
, True
, handle
,
840 static void smb_full_audit_disconnect(vfs_handle_struct
*handle
)
842 SMB_VFS_NEXT_DISCONNECT(handle
);
844 do_log(SMB_VFS_OP_DISCONNECT
, True
, handle
,
845 "%s", lp_servicename(SNUM(handle
->conn
)));
847 /* The bitmaps will be disconnected when the private
853 static SMB_BIG_UINT
smb_full_audit_disk_free(vfs_handle_struct
*handle
,
855 BOOL small_query
, SMB_BIG_UINT
*bsize
,
856 SMB_BIG_UINT
*dfree
, SMB_BIG_UINT
*dsize
)
860 result
= SMB_VFS_NEXT_DISK_FREE(handle
, path
, small_query
, bsize
,
863 /* Don't have a reasonable notion of failure here */
865 do_log(SMB_VFS_OP_DISK_FREE
, True
, handle
, "%s", path
);
870 static int smb_full_audit_get_quota(struct vfs_handle_struct
*handle
,
871 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
876 result
= SMB_VFS_NEXT_GET_QUOTA(handle
, qtype
, id
, qt
);
878 do_log(SMB_VFS_OP_GET_QUOTA
, (result
>= 0), handle
, "");
884 static int smb_full_audit_set_quota(struct vfs_handle_struct
*handle
,
885 enum SMB_QUOTA_TYPE qtype
, unid_t id
,
890 result
= SMB_VFS_NEXT_SET_QUOTA(handle
, qtype
, id
, qt
);
892 do_log(SMB_VFS_OP_SET_QUOTA
, (result
>= 0), handle
, "");
897 static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct
*handle
,
898 struct files_struct
*fsp
,
899 SHADOW_COPY_DATA
*shadow_copy_data
, BOOL labels
)
903 result
= SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle
, fsp
, shadow_copy_data
, labels
);
905 do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA
, (result
>= 0), handle
, "");
910 static int smb_full_audit_statvfs(struct vfs_handle_struct
*handle
,
912 struct vfs_statvfs_struct
*statbuf
)
916 result
= SMB_VFS_NEXT_STATVFS(handle
, path
, statbuf
);
918 do_log(SMB_VFS_OP_STATVFS
, (result
>= 0), handle
, "");
923 static SMB_STRUCT_DIR
*smb_full_audit_opendir(vfs_handle_struct
*handle
,
924 const char *fname
, const char *mask
, uint32 attr
)
926 SMB_STRUCT_DIR
*result
;
928 result
= SMB_VFS_NEXT_OPENDIR(handle
, fname
, mask
, attr
);
930 do_log(SMB_VFS_OP_OPENDIR
, (result
!= NULL
), handle
, "%s", fname
);
935 static SMB_STRUCT_DIRENT
*smb_full_audit_readdir(vfs_handle_struct
*handle
,
936 SMB_STRUCT_DIR
*dirp
)
938 SMB_STRUCT_DIRENT
*result
;
940 result
= SMB_VFS_NEXT_READDIR(handle
, dirp
);
942 /* This operation has no reasonable error condition
943 * (End of dir is also failure), so always succeed.
945 do_log(SMB_VFS_OP_READDIR
, True
, handle
, "");
950 static void smb_full_audit_seekdir(vfs_handle_struct
*handle
,
951 SMB_STRUCT_DIR
*dirp
, long offset
)
953 SMB_VFS_NEXT_SEEKDIR(handle
, dirp
, offset
);
955 do_log(SMB_VFS_OP_SEEKDIR
, True
, handle
, "");
959 static long smb_full_audit_telldir(vfs_handle_struct
*handle
,
960 SMB_STRUCT_DIR
*dirp
)
964 result
= SMB_VFS_NEXT_TELLDIR(handle
, dirp
);
966 do_log(SMB_VFS_OP_TELLDIR
, True
, handle
, "");
971 static void smb_full_audit_rewinddir(vfs_handle_struct
*handle
,
972 SMB_STRUCT_DIR
*dirp
)
974 SMB_VFS_NEXT_REWINDDIR(handle
, dirp
);
976 do_log(SMB_VFS_OP_REWINDDIR
, True
, handle
, "");
980 static int smb_full_audit_mkdir(vfs_handle_struct
*handle
,
981 const char *path
, mode_t mode
)
985 result
= SMB_VFS_NEXT_MKDIR(handle
, path
, mode
);
987 do_log(SMB_VFS_OP_MKDIR
, (result
>= 0), handle
, "%s", path
);
992 static int smb_full_audit_rmdir(vfs_handle_struct
*handle
,
997 result
= SMB_VFS_NEXT_RMDIR(handle
, path
);
999 do_log(SMB_VFS_OP_RMDIR
, (result
>= 0), handle
, "%s", path
);
1004 static int smb_full_audit_closedir(vfs_handle_struct
*handle
,
1005 SMB_STRUCT_DIR
*dirp
)
1009 result
= SMB_VFS_NEXT_CLOSEDIR(handle
, dirp
);
1011 do_log(SMB_VFS_OP_CLOSEDIR
, (result
>= 0), handle
, "");
1016 static int smb_full_audit_open(vfs_handle_struct
*handle
,
1017 const char *fname
, files_struct
*fsp
, int flags
, mode_t mode
)
1021 result
= SMB_VFS_NEXT_OPEN(handle
, fname
, fsp
, flags
, mode
);
1023 do_log(SMB_VFS_OP_OPEN
, (result
>= 0), handle
, "%s|%s",
1024 ((flags
& O_WRONLY
) || (flags
& O_RDWR
))?"w":"r",
1030 static int smb_full_audit_close(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
)
1034 result
= SMB_VFS_NEXT_CLOSE(handle
, fsp
, fd
);
1036 do_log(SMB_VFS_OP_CLOSE
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1041 static ssize_t
smb_full_audit_read(vfs_handle_struct
*handle
, files_struct
*fsp
,
1042 int fd
, void *data
, size_t n
)
1046 result
= SMB_VFS_NEXT_READ(handle
, fsp
, fd
, data
, n
);
1048 do_log(SMB_VFS_OP_READ
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1053 static ssize_t
smb_full_audit_pread(vfs_handle_struct
*handle
, files_struct
*fsp
,
1054 int fd
, void *data
, size_t n
, SMB_OFF_T offset
)
1058 result
= SMB_VFS_NEXT_PREAD(handle
, fsp
, fd
, data
, n
, offset
);
1060 do_log(SMB_VFS_OP_PREAD
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1065 static ssize_t
smb_full_audit_write(vfs_handle_struct
*handle
, files_struct
*fsp
,
1066 int fd
, const void *data
, size_t n
)
1070 result
= SMB_VFS_NEXT_WRITE(handle
, fsp
, fd
, data
, n
);
1072 do_log(SMB_VFS_OP_WRITE
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1077 static ssize_t
smb_full_audit_pwrite(vfs_handle_struct
*handle
, files_struct
*fsp
,
1078 int fd
, const void *data
, size_t n
,
1083 result
= SMB_VFS_NEXT_PWRITE(handle
, fsp
, fd
, data
, n
, offset
);
1085 do_log(SMB_VFS_OP_PWRITE
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1090 static SMB_OFF_T
smb_full_audit_lseek(vfs_handle_struct
*handle
, files_struct
*fsp
,
1091 int filedes
, SMB_OFF_T offset
, int whence
)
1095 result
= SMB_VFS_NEXT_LSEEK(handle
, fsp
, filedes
, offset
, whence
);
1097 do_log(SMB_VFS_OP_LSEEK
, (result
!= (ssize_t
)-1), handle
,
1098 "%s", fsp
->fsp_name
);
1103 static ssize_t
smb_full_audit_sendfile(vfs_handle_struct
*handle
, int tofd
,
1104 files_struct
*fsp
, int fromfd
,
1105 const DATA_BLOB
*hdr
, SMB_OFF_T offset
,
1110 result
= SMB_VFS_NEXT_SENDFILE(handle
, tofd
, fsp
, fromfd
, hdr
,
1113 do_log(SMB_VFS_OP_SENDFILE
, (result
>= 0), handle
,
1114 "%s", fsp
->fsp_name
);
1119 static int smb_full_audit_rename(vfs_handle_struct
*handle
,
1120 const char *oldname
, const char *newname
)
1124 result
= SMB_VFS_NEXT_RENAME(handle
, oldname
, newname
);
1126 do_log(SMB_VFS_OP_RENAME
, (result
>= 0), handle
, "%s|%s", oldname
, newname
);
1131 static int smb_full_audit_fsync(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
)
1135 result
= SMB_VFS_NEXT_FSYNC(handle
, fsp
, fd
);
1137 do_log(SMB_VFS_OP_FSYNC
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1142 static int smb_full_audit_stat(vfs_handle_struct
*handle
,
1143 const char *fname
, SMB_STRUCT_STAT
*sbuf
)
1147 result
= SMB_VFS_NEXT_STAT(handle
, fname
, sbuf
);
1149 do_log(SMB_VFS_OP_STAT
, (result
>= 0), handle
, "%s", fname
);
1154 static int smb_full_audit_fstat(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
1155 SMB_STRUCT_STAT
*sbuf
)
1159 result
= SMB_VFS_NEXT_FSTAT(handle
, fsp
, fd
, sbuf
);
1161 do_log(SMB_VFS_OP_FSTAT
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1166 static int smb_full_audit_lstat(vfs_handle_struct
*handle
,
1167 const char *path
, SMB_STRUCT_STAT
*sbuf
)
1171 result
= SMB_VFS_NEXT_LSTAT(handle
, path
, sbuf
);
1173 do_log(SMB_VFS_OP_LSTAT
, (result
>= 0), handle
, "%s", path
);
1178 static int smb_full_audit_unlink(vfs_handle_struct
*handle
,
1183 result
= SMB_VFS_NEXT_UNLINK(handle
, path
);
1185 do_log(SMB_VFS_OP_UNLINK
, (result
>= 0), handle
, "%s", path
);
1190 static int smb_full_audit_chmod(vfs_handle_struct
*handle
,
1191 const char *path
, mode_t mode
)
1195 result
= SMB_VFS_NEXT_CHMOD(handle
, path
, mode
);
1197 do_log(SMB_VFS_OP_CHMOD
, (result
>= 0), handle
, "%s|%o", path
, mode
);
1202 static int smb_full_audit_fchmod(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
1207 result
= SMB_VFS_NEXT_FCHMOD(handle
, fsp
, fd
, mode
);
1209 do_log(SMB_VFS_OP_FCHMOD
, (result
>= 0), handle
,
1210 "%s|%o", fsp
->fsp_name
, mode
);
1215 static int smb_full_audit_chown(vfs_handle_struct
*handle
,
1216 const char *path
, uid_t uid
, gid_t gid
)
1220 result
= SMB_VFS_NEXT_CHOWN(handle
, path
, uid
, gid
);
1222 do_log(SMB_VFS_OP_CHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1223 path
, (long int)uid
, (long int)gid
);
1228 static int smb_full_audit_fchown(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
1229 uid_t uid
, gid_t gid
)
1233 result
= SMB_VFS_NEXT_FCHOWN(handle
, fsp
, fd
, uid
, gid
);
1235 do_log(SMB_VFS_OP_FCHOWN
, (result
>= 0), handle
, "%s|%ld|%ld",
1236 fsp
->fsp_name
, (long int)uid
, (long int)gid
);
1241 static int smb_full_audit_chdir(vfs_handle_struct
*handle
,
1246 result
= SMB_VFS_NEXT_CHDIR(handle
, path
);
1248 do_log(SMB_VFS_OP_CHDIR
, (result
>= 0), handle
, "chdir|%s", path
);
1253 static char *smb_full_audit_getwd(vfs_handle_struct
*handle
,
1258 result
= SMB_VFS_NEXT_GETWD(handle
, path
);
1260 do_log(SMB_VFS_OP_GETWD
, (result
!= NULL
), handle
, "%s", path
);
1265 static int smb_full_audit_utime(vfs_handle_struct
*handle
,
1266 const char *path
, struct utimbuf
*times
)
1270 result
= SMB_VFS_NEXT_UTIME(handle
, path
, times
);
1272 do_log(SMB_VFS_OP_UTIME
, (result
>= 0), handle
, "%s", path
);
1277 static int smb_full_audit_ftruncate(vfs_handle_struct
*handle
, files_struct
*fsp
,
1278 int fd
, SMB_OFF_T len
)
1282 result
= SMB_VFS_NEXT_FTRUNCATE(handle
, fsp
, fd
, len
);
1284 do_log(SMB_VFS_OP_FTRUNCATE
, (result
>= 0), handle
,
1285 "%s", fsp
->fsp_name
);
1290 static BOOL
smb_full_audit_lock(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
1291 int op
, SMB_OFF_T offset
, SMB_OFF_T count
, int type
)
1295 result
= SMB_VFS_NEXT_LOCK(handle
, fsp
, fd
, op
, offset
, count
, type
);
1297 do_log(SMB_VFS_OP_LOCK
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1302 static int smb_full_audit_kernel_flock(struct vfs_handle_struct
*handle
,
1303 struct files_struct
*fsp
, int fd
,
1308 result
= SMB_VFS_NEXT_KERNEL_FLOCK(handle
, fsp
, fd
, share_mode
);
1310 do_log(SMB_VFS_OP_KERNEL_FLOCK
, (result
>= 0), handle
, "%s",
1316 static BOOL
smb_full_audit_getlock(vfs_handle_struct
*handle
, files_struct
*fsp
, int fd
,
1317 SMB_OFF_T
*poffset
, SMB_OFF_T
*pcount
, int *ptype
, pid_t
*ppid
)
1321 result
= SMB_VFS_NEXT_GETLOCK(handle
, fsp
, fd
, poffset
, pcount
, ptype
, ppid
);
1323 do_log(SMB_VFS_OP_GETLOCK
, (result
>= 0), handle
, "%s", fsp
->fsp_name
);
1328 static int smb_full_audit_symlink(vfs_handle_struct
*handle
,
1329 const char *oldpath
, const char *newpath
)
1333 result
= SMB_VFS_NEXT_SYMLINK(handle
, oldpath
, newpath
);
1335 do_log(SMB_VFS_OP_SYMLINK
, (result
>= 0), handle
,
1336 "%s|%s", oldpath
, newpath
);
1341 static int smb_full_audit_readlink(vfs_handle_struct
*handle
,
1342 const char *path
, char *buf
, size_t bufsiz
)
1346 result
= SMB_VFS_NEXT_READLINK(handle
, path
, buf
, bufsiz
);
1348 do_log(SMB_VFS_OP_READLINK
, (result
>= 0), handle
, "%s", path
);
1353 static int smb_full_audit_link(vfs_handle_struct
*handle
,
1354 const char *oldpath
, const char *newpath
)
1358 result
= SMB_VFS_NEXT_LINK(handle
, oldpath
, newpath
);
1360 do_log(SMB_VFS_OP_LINK
, (result
>= 0), handle
,
1361 "%s|%s", oldpath
, newpath
);
1366 static int smb_full_audit_mknod(vfs_handle_struct
*handle
,
1367 const char *pathname
, mode_t mode
, SMB_DEV_T dev
)
1371 result
= SMB_VFS_NEXT_MKNOD(handle
, pathname
, mode
, dev
);
1373 do_log(SMB_VFS_OP_MKNOD
, (result
>= 0), handle
, "%s", pathname
);
1378 static char *smb_full_audit_realpath(vfs_handle_struct
*handle
,
1379 const char *path
, char *resolved_path
)
1383 result
= SMB_VFS_NEXT_REALPATH(handle
, path
, resolved_path
);
1385 do_log(SMB_VFS_OP_REALPATH
, (result
!= NULL
), handle
, "%s", path
);
1390 static size_t smb_full_audit_fget_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1391 int fd
, uint32 security_info
,
1396 result
= SMB_VFS_NEXT_FGET_NT_ACL(handle
, fsp
, fd
, security_info
,
1399 do_log(SMB_VFS_OP_FGET_NT_ACL
, (result
> 0), handle
,
1400 "%s", fsp
->fsp_name
);
1405 static size_t smb_full_audit_get_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1406 const char *name
, uint32 security_info
,
1411 result
= SMB_VFS_NEXT_GET_NT_ACL(handle
, fsp
, name
, security_info
,
1414 do_log(SMB_VFS_OP_GET_NT_ACL
, (result
> 0), handle
,
1415 "%s", fsp
->fsp_name
);
1420 static BOOL
smb_full_audit_fset_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1421 int fd
, uint32 security_info_sent
,
1426 result
= SMB_VFS_NEXT_FSET_NT_ACL(handle
, fsp
, fd
, security_info_sent
,
1429 do_log(SMB_VFS_OP_FSET_NT_ACL
, result
, handle
, "%s", fsp
->fsp_name
);
1434 static BOOL
smb_full_audit_set_nt_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1435 const char *name
, uint32 security_info_sent
,
1440 result
= SMB_VFS_NEXT_SET_NT_ACL(handle
, fsp
, name
, security_info_sent
,
1443 do_log(SMB_VFS_OP_SET_NT_ACL
, result
, handle
, "%s", fsp
->fsp_name
);
1448 static int smb_full_audit_chmod_acl(vfs_handle_struct
*handle
,
1449 const char *path
, mode_t mode
)
1453 result
= SMB_VFS_NEXT_CHMOD_ACL(handle
, path
, mode
);
1455 do_log(SMB_VFS_OP_CHMOD_ACL
, (result
>= 0), handle
,
1456 "%s|%o", path
, mode
);
1461 static int smb_full_audit_fchmod_acl(vfs_handle_struct
*handle
, files_struct
*fsp
,
1462 int fd
, mode_t mode
)
1466 result
= SMB_VFS_NEXT_FCHMOD_ACL(handle
, fsp
, fd
, mode
);
1468 do_log(SMB_VFS_OP_FCHMOD_ACL
, (result
>= 0), handle
,
1469 "%s|%o", fsp
->fsp_name
, mode
);
1474 static int smb_full_audit_sys_acl_get_entry(vfs_handle_struct
*handle
,
1476 SMB_ACL_T theacl
, int entry_id
,
1477 SMB_ACL_ENTRY_T
*entry_p
)
1481 result
= SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle
, theacl
, entry_id
,
1484 do_log(SMB_VFS_OP_SYS_ACL_GET_ENTRY
, (result
>= 0), handle
,
1490 static int smb_full_audit_sys_acl_get_tag_type(vfs_handle_struct
*handle
,
1492 SMB_ACL_ENTRY_T entry_d
,
1493 SMB_ACL_TAG_T
*tag_type_p
)
1497 result
= SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle
, entry_d
,
1500 do_log(SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE
, (result
>= 0), handle
,
1506 static int smb_full_audit_sys_acl_get_permset(vfs_handle_struct
*handle
,
1508 SMB_ACL_ENTRY_T entry_d
,
1509 SMB_ACL_PERMSET_T
*permset_p
)
1513 result
= SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle
, entry_d
,
1516 do_log(SMB_VFS_OP_SYS_ACL_GET_PERMSET
, (result
>= 0), handle
,
1522 static void * smb_full_audit_sys_acl_get_qualifier(vfs_handle_struct
*handle
,
1524 SMB_ACL_ENTRY_T entry_d
)
1528 result
= SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle
, entry_d
);
1530 do_log(SMB_VFS_OP_SYS_ACL_GET_QUALIFIER
, (result
!= NULL
), handle
,
1536 static SMB_ACL_T
smb_full_audit_sys_acl_get_file(vfs_handle_struct
*handle
,
1538 SMB_ACL_TYPE_T type
)
1542 result
= SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle
, path_p
, type
);
1544 do_log(SMB_VFS_OP_SYS_ACL_GET_FILE
, (result
!= NULL
), handle
,
1550 static SMB_ACL_T
smb_full_audit_sys_acl_get_fd(vfs_handle_struct
*handle
,
1551 files_struct
*fsp
, int fd
)
1555 result
= SMB_VFS_NEXT_SYS_ACL_GET_FD(handle
, fsp
, fd
);
1557 do_log(SMB_VFS_OP_SYS_ACL_GET_FD
, (result
!= NULL
), handle
,
1558 "%s", fsp
->fsp_name
);
1563 static int smb_full_audit_sys_acl_clear_perms(vfs_handle_struct
*handle
,
1565 SMB_ACL_PERMSET_T permset
)
1569 result
= SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle
, permset
);
1571 do_log(SMB_VFS_OP_SYS_ACL_CLEAR_PERMS
, (result
>= 0), handle
,
1577 static int smb_full_audit_sys_acl_add_perm(vfs_handle_struct
*handle
,
1579 SMB_ACL_PERMSET_T permset
,
1580 SMB_ACL_PERM_T perm
)
1584 result
= SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle
, permset
, perm
);
1586 do_log(SMB_VFS_OP_SYS_ACL_ADD_PERM
, (result
>= 0), handle
,
1592 static char * smb_full_audit_sys_acl_to_text(vfs_handle_struct
*handle
,
1598 result
= SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle
, theacl
, plen
);
1600 do_log(SMB_VFS_OP_SYS_ACL_TO_TEXT
, (result
!= NULL
), handle
,
1606 static SMB_ACL_T
smb_full_audit_sys_acl_init(vfs_handle_struct
*handle
,
1612 result
= SMB_VFS_NEXT_SYS_ACL_INIT(handle
, count
);
1614 do_log(SMB_VFS_OP_SYS_ACL_INIT
, (result
!= NULL
), handle
,
1620 static int smb_full_audit_sys_acl_create_entry(vfs_handle_struct
*handle
,
1622 SMB_ACL_ENTRY_T
*pentry
)
1626 result
= SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle
, pacl
, pentry
);
1628 do_log(SMB_VFS_OP_SYS_ACL_CREATE_ENTRY
, (result
>= 0), handle
,
1634 static int smb_full_audit_sys_acl_set_tag_type(vfs_handle_struct
*handle
,
1636 SMB_ACL_ENTRY_T entry
,
1637 SMB_ACL_TAG_T tagtype
)
1641 result
= SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle
, entry
,
1644 do_log(SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE
, (result
>= 0), handle
,
1650 static int smb_full_audit_sys_acl_set_qualifier(vfs_handle_struct
*handle
,
1652 SMB_ACL_ENTRY_T entry
,
1657 result
= SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle
, entry
, qual
);
1659 do_log(SMB_VFS_OP_SYS_ACL_SET_QUALIFIER
, (result
>= 0), handle
,
1665 static int smb_full_audit_sys_acl_set_permset(vfs_handle_struct
*handle
,
1667 SMB_ACL_ENTRY_T entry
,
1668 SMB_ACL_PERMSET_T permset
)
1672 result
= SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle
, entry
, permset
);
1674 do_log(SMB_VFS_OP_SYS_ACL_SET_PERMSET
, (result
>= 0), handle
,
1680 static int smb_full_audit_sys_acl_valid(vfs_handle_struct
*handle
,
1686 result
= SMB_VFS_NEXT_SYS_ACL_VALID(handle
, theacl
);
1688 do_log(SMB_VFS_OP_SYS_ACL_VALID
, (result
>= 0), handle
,
1694 static int smb_full_audit_sys_acl_set_file(vfs_handle_struct
*handle
,
1696 const char *name
, SMB_ACL_TYPE_T acltype
,
1701 result
= SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle
, name
, acltype
,
1704 do_log(SMB_VFS_OP_SYS_ACL_SET_FILE
, (result
>= 0), handle
,
1710 static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct
*handle
, files_struct
*fsp
,
1711 int fd
, SMB_ACL_T theacl
)
1715 result
= SMB_VFS_NEXT_SYS_ACL_SET_FD(handle
, fsp
, fd
, theacl
);
1717 do_log(SMB_VFS_OP_SYS_ACL_SET_FD
, (result
>= 0), handle
,
1718 "%s", fsp
->fsp_name
);
1723 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct
*handle
,
1729 result
= SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle
, path
);
1731 do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE
, (result
>= 0), handle
,
1737 static int smb_full_audit_sys_acl_get_perm(vfs_handle_struct
*handle
,
1739 SMB_ACL_PERMSET_T permset
,
1740 SMB_ACL_PERM_T perm
)
1744 result
= SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle
, permset
, perm
);
1746 do_log(SMB_VFS_OP_SYS_ACL_GET_PERM
, (result
>= 0), handle
,
1752 static int smb_full_audit_sys_acl_free_text(vfs_handle_struct
*handle
,
1758 result
= SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle
, text
);
1760 do_log(SMB_VFS_OP_SYS_ACL_FREE_TEXT
, (result
>= 0), handle
,
1766 static int smb_full_audit_sys_acl_free_acl(vfs_handle_struct
*handle
,
1768 SMB_ACL_T posix_acl
)
1772 result
= SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle
, posix_acl
);
1774 do_log(SMB_VFS_OP_SYS_ACL_FREE_ACL
, (result
>= 0), handle
,
1780 static int smb_full_audit_sys_acl_free_qualifier(vfs_handle_struct
*handle
,
1782 SMB_ACL_TAG_T tagtype
)
1786 result
= SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle
, qualifier
,
1789 do_log(SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER
, (result
>= 0), handle
,
1795 static ssize_t
smb_full_audit_getxattr(struct vfs_handle_struct
*handle
,
1797 const char *name
, void *value
, size_t size
)
1801 result
= SMB_VFS_NEXT_GETXATTR(handle
, path
, name
, value
, size
);
1803 do_log(SMB_VFS_OP_GETXATTR
, (result
>= 0), handle
,
1804 "%s|%s", path
, name
);
1809 static ssize_t
smb_full_audit_lgetxattr(struct vfs_handle_struct
*handle
,
1810 const char *path
, const char *name
,
1811 void *value
, size_t size
)
1815 result
= SMB_VFS_NEXT_LGETXATTR(handle
, path
, name
, value
, size
);
1817 do_log(SMB_VFS_OP_LGETXATTR
, (result
>= 0), handle
,
1818 "%s|%s", path
, name
);
1823 static ssize_t
smb_full_audit_fgetxattr(struct vfs_handle_struct
*handle
,
1824 struct files_struct
*fsp
, int fd
,
1825 const char *name
, void *value
, size_t size
)
1829 result
= SMB_VFS_NEXT_FGETXATTR(handle
, fsp
, fd
, name
, value
, size
);
1831 do_log(SMB_VFS_OP_FGETXATTR
, (result
>= 0), handle
,
1832 "%s|%s", fsp
->fsp_name
, name
);
1837 static ssize_t
smb_full_audit_listxattr(struct vfs_handle_struct
*handle
,
1838 const char *path
, char *list
, size_t size
)
1842 result
= SMB_VFS_NEXT_LISTXATTR(handle
, path
, list
, size
);
1844 do_log(SMB_VFS_OP_LISTXATTR
, (result
>= 0), handle
, "%s", path
);
1849 static ssize_t
smb_full_audit_llistxattr(struct vfs_handle_struct
*handle
,
1850 const char *path
, char *list
, size_t size
)
1854 result
= SMB_VFS_NEXT_LLISTXATTR(handle
, path
, list
, size
);
1856 do_log(SMB_VFS_OP_LLISTXATTR
, (result
>= 0), handle
, "%s", path
);
1861 static ssize_t
smb_full_audit_flistxattr(struct vfs_handle_struct
*handle
,
1862 struct files_struct
*fsp
, int fd
, char *list
,
1867 result
= SMB_VFS_NEXT_FLISTXATTR(handle
, fsp
, fd
, list
, size
);
1869 do_log(SMB_VFS_OP_FLISTXATTR
, (result
>= 0), handle
,
1870 "%s", fsp
->fsp_name
);
1875 static int smb_full_audit_removexattr(struct vfs_handle_struct
*handle
,
1881 result
= SMB_VFS_NEXT_REMOVEXATTR(handle
, path
, name
);
1883 do_log(SMB_VFS_OP_REMOVEXATTR
, (result
>= 0), handle
,
1884 "%s|%s", path
, name
);
1889 static int smb_full_audit_lremovexattr(struct vfs_handle_struct
*handle
,
1895 result
= SMB_VFS_NEXT_LREMOVEXATTR(handle
, path
, name
);
1897 do_log(SMB_VFS_OP_LREMOVEXATTR
, (result
>= 0), handle
,
1898 "%s|%s", path
, name
);
1903 static int smb_full_audit_fremovexattr(struct vfs_handle_struct
*handle
,
1904 struct files_struct
*fsp
, int fd
,
1909 result
= SMB_VFS_NEXT_FREMOVEXATTR(handle
, fsp
, fd
, name
);
1911 do_log(SMB_VFS_OP_FREMOVEXATTR
, (result
>= 0), handle
,
1912 "%s|%s", fsp
->fsp_name
, name
);
1917 static int smb_full_audit_setxattr(struct vfs_handle_struct
*handle
,
1919 const char *name
, const void *value
, size_t size
,
1924 result
= SMB_VFS_NEXT_SETXATTR(handle
, path
, name
, value
, size
,
1927 do_log(SMB_VFS_OP_SETXATTR
, (result
>= 0), handle
,
1928 "%s|%s", path
, name
);
1933 static int smb_full_audit_lsetxattr(struct vfs_handle_struct
*handle
,
1935 const char *name
, const void *value
, size_t size
,
1940 result
= SMB_VFS_NEXT_LSETXATTR(handle
, path
, name
, value
, size
,
1943 do_log(SMB_VFS_OP_LSETXATTR
, (result
>= 0), handle
,
1944 "%s|%s", path
, name
);
1949 static int smb_full_audit_fsetxattr(struct vfs_handle_struct
*handle
,
1950 struct files_struct
*fsp
, int fd
, const char *name
,
1951 const void *value
, size_t size
, int flags
)
1955 result
= SMB_VFS_NEXT_FSETXATTR(handle
, fsp
, fd
, name
, value
, size
,
1958 do_log(SMB_VFS_OP_FSETXATTR
, (result
>= 0), handle
,
1959 "%s|%s", fsp
->fsp_name
, name
);
1964 static int smb_full_audit_aio_read(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1968 result
= SMB_VFS_NEXT_AIO_READ(handle
, fsp
, aiocb
);
1969 do_log(SMB_VFS_OP_AIO_READ
, (result
>= 0), handle
,
1970 "%s", fsp
->fsp_name
);
1975 static int smb_full_audit_aio_write(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1979 result
= SMB_VFS_NEXT_AIO_WRITE(handle
, fsp
, aiocb
);
1980 do_log(SMB_VFS_OP_AIO_WRITE
, (result
>= 0), handle
,
1981 "%s", fsp
->fsp_name
);
1986 static ssize_t
smb_full_audit_aio_return(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
1990 result
= SMB_VFS_NEXT_AIO_RETURN(handle
, fsp
, aiocb
);
1991 do_log(SMB_VFS_OP_AIO_RETURN
, (result
>= 0), handle
,
1992 "%s", fsp
->fsp_name
);
1997 static int smb_full_audit_aio_cancel(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int fd
, SMB_STRUCT_AIOCB
*aiocb
)
2001 result
= SMB_VFS_NEXT_AIO_CANCEL(handle
, fsp
, fd
, aiocb
);
2002 do_log(SMB_VFS_OP_AIO_CANCEL
, (result
>= 0), handle
,
2003 "%s", fsp
->fsp_name
);
2008 static int smb_full_audit_aio_error(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, SMB_STRUCT_AIOCB
*aiocb
)
2012 result
= SMB_VFS_NEXT_AIO_ERROR(handle
, fsp
, aiocb
);
2013 do_log(SMB_VFS_OP_AIO_ERROR
, (result
>= 0), handle
,
2014 "%s", fsp
->fsp_name
);
2019 static int smb_full_audit_aio_fsync(struct vfs_handle_struct
*handle
, struct files_struct
*fsp
, int op
, SMB_STRUCT_AIOCB
*aiocb
)
2023 result
= SMB_VFS_NEXT_AIO_FSYNC(handle
, fsp
, op
, aiocb
);
2024 do_log(SMB_VFS_OP_AIO_FSYNC
, (result
>= 0), handle
,
2025 "%s", fsp
->fsp_name
);
2030 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
)
2034 result
= SMB_VFS_NEXT_AIO_SUSPEND(handle
, fsp
, aiocb
, n
, ts
);
2035 do_log(SMB_VFS_OP_AIO_SUSPEND
, (result
>= 0), handle
,
2036 "%s", fsp
->fsp_name
);
2042 NTSTATUS
vfs_full_audit_init(void)
2044 NTSTATUS ret
= smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,
2045 "full_audit", audit_op_tuples
);
2047 if (!NT_STATUS_IS_OK(ret
))
2050 vfs_full_audit_debug_level
= debug_add_class("full_audit");
2051 if (vfs_full_audit_debug_level
== -1) {
2052 vfs_full_audit_debug_level
= DBGC_VFS
;
2053 DEBUG(0, ("vfs_full_audit: Couldn't register custom debugging "
2056 DEBUG(10, ("vfs_full_audit: Debug class number of "
2057 "'full_audit': %d\n", vfs_full_audit_debug_level
));