s3-vfs: rename open function to open_fn.
[kai/samba-autobuild/.git] / source3 / modules / vfs_audit.c
index 809ecc9e44b9cd838b42cceaf2ef8699bf93194f..349600fc43f5ef2e1f82bd1bbad773e68789e929 100644 (file)
@@ -22,6 +22,9 @@
 
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "system/syslog.h"
+#include "smbd/smbd.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -78,15 +81,18 @@ static int audit_syslog_priority(vfs_handle_struct *handle)
 static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user)
 {
        int result;
-       
+
+       result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
+       if (result < 0) {
+               return result;
+       }
+
        openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle));
 
        syslog(audit_syslog_priority(handle), "connect to service %s by user %s\n", 
               svc, user);
 
-       result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
-
-       return result;
+       return 0;
 }
 
 static void audit_disconnect(vfs_handle_struct *handle)
@@ -148,7 +154,7 @@ static int audit_open(vfs_handle_struct *handle,
        result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
 
        syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n", 
-              smb_fname_str_dbg(smb_fname), result,
+              smb_fname->base_name, result,
               ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", 
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
@@ -179,22 +185,23 @@ static int audit_rename(vfs_handle_struct *handle,
        result = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
 
        syslog(audit_syslog_priority(handle), "rename %s -> %s %s%s\n",
-              smb_fname_str_dbg(smb_fname_src),
-              smb_fname_str_dbg(smb_fname_dst),
+              smb_fname_src->base_name,
+              smb_fname_dst->base_name,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
 
        return result;    
 }
 
-static int audit_unlink(vfs_handle_struct *handle, const char *path)
+static int audit_unlink(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        int result;
 
-       result = SMB_VFS_NEXT_UNLINK(handle, path);
+       result = SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 
        syslog(audit_syslog_priority(handle), "unlink %s %s%s\n",
-              path,
+              smb_fname->base_name,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
 
@@ -236,7 +243,7 @@ static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mod
        result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
 
        syslog(audit_syslog_priority(handle), "fchmod %s mode 0x%x %s%s\n",
-              fsp->fsp_name, mode,
+              fsp->fsp_name->base_name, mode,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
 
@@ -250,44 +257,31 @@ static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t
        result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
 
        syslog(audit_syslog_priority(handle), "fchmod_acl %s mode 0x%x %s%s\n",
-              fsp->fsp_name, mode,
+              fsp->fsp_name->base_name, mode,
               (result < 0) ? "failed: " : "",
               (result < 0) ? strerror(errno) : "");
 
        return result;
 }
 
-/* VFS operations */
-static vfs_op_tuple audit_op_tuples[] = {
-
-       /* Disk operations */
-
-       {SMB_VFS_OP(audit_connect),     SMB_VFS_OP_CONNECT,     SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_disconnect),  SMB_VFS_OP_DISCONNECT,  SMB_VFS_LAYER_LOGGER},
-
-       /* Directory operations */
-
-       {SMB_VFS_OP(audit_opendir),     SMB_VFS_OP_OPENDIR,     SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_mkdir),               SMB_VFS_OP_MKDIR,       SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_rmdir),               SMB_VFS_OP_RMDIR,       SMB_VFS_LAYER_LOGGER},
-
-       /* File operations */
-
-       {SMB_VFS_OP(audit_open),                SMB_VFS_OP_OPEN,        SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_close),               SMB_VFS_OP_CLOSE,       SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_rename),              SMB_VFS_OP_RENAME,      SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_unlink),              SMB_VFS_OP_UNLINK,      SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_chmod),               SMB_VFS_OP_CHMOD,       SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_fchmod),              SMB_VFS_OP_FCHMOD,      SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_chmod_acl),   SMB_VFS_OP_CHMOD_ACL,   SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(audit_fchmod_acl),  SMB_VFS_OP_FCHMOD_ACL,  SMB_VFS_LAYER_LOGGER},
-
-       /* Finish VFS operations definition */
-
-       {SMB_VFS_OP(NULL),                      SMB_VFS_OP_NOOP,        SMB_VFS_LAYER_NOOP}
+static struct vfs_fn_pointers vfs_audit_fns = {
+       .connect_fn = audit_connect,
+       .disconnect = audit_disconnect,
+       .opendir = audit_opendir,
+       .mkdir = audit_mkdir,
+       .rmdir = audit_rmdir,
+       .open_fn = audit_open,
+       .close_fn = audit_close,
+       .rename = audit_rename,
+       .unlink = audit_unlink,
+       .chmod = audit_chmod,
+       .fchmod = audit_fchmod,
+       .chmod_acl = audit_chmod_acl,
+       .fchmod_acl = audit_fchmod_acl
 };
 
 NTSTATUS vfs_audit_init(void)
 {
-       return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "audit", audit_op_tuples);
+       return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "audit",
+                               &vfs_audit_fns);
 }