Remove can_access_file_data() - make it use the standard smbd_check_access_rights...
authorJeremy Allison <jra@samba.org>
Fri, 4 Nov 2011 22:45:13 +0000 (15:45 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 4 Nov 2011 22:45:13 +0000 (15:45 -0700)
source3/modules/onefs_open.c
source3/smbd/file_access.c
source3/smbd/open.c

index dd4eb90b13ae48402e51dd42087765e794cfae09..d7b2af35441055870d1a8fcc9c2c0f014e0d2461 100644 (file)
@@ -1042,8 +1042,8 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
 
                        if (((can_access_mask & FILE_WRITE_DATA) &&
                                !CAN_WRITE(conn)) ||
-                           !can_access_file_data(conn, smb_fname,
-                                                 can_access_mask)) {
+                               !NT_STATUS_IS_OK(smbd_check_access_rights(conn,
+                                               smb_fname, can_access_mask))) {
                                can_access = False;
                        }
 
index c2203673f3d86236eb1abb4b1c946232536a9227..81cb7bd43f1ed8c7732da9ada0d454c0ba04a941 100644 (file)
@@ -176,61 +176,6 @@ bool can_delete_file_in_directory(connection_struct *conn,
        return ret;
 }
 
-/****************************************************************************
- Actually emulate the in-kernel access checking for read/write access. We need
- this to successfully check for ability to write for dos filetimes.
- Note this doesn't take into account share write permissions.
-****************************************************************************/
-
-bool can_access_file_data(connection_struct *conn,
-                         const struct smb_filename *smb_fname,
-                         uint32 access_mask)
-{
-       if (!(access_mask & (FILE_READ_DATA|FILE_WRITE_DATA))) {
-               return False;
-       }
-       access_mask &= (FILE_READ_DATA|FILE_WRITE_DATA);
-
-       /* some fast paths first */
-
-       DEBUG(10,("can_access_file_data: requesting 0x%x on file %s\n",
-                 (unsigned int)access_mask, smb_fname_str_dbg(smb_fname)));
-
-       if (get_current_uid(conn) == (uid_t)0) {
-               /* I'm sorry sir, I didn't know you were root... */
-               return True;
-       }
-
-       SMB_ASSERT(VALID_STAT(smb_fname->st));
-
-       /* Check primary owner access. */
-       if (get_current_uid(conn) == smb_fname->st.st_ex_uid) {
-               switch (access_mask) {
-                       case FILE_READ_DATA:
-                               return (smb_fname->st.st_ex_mode & S_IRUSR) ?
-                                   True : False;
-
-                       case FILE_WRITE_DATA:
-                               return (smb_fname->st.st_ex_mode & S_IWUSR) ?
-                                   True : False;
-
-                       default: /* FILE_READ_DATA|FILE_WRITE_DATA */
-
-                               if ((smb_fname->st.st_ex_mode &
-                                       (S_IWUSR|S_IRUSR)) ==
-                                   (S_IWUSR|S_IRUSR)) {
-                                       return True;
-                               } else {
-                                       return False;
-                               }
-               }
-       }
-
-       /* now for ACL checks */
-
-       return can_access_file_acl(conn, smb_fname, access_mask);
-}
-
 /****************************************************************************
  Userspace check for write access.
  Note this doesn't take into account share write permissions.
@@ -239,7 +184,9 @@ bool can_access_file_data(connection_struct *conn,
 bool can_write_to_file(connection_struct *conn,
                       const struct smb_filename *smb_fname)
 {
-       return can_access_file_data(conn, smb_fname, FILE_WRITE_DATA);
+       return NT_STATUS_IS_OK(smbd_check_access_rights(conn,
+                               smb_fname,
+                               FILE_WRITE_DATA));
 }
 
 /****************************************************************************
index 2f79908b626cdad904740f4cde33f818ee39c787..a1a247fca26436dafca63adb392d7cbed1347455 100644 (file)
@@ -2081,8 +2081,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
                        if (((can_access_mask & FILE_WRITE_DATA) &&
                                !CAN_WRITE(conn)) ||
-                           !can_access_file_data(conn, smb_fname,
-                                                 can_access_mask)) {
+                               !NT_STATUS_IS_OK(smbd_check_access_rights(conn,
+                                               smb_fname, can_access_mask))) {
                                can_access = False;
                        }