smbd: use parent_smb_fname() in can_delete_file_in_directory()
authorRalph Boehme <slow@samba.org>
Tue, 28 Apr 2020 13:21:37 +0000 (15:21 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 29 Apr 2020 16:39:39 +0000 (16:39 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/file_access.c

index cc939325e6292b1a8b6832904f8cb35dc264079a..39a8f195040447bdf1772e933dec28b3dd7c7ad5 100644 (file)
@@ -36,8 +36,7 @@ bool can_delete_file_in_directory(connection_struct *conn,
                                  const struct smb_filename *smb_fname)
 {
        TALLOC_CTX *ctx = talloc_tos();
-       char *dname = NULL;
-       struct smb_filename *smb_fname_parent;
+       struct smb_filename *smb_fname_parent = NULL;
        bool ret;
 
        if (!CAN_WRITE(conn)) {
@@ -50,18 +49,9 @@ bool can_delete_file_in_directory(connection_struct *conn,
        }
 
        /* Get the parent directory permission mask and owners. */
-       if (!parent_dirname(ctx, smb_fname->base_name, &dname, NULL)) {
-               return False;
-       }
-
-       smb_fname_parent = synthetic_smb_fname(ctx,
-                               dname,
-                               NULL,
-                               NULL,
-                               smb_fname->flags);
-       if (smb_fname_parent == NULL) {
-               ret = false;
-               goto out;
+       ret = parent_smb_fname(ctx, smb_fname, &smb_fname_parent, NULL);
+       if (ret != true) {
+               return false;
        }
 
        if(SMB_VFS_STAT(conn, smb_fname_parent) != 0) {
@@ -129,7 +119,6 @@ bool can_delete_file_in_directory(connection_struct *conn,
                                false,
                                FILE_DELETE_CHILD));
  out:
-       TALLOC_FREE(dname);
        TALLOC_FREE(smb_fname_parent);
        return ret;
 }