Change the prototype of the vfs function get_nt_acl().
authorMichael Adam <obnox@samba.org>
Wed, 5 Dec 2007 08:53:10 +0000 (09:53 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 19 Dec 2007 22:08:01 +0000 (23:08 +0100)
Up to now, get_nt_acl() took a files_struct pointer (fsp) and
a file name. All the underlying functions should need and now
do need (after the previous preparatory work), is a connection_struct
and a file name. The connection_struct is already there in the
vfs_handle passed to the vfs functions. So the files_struct
argument can be eliminated.

This eliminates the need of calling open_file_stat in a couple
of places to produce the fsp needed.

Michael
(This used to be commit b5f600fab53c9d159a958c59795db3ba4a8acc63)

12 files changed:
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_afsacl.c
source3/modules/vfs_catia.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_zfsacl.c
source3/rpc_server/srv_srvsvc_nt.c
source3/smbd/file_access.c
source3/smbd/nttrans.c
source3/smbd/posix_acls.c

index b45320dd8720a170b7dca4daab2d9b588724a0c5..e1669a271c4c08975290c04522fcb00d29386335 100644 (file)
@@ -75,6 +75,9 @@
 /* Leave at 22 - not yet released. Change all BOOL parameters (int) to bool. jra. */
 /* Leave at 22 - not yet released. Added recvfile. */
 /* Leave at 22 - not yet released. Change get_nt_acl to return NTSTATUS - vl */
+/* Leave at 22 - not yet released. Change get_nt_acl to *not* take a
+ * files_struct. - obnox.*/
+
 #define SMB_VFS_INTERFACE_VERSION 22
 
 
@@ -311,7 +314,6 @@ struct vfs_ops {
                                        uint32 security_info,
                                        struct security_descriptor **ppdesc);
                NTSTATUS (*get_nt_acl)(struct vfs_handle_struct *handle,
-                                      struct files_struct *fsp,
                                       const char *name,
                                       uint32 security_info,
                                       struct security_descriptor **ppdesc);
index cc7780f35461a0665fea56db75d9be1ad2151961..c31d6cfc67a75ae36fd16323f36c3f5b9dc80b2b 100644 (file)
@@ -85,7 +85,7 @@
 
 /* NT ACL operations. */
 #define SMB_VFS_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
-#define SMB_VFS_GET_NT_ACL(fsp, name, security_info, ppdesc) ((fsp)->conn->vfs.ops.get_nt_acl((fsp)->conn->vfs.handles.get_nt_acl, (fsp), (name), (security_info), (ppdesc)))
+#define SMB_VFS_GET_NT_ACL(conn, name, security_info, ppdesc) ((conn)->vfs.ops.get_nt_acl((conn)->vfs.handles.get_nt_acl, (name), (security_info), (ppdesc)))
 #define SMB_VFS_FSET_NT_ACL(fsp, fd, security_info_sent, psd) ((fsp)->conn->vfs.ops.fset_nt_acl((fsp)->conn->vfs.handles.fset_nt_acl, (fsp), (fd), (security_info_sent), (psd)))
 #define SMB_VFS_SET_NT_ACL(fsp, name, security_info_sent, psd) ((fsp)->conn->vfs.ops.set_nt_acl((fsp)->conn->vfs.handles.set_nt_acl, (fsp), (name), (security_info_sent), (psd)))
 
 
 /* NT ACL operations. */
 #define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, fd, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
-#define SMB_VFS_OPAQUE_GET_NT_ACL(fsp, name, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.get_nt_acl((fsp)->conn->vfs_opaque.handles.get_nt_acl, (fsp), (name), (security_info), (ppdesc)))
+#define SMB_VFS_OPAQUE_GET_NT_ACL(conn, name, security_info, ppdesc) ((conn)->vfs_opaque.ops.get_nt_acl((conn)->vfs_opaque.handles.get_nt_acl, (name), (security_info), (ppdesc)))
 #define SMB_VFS_OPAQUE_FSET_NT_ACL(fsp, fd, security_info_sent, psd) ((fsp)->conn->vfs_opaque.ops.fset_nt_acl((fsp)->conn->vfs_opaque.handles.fset_nt_acl, (fsp), (fd), (security_info_sent), (psd)))
 #define SMB_VFS_OPAQUE_SET_NT_ACL(fsp, name, security_info_sent, psd) ((fsp)->conn->vfs_opaque.ops.set_nt_acl((fsp)->conn->vfs_opaque.handles.set_nt_acl, (fsp), (name), (security_info_sent), (psd)))
 
 
 /* NT ACL operations. */
 #define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, fd, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (fd), (security_info), (ppdesc)))
-#define SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, ppdesc) ((handle)->vfs_next.ops.get_nt_acl((handle)->vfs_next.handles.get_nt_acl, (fsp), (name), (security_info), (ppdesc)))
+#define SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc) ((handle)->vfs_next.ops.get_nt_acl((handle)->vfs_next.handles.get_nt_acl, (name), (security_info), (ppdesc)))
 #define SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent, psd) ((handle)->vfs_next.ops.fset_nt_acl((handle)->vfs_next.handles.fset_nt_acl, (fsp), (fd), (security_info_sent), (psd)))
 #define SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent, psd) ((handle)->vfs_next.ops.set_nt_acl((handle)->vfs_next.handles.set_nt_acl, (fsp), (name), (security_info_sent), (psd)))
 
index 9dd4d7ec93199a59490ea88dd32e7551d96f0106..a14a1172298cd21d69ca5a103b4e91952e41c0e8 100644 (file)
@@ -1015,7 +1015,6 @@ static NTSTATUS afsacl_fget_nt_acl(struct vfs_handle_struct *handle,
 }
 
 static NTSTATUS afsacl_get_nt_acl(struct vfs_handle_struct *handle,
-                                 struct files_struct *fsp,
                                  const char *name,  uint32 security_info,
                                  struct security_descriptor **ppdesc)
 {
index 71f478a8a9a6aaa7c1e32e6ab88588db4e8d4872..ab48c963ec4fdc9122ac9a5669993875f73a8eb6 100644 (file)
@@ -290,8 +290,7 @@ static NTSTATUS catia_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
                               const char *name, uint32 security_info,
                               struct  security_descriptor **ppdesc)
 {
-        return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
-                                      ppdesc);
+        return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
 }
 
 static NTSTATUS catia_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
index 3dd3727340b334416f3672be47962720e8615a1a..17b183600a6bbb4fdf2fbcc2fba6face8b0592b0 100644 (file)
@@ -956,13 +956,13 @@ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
 }
 
 static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
-                                  files_struct *fsp, const char *name,
+                                  const char *name,
                                   uint32 security_info, SEC_DESC **ppdesc)
 {
        NTSTATUS result;
 
        START_PROFILE(get_nt_acl);
-       result = posix_get_nt_acl(fsp->conn, fsp->fsp_name, security_info, ppdesc);
+       result = posix_get_nt_acl(handle->conn, name, security_info, ppdesc);
        END_PROFILE(get_nt_acl);
        return result;
 }
index f4aeefbbf054352bf898a69e8386ca0ad6c858d6..f6b6e858374b75fe0fa22798a49ee799163caa8b 100644 (file)
@@ -1547,8 +1547,7 @@ static NTSTATUS smb_full_audit_get_nt_acl(vfs_handle_struct *handle,
 {
        NTSTATUS result;
 
-       result = SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info,
-                                        ppdesc);
+       result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
 
        do_log(SMB_VFS_OP_GET_NT_ACL, NT_STATUS_IS_OK(result), handle,
               "%s", fsp->fsp_name);
index e7331bef29c4f49d2af36d2f50fdef7f042de6b6..24ca3d5e423c3082e72919e3da10bc54d45a5f97 100644 (file)
@@ -249,7 +249,7 @@ static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
 }
 
 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
-       files_struct *fsp, const char *name,
+       const char *name,
        uint32 security_info, SEC_DESC **ppdesc)
 {
        SMB4ACL_T *pacl = NULL;
index 83893c7aea368158aee49d9e41ebcb49247cb4d8..060d64cffbbce7a58618dcfdab24794e3952c197 100644 (file)
@@ -189,7 +189,6 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct *handle,
 }
 
 static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle,
-                               struct files_struct *fsp,
                                const char *name,  uint32 security_info,
                                struct security_descriptor **ppdesc)
 {
index 125ccb4752add9440c68443644748a4c5d690c6a..43f57a01097322f8089a7518261de98d6c6e1d3d 100644 (file)
@@ -2089,7 +2089,6 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
        char *filename_in = NULL;
        char *filename = NULL;
        char *qualname = NULL;
-       files_struct *fsp = NULL;
        SMB_STRUCT_STAT st;
        NTSTATUS nt_status;
        struct current_user user;
@@ -2149,25 +2148,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
                goto error_exit;
        }
 
-       nt_status = open_file_stat(conn, NULL, filename, &st, &fsp);
-       /* Perhaps it is a directory */
-       if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
-               nt_status = open_directory(conn, NULL, filename, &st,
-                                          READ_CONTROL_ACCESS,
-                                          FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                          FILE_OPEN,
-                                          0,
-                                          FILE_ATTRIBUTE_DIRECTORY,
-                                          NULL, &fsp);
-       }
-
-       if (!NT_STATUS_IS_OK(nt_status)) {
-               DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename));
-               r_u->status = ntstatus_to_werror(nt_status);
-               goto error_exit;
-       }
-
-       nt_status = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name,
+       nt_status = SMB_VFS_GET_NT_ACL(conn, filename,
                                       (OWNER_SECURITY_INFORMATION
                                        |GROUP_SECURITY_INFORMATION
                                        |DACL_SECURITY_INFORMATION), &psd);
@@ -2188,17 +2169,12 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC
 
        psd->dacl->revision = (uint16) NT4_ACL_REVISION;
 
-       close_file(fsp, NORMAL_CLOSE);
        unbecome_user();
        close_cnum(conn, user.vuid);
        return r_u->status;
 
 error_exit:
 
-       if(fsp) {
-               close_file(fsp, NORMAL_CLOSE);
-       }
-
        if (became_user)
                unbecome_user();
 
index a58bcdd8915c361210e1d2f595090998b304a5ac..964d1af2588d2a7e0c9883f80cd21afe51558801 100644 (file)
@@ -25,67 +25,6 @@ extern struct current_user current_user;
 #undef  DBGC_CLASS
 #define DBGC_CLASS DBGC_ACLS
 
-/****************************************************************************
- Helper function that gets a security descriptor by connection and
- file name.
- NOTE: This is transitional, in the sense that SMB_VFS_GET_NT_ACL really
- should *not* get a files_struct pointer but a connection_struct ptr
- (automatic by the vfs handle) and the file name and _use_ that!
-****************************************************************************/
-static NTSTATUS conn_get_nt_acl(TALLOC_CTX *mem_ctx,
-                               struct connection_struct *conn,
-                               const char *fname,
-                               SMB_STRUCT_STAT *psbuf,
-                               struct security_descriptor **psd)
-{
-       NTSTATUS status;
-       struct files_struct *fsp = NULL;
-       struct security_descriptor *secdesc = NULL;
-
-       if (!VALID_STAT(*psbuf)) {
-               if (SMB_VFS_STAT(conn, fname, psbuf) != 0) {
-                       return map_nt_error_from_unix(errno);
-               }
-       }
-
-       /* fake a files_struct ptr: */
-
-       if (S_ISDIR(psbuf->st_mode)) {
-               status = open_directory(conn, NULL, fname, psbuf,
-                                       READ_CONTROL_ACCESS,
-                                       FILE_SHARE_READ|FILE_SHARE_WRITE,
-                                       FILE_OPEN,
-                                       0,
-                                       FILE_ATTRIBUTE_DIRECTORY,
-                                       NULL, &fsp);
-       }
-       else {
-               status = open_file_stat(conn, NULL, fname, psbuf, &fsp);
-       }
-
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(3, ("Unable to open file %s: %s\n", fname,
-                         nt_errstr(status)));
-               return status;
-       }
-
-       status = SMB_VFS_GET_NT_ACL(fsp, fname,
-                                   (OWNER_SECURITY_INFORMATION |
-                                    GROUP_SECURITY_INFORMATION |
-                                    DACL_SECURITY_INFORMATION),
-                                   &secdesc);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(5, ("Unable to get NT ACL for file %s\n", fname));
-               goto done;
-       }
-
-       *psd = talloc_move(mem_ctx, &secdesc);
-
-done:
-       close_file(fsp, NORMAL_CLOSE);
-       return status;
-}
-
 static bool can_access_file_acl(struct connection_struct *conn,
                                const char * fname, SMB_STRUCT_STAT *psbuf,
                                uint32_t access_mask)
@@ -95,7 +34,11 @@ static bool can_access_file_acl(struct connection_struct *conn,
        uint32_t access_granted;
        struct security_descriptor *secdesc = NULL;
 
-       status = conn_get_nt_acl(talloc_tos(), conn, fname, psbuf, &secdesc);
+       status = SMB_VFS_GET_NT_ACL(conn, fname,
+                                   (OWNER_SECURITY_INFORMATION |
+                                    GROUP_SECURITY_INFORMATION |
+                                    DACL_SECURITY_INFORMATION),
+                                   &secdesc);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(5, ("Could not get acl: %s\n", nt_errstr(status)));
                return false;
index 1fbb681c720f68dd5b5b3ba5138f8669ce8b0954..cb98a8139c6c2a906d5e1bc162775691b7c914e2 100644 (file)
@@ -1640,7 +1640,7 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
                }
                else {
                        status = SMB_VFS_GET_NT_ACL(
-                               fsp, fsp->fsp_name, security_info_wanted, &psd);
+                               conn, fsp->fsp_name, security_info_wanted, &psd);
                }
        }
 
index d9782cfdb877e759740ab1eb2a3dc9a761d97fc6..d8794e2114e083d43d4dee0fe1c0d0b25372be19 100644 (file)
@@ -3307,7 +3307,7 @@ static NTSTATUS append_parent_acl(files_struct *fsp,
                return status;
        }
 
-       status = SMB_VFS_GET_NT_ACL(parent_fsp, parent_fsp->fsp_name,
+       status = SMB_VFS_GET_NT_ACL(parent_fsp->conn, parent_fsp->fsp_name,
                                    DACL_SECURITY_INFORMATION, &parent_sd );
 
        close_file(parent_fsp, NORMAL_CLOSE);