cope better with read only files in smb2_deltree
authorAndrew Tridgell <tridge@samba.org>
Tue, 27 May 2008 04:06:27 +0000 (14:06 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 27 May 2008 04:06:27 +0000 (14:06 +1000)
(This used to be commit 88a2c7b2f44f160836e477e460812df557204f51)

source4/libcli/smb2/util.c

index 9eb344e83fdc5ef0058e575467027c01e2423190..311cea94a085a1494e49c8b7dd67d6bedf032de8 100644 (file)
@@ -127,6 +127,16 @@ int smb2_deltree(struct smb2_tree *tree, const char *dname)
                return 0;
        }
 
                return 0;
        }
 
+       if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
+               /* it could be read-only */
+               status = smb2_util_setatr(tree, dname, FILE_ATTRIBUTE_NORMAL);
+               status = smb2_util_unlink(tree, dname);
+       }
+       if (NT_STATUS_IS_OK(status)) {
+               talloc_free(tmp_ctx);
+               return 1;
+       }
+
        ZERO_STRUCT(create_parm);
        create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
        create_parm.in.share_access = 
        ZERO_STRUCT(create_parm);
        create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
        create_parm.in.share_access =