r7882: Looks like a large patch - but what it actually does is make Samba
[ira/wip.git] / source / modules / vfs_full_audit.c
index e91c1813a87cded8127ef61f55ee39051e0ab647..d2ac9b7c16a260660353fd9c43585baee7400348 100644 (file)
@@ -82,10 +82,20 @@ static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
                           struct connection_struct *conn,
                           enum SMB_QUOTA_TYPE qtype, unid_t id,
                           SMB_DISK_QUOTA *qt);
+static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
+                                struct files_struct *fsp,
+                                SHADOW_COPY_DATA *shadow_copy_data, BOOL labels);
+
 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
                          const char *fname);
 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
                                    connection_struct *conn, DIR *dirp);
+static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp, long offset);
+static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp);
+static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp);
 static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn,
                       const char *path, mode_t mode);
 static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn,
@@ -111,7 +121,7 @@ static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
                              const DATA_BLOB *hdr, SMB_OFF_T offset,
                              size_t n);
 static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn,
-                       const char *old, const char *new);
+                       const char *oldname, const char *newname);
 static int smb_full_audit_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd);
 static int smb_full_audit_stat(vfs_handle_struct *handle, connection_struct *conn,
                      const char *fname, SMB_STRUCT_STAT *sbuf);
@@ -297,6 +307,8 @@ static vfs_op_tuple audit_op_tuples[] = {
         SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_set_quota),  SMB_VFS_OP_SET_QUOTA,
         SMB_VFS_LAYER_LOGGER},
+       {SMB_VFS_OP(smb_full_audit_get_shadow_copy_data), SMB_VFS_OP_GET_SHADOW_COPY_DATA,
+        SMB_VFS_LAYER_LOGGER},
 
        /* Directory operations */
 
@@ -304,6 +316,12 @@ static vfs_op_tuple audit_op_tuples[] = {
         SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_readdir),    SMB_VFS_OP_READDIR,
         SMB_VFS_LAYER_LOGGER},
+       {SMB_VFS_OP(smb_full_audit_seekdir),    SMB_VFS_OP_SEEKDIR,
+        SMB_VFS_LAYER_LOGGER},
+       {SMB_VFS_OP(smb_full_audit_telldir),    SMB_VFS_OP_TELLDIR,
+        SMB_VFS_LAYER_LOGGER},
+       {SMB_VFS_OP(smb_full_audit_rewinddir),  SMB_VFS_OP_REWINDDIR,
+        SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_mkdir),      SMB_VFS_OP_MKDIR,
         SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_rmdir),      SMB_VFS_OP_RMDIR,
@@ -383,9 +401,9 @@ static vfs_op_tuple audit_op_tuples[] = {
 
        /* POSIX ACL operations. */
 
-       {SMB_VFS_OP(smb_full_audit_chmod_acl),  SMB_VFS_OP_CHMOD,
+       {SMB_VFS_OP(smb_full_audit_chmod_acl),  SMB_VFS_OP_CHMOD_ACL,
         SMB_VFS_LAYER_LOGGER},
-       {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD,
+       {SMB_VFS_OP(smb_full_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
         SMB_VFS_LAYER_LOGGER},
        {SMB_VFS_OP(smb_full_audit_sys_acl_get_entry),  SMB_VFS_OP_SYS_ACL_GET_ENTRY,
         SMB_VFS_LAYER_LOGGER},
@@ -479,6 +497,9 @@ static struct {
        { SMB_VFS_OP_GET_SHADOW_COPY_DATA,      "get_shadow_copy_data" },
        { SMB_VFS_OP_OPENDIR,   "opendir" },
        { SMB_VFS_OP_READDIR,   "readdir" },
+       { SMB_VFS_OP_SEEKDIR,   "seekdir" },
+       { SMB_VFS_OP_TELLDIR,   "telldir" },
+       { SMB_VFS_OP_REWINDDIR, "rewinddir" },
        { SMB_VFS_OP_MKDIR,     "mkdir" },
        { SMB_VFS_OP_RMDIR,     "rmdir" },
        { SMB_VFS_OP_CLOSEDIR,  "closedir" },
@@ -630,6 +651,11 @@ static void init_bitmap(struct bitmap **bm, const char **ops)
                }
 
                for (i=0; i<SMB_VFS_OP_LAST; i++) {
+                       if (vfs_op_names[i].name == NULL) {
+                               smb_panic("vfs_full_audit.c: name table not "
+                                         "in sync with vfs.h\n");
+                       }
+
                        if (strequal(*ops, vfs_op_names[i].name)) {
                                bitmap_set(*bm, i);
                                found = True;
@@ -776,6 +802,19 @@ static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
        return result;
 }
 
+static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
+                               struct files_struct *fsp,
+                               SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
+{
+       int result;
+
+       result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels);
+
+       do_log(SMB_VFS_OP_GET_SHADOW_COPY_DATA, (result >= 0), handle, "");
+
+       return result;
+}
+
 static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn,
                          const char *fname)
 {
@@ -788,10 +827,10 @@ static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct
        return result;
 }
 
-static struct dirent *smb_full_audit_readdir(vfs_handle_struct *handle,
+static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
                                    connection_struct *conn, DIR *dirp)
 {
-       struct dirent *result;
+       SMB_STRUCT_DIRENT *result;
 
        result = SMB_VFS_NEXT_READDIR(handle, conn, dirp);
 
@@ -803,6 +842,36 @@ static struct dirent *smb_full_audit_readdir(vfs_handle_struct *handle,
        return result;
 }
 
+static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp, long offset)
+{
+       SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset);
+
+       do_log(SMB_VFS_OP_SEEKDIR, True, handle, "");
+       return;
+}
+
+static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp)
+{
+       long result;
+
+       result = SMB_VFS_NEXT_TELLDIR(handle, conn, dirp);
+
+       do_log(SMB_VFS_OP_OPENDIR, True, handle, "");
+
+       return result;
+}
+
+static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn,
+                       DIR *dirp)
+{
+       SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp);
+
+       do_log(SMB_VFS_OP_REWINDDIR, True, handle, "");
+       return;
+}
+
 static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn,
                       const char *path, mode_t mode)
 {
@@ -943,13 +1012,13 @@ static ssize_t smb_full_audit_sendfile(vfs_handle_struct *handle, int tofd,
 }
 
 static int smb_full_audit_rename(vfs_handle_struct *handle, connection_struct *conn,
-                       const char *old, const char *new)
+                       const char *oldname, const char *newname)
 {
        int result;
        
-       result = SMB_VFS_NEXT_RENAME(handle, conn, old, new);
+       result = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname);
 
-       do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", old, new);
+       do_log(SMB_VFS_OP_RENAME, (result >= 0), handle, "%s|%s", oldname, newname);
 
        return result;    
 }