smbd: Factor out check_access_fsp() from check_access()
authorVolker Lendecke <vl@samba.org>
Tue, 17 Nov 2015 14:10:42 +0000 (15:10 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 17 Nov 2015 18:53:24 +0000 (19:53 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/proto.h
source3/smbd/trans2.c

index 7926dd6..be51182 100644 (file)
@@ -1079,6 +1079,8 @@ int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf);
 
 /* The following definitions come from smbd/trans2.c  */
 
+NTSTATUS check_access_fsp(const struct files_struct *fsp,
+                         uint32_t access_mask);
 NTSTATUS check_access(connection_struct *conn,
                                files_struct *fsp,
                                const struct smb_filename *smb_fname,
index ec6d91b..dd226ee 100644 (file)
@@ -54,6 +54,15 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
                                files_struct *fsp,
                                const SMB_STRUCT_STAT *psbuf);
 
+NTSTATUS check_access_fsp(const struct files_struct *fsp,
+                         uint32_t access_mask)
+{
+       if (!(fsp->access_mask & access_mask)) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+       return NT_STATUS_OK;
+}
+
 /********************************************************************
  The canonical "check access" based on object handle or path function.
 ********************************************************************/
@@ -64,10 +73,8 @@ NTSTATUS check_access(connection_struct *conn,
                                uint32_t access_mask)
 {
        if (fsp) {
-               if (!(fsp->access_mask & access_mask)) {
-                       return NT_STATUS_ACCESS_DENIED;
-               }
-               return NT_STATUS_OK;
+               NTSTATUS status = check_access_fsp(fsp, access_mask);
+               return status;
        } else {
                NTSTATUS status = smbd_check_access_rights(conn,
                                        smb_fname,