More for #9374 - Allow smb2.acls torture test to pass against smbd with a POSIX ACLs...
authorJeremy Allison <jra@samba.org>
Wed, 14 Nov 2012 22:40:51 +0000 (14:40 -0800)
committerMichael Adam <obnox@samba.org>
Tue, 20 Nov 2012 00:46:27 +0000 (01:46 +0100)
Change can_delete_directory() to can_delete_directory_fsp(), as
we only ever call this from an open directory file handle.

This allows us to use OpenDir_fsp() instead of OpenDir().
OpenDir() re-checks the ACL on the directory, which may
refuse DIR_LIST permissions. OpenDir_fsp() does not. As
this is a file-server internal check to see if the directory
actually contains any files before setting delete on close,
we can ignore the ACL here (Windows does).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Tue Nov 20 01:46:28 CET 2012 on sn-devel-104

source3/include/proto.h
source3/smbd/dir.c
source3/smbd/file_access.c

index bcecde955d1076fa9974743495888f0ec0f6a4a1..6856dd7730063cdec3b124f262108f34b621b614 100644 (file)
@@ -1626,8 +1626,7 @@ void cancel_pending_lock_requests_by_fid(files_struct *fsp,
                        enum file_close_type close_type);
 void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
                                    const char *name);
-NTSTATUS can_delete_directory(struct connection_struct *conn,
-                               const char *dirname);
+NTSTATUS can_delete_directory_fsp(files_struct *fsp);
 bool change_to_root_user(void);
 void contend_level2_oplocks_begin(files_struct *fsp,
                                  enum level2_contention_type type);
index e12812e8da281debc87666baa18fdd640eecaca5..525f20ec7f58f6529fbb78ebe1377e81d38433b8 100644 (file)
@@ -1743,16 +1743,20 @@ bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset)
  Is this directory empty ?
 *****************************************************************/
 
-NTSTATUS can_delete_directory(struct connection_struct *conn,
-                             const char *dirname)
+NTSTATUS can_delete_directory_fsp(files_struct *fsp)
 {
        NTSTATUS status = NT_STATUS_OK;
        long dirpos = 0;
        const char *dname = NULL;
+       const char *dirname = fsp->fsp_name->base_name;
        char *talloced = NULL;
        SMB_STRUCT_STAT st;
-       struct smb_Dir *dir_hnd = OpenDir(talloc_tos(), conn,
-                                       dirname, NULL, 0);
+       struct connection_struct *conn = fsp->conn;
+       struct smb_Dir *dir_hnd = OpenDir_fsp(talloc_tos(),
+                                       conn,
+                                       fsp,
+                                       NULL,
+                                       0);
 
        if (!dir_hnd) {
                return map_nt_error_from_unix(errno);
@@ -1772,7 +1776,7 @@ NTSTATUS can_delete_directory(struct connection_struct *conn,
                        continue;
                }
 
-               DEBUG(10,("can_delete_directory: got name %s - can't delete\n",
+               DEBUG(10,("got name %s - can't delete\n",
                         dname ));
                status = NT_STATUS_DIRECTORY_NOT_EMPTY;
                break;
index 0e74207b84d24e824b631b7e6e97122b861e8055..f4a7bb3d45ae3b236224017ba8126754bcc20069 100644 (file)
@@ -228,8 +228,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
                        return NT_STATUS_ACCESS_DENIED;
                }
 
-               return can_delete_directory(fsp->conn,
-                                           fsp->fsp_name->base_name);
+               return can_delete_directory_fsp(fsp);
        }
 
        return NT_STATUS_OK;