The branch, master has been updated
       via  954d877a2ee smbd: remove unneeded parent_dir variable from 
mkdir_internal()
       via  328716b91b1 smbd: convert inherit_from_dir arg of 
change_dir_owner_to_parent() to struct smb_filename
       via  3eb42c24ff7 smbd: convert inherit_from_dir arg of 
change_file_owner_to_parent() to struct smb_filename
       via  bf504ac3c64 smbd: convert inherit_access_posix_acl() arg parent_dir 
to struct smb_filename
       via  0ff2dda37d3 smbd: convert parent_dir arg of open_file() to struct 
smb_filename
       via  4cc86556a83 smbd: pass dirname as struct smb_filename to 
is_visible_file()
       via  84743b727f4 smbd: realign is_visible_file() args one per line
       via  37a9736810d smbd: copy twrp in cp_smb_filename()
       via  9f64f30140c smbd: add previous version timestamp to struct 
smb_filename
       via  45a560bce3e smbd: pass struct smb_filename smb_fname_parent to 
unix_mode()
       via  214dea7defe smbd: pass struct smb_filename parent_dir to 
file_set_dosmode()
       via  224b1405839 smbd: align file_set_dosmode() args one per line
       via  d9ae1c78b92 smbd: pass struct smb_filename to 
directory_has_default_acl()
       via  aa0ec8a2098 smbd: use parent_smb_fname() in check_reduced_name()
       via  8fdfbc8d5c9 smbd: use parent_smb_fname() in 
check_reduced_name_with_privilege()
       via  adf75b8cef7 smbd: use parent_smb_fname() in smb_unix_mknod()
       via  75b85a4d846 smbd: use parent_smb_fname() in 
parent_dirname_compatible_open()
       via  3830ba0d5bc smbd: use parent_smb_fname() in inherit_new_acl()
       via  90a198bcd0a smbd: use parent_smb_fname() in mkdir_internal()
       via  16f866a1a0d smbd: use parent_smb_fname() in open_file_ntcreate()
       via  4c497c77315 smbd: use parent_smb_fname() in non_widelink_open()
       via  61bf5410f0e smbd: use parent_smb_fname() in check_parent_access()
       via  58a995931d7 smbd: use parent_smb_fname() in copy_internals()
       via  c0a9c8698c2 smbd: use parent_smb_fname() in unix_convert()
       via  3cc0dcad35c smbd: use synthetic_smb_fname() in check_parent_exists()
       via  4d1ba69abad smbd: use parent_smb_fname() in 
can_delete_file_in_directory()
       via  aa125a7d368 vfs_linux_xfs_sgid: use parent_smb_fname()
       via  259857038b6 vfs_gpfs: use parent_smb_fname()
       via  036ed35b3bb vfs_default: use parent_smb_fname()
       via  8bd6908baef vfs_ceph: use parent_smb_fname()
       via  7f68944acdf vfs_aio_pthread: use parent_smb_fname()
       via  eafd4160b0d vfs_acl_common: use parent_smb_fname()
       via  5fe180e7510 s3/lib: add parent_smb_fname()
      from  a454c9cd42e testprogs: Add client kerberos test

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 954d877a2eefd985479f35a99c2dd8c804f15cc0
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 11:06:26 2020 +0200

    smbd: remove unneeded parent_dir variable from mkdir_internal()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Wed Apr 29 18:16:02 UTC 2020 on sn-devel-184

commit 328716b91b1365ed0ec0a5e6f16114a453cbd88e
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 11:05:25 2020 +0200

    smbd: convert inherit_from_dir arg of change_dir_owner_to_parent() to 
struct smb_filename
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 3eb42c24ff767efd6d8335aecdd51be4549c84d3
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 11:03:11 2020 +0200

    smbd: convert inherit_from_dir arg of change_file_owner_to_parent() to 
struct smb_filename
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit bf504ac3c6421757c1aa2822b3ffa5212e1e87f7
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 10:56:23 2020 +0200

    smbd: convert inherit_access_posix_acl() arg parent_dir to struct 
smb_filename
    
    This also fixes a bug introduced by cea8e57eac2ed7b90a5c5d207bf392ff0546398e
    where inherit_access_posix_acl() used the smb_fname->base_name instead of
    inherit_from_dir in synthetic_smb_fname() to get an struct smb_filename of 
the
    parent directory.
    
    Nobody complained so far, fix it silently.
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 0ff2dda37d34338f2b931839815a21269ab1626a
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 10:43:05 2020 +0200

    smbd: convert parent_dir arg of open_file() to struct smb_filename
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 4cc86556a8323d4bd08bf0c93b971919e96a2a19
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 10:09:16 2020 +0200

    smbd: pass dirname as struct smb_filename to is_visible_file()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 84743b727f4f5bb367876d7651098ebec66fcdd9
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 09:51:13 2020 +0200

    smbd: realign is_visible_file() args one per line
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 37a9736810d236420f13f158a10b13cf5f67a532
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:24:59 2020 +0200

    smbd: copy twrp in cp_smb_filename()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 9f64f30140c4ad2a4d34294f35f5082f96fc5460
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:23:37 2020 +0200

    smbd: add previous version timestamp to struct smb_filename
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 45a560bce3ef06c211e60e3932521303cc396896
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:18:08 2020 +0200

    smbd: pass struct smb_filename smb_fname_parent to unix_mode()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 214dea7defeb3d87cfaaf02a0b1171b8ca28ba91
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:09:18 2020 +0200

    smbd: pass struct smb_filename parent_dir to file_set_dosmode()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 224b140583937f450bbc8946206f11bc6b87eccc
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:06:21 2020 +0200

    smbd: align file_set_dosmode() args one per line
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit d9ae1c78b92c876dbe285d6edd170e920933c0a5
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 18:03:41 2020 +0200

    smbd: pass struct smb_filename to directory_has_default_acl()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit aa0ec8a20983ad2ec96eb0d874633baafb228807
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 17:58:07 2020 +0200

    smbd: use parent_smb_fname() in check_reduced_name()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 8fdfbc8d5c9926ecaf69012ce94fd323284ce60a
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 17:50:01 2020 +0200

    smbd: use parent_smb_fname() in check_reduced_name_with_privilege()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit adf75b8cef7887913965b7ced2618723fbe74992
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 17:08:53 2020 +0200

    smbd: use parent_smb_fname() in smb_unix_mknod()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 75b85a4d846e89ddc517906311a1da07645b2ffd
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:55:30 2020 +0200

    smbd: use parent_smb_fname() in parent_dirname_compatible_open()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 3830ba0d5bc34c64e79e492315e41dde10a86e33
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:52:09 2020 +0200

    smbd: use parent_smb_fname() in inherit_new_acl()
    
    Note: has to rename the variable parent_smb_fname otherwise it conflicts 
with
    the function name.
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 90a198bcd0a7c2b76f474de1f95f5dc39882c3ec
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:47:44 2020 +0200

    smbd: use parent_smb_fname() in mkdir_internal()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 16f866a1a0d5bdd791592bf591c64dd59918fe42
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:44:00 2020 +0200

    smbd: use parent_smb_fname() in open_file_ntcreate()
    
    Prepares for converting a bunch of functions to struct smb_filename later.
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 4c497c773156111e8fd12ab8573cf78d62823218
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:40:25 2020 +0200

    smbd: use parent_smb_fname() in non_widelink_open()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 61bf5410f0eeb274a67f426811c2dae921626452
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:23:07 2020 +0200

    smbd: use parent_smb_fname() in check_parent_access()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 58a995931d742bf76d7fd38b5ab87444c29972a5
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:11:38 2020 +0200

    smbd: use parent_smb_fname() in copy_internals()
    
    Prepares for converting file_set_dosmode() to struct smb_filename.
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit c0a9c8698c21b72e3409af9263e2afa16443f805
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 16:00:42 2020 +0200

    smbd: use parent_smb_fname() in unix_convert()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 3cc0dcad35c0a3fea5e44045d3a241f0d0bffc32
Author: Ralph Boehme <[email protected]>
Date:   Wed Apr 29 15:43:30 2020 +0200

    smbd: use synthetic_smb_fname() in check_parent_exists()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 4d1ba69abad08262c71461a6b660c7589d40d596
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 15:21:37 2020 +0200

    smbd: use parent_smb_fname() in can_delete_file_in_directory()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit aa125a7d3689c7707e21a52b67ce4ec33cc0454c
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 15:01:59 2020 +0200

    vfs_linux_xfs_sgid: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 259857038b6c95d233cc71dfbf295d454dc8a619
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 14:47:40 2020 +0200

    vfs_gpfs: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 036ed35b3bba237f68fec2f1c16173bec729474e
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 14:43:20 2020 +0200

    vfs_default: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 8bd6908baef37015c2123d75f014509069ae6eb9
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 14:41:21 2020 +0200

    vfs_ceph: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 7f68944acdfe5cee44f2329f5a581cad7ee430f6
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 14:28:32 2020 +0200

    vfs_aio_pthread: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit eafd4160b0deef36dd86c692b8980970790b50e2
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 14:15:38 2020 +0200

    vfs_acl_common: use parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

commit 5fe180e751093bb10f847137f879a961db245689
Author: Ralph Boehme <[email protected]>
Date:   Tue Apr 28 12:55:26 2020 +0200

    s3/lib: add parent_smb_fname()
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Jeremy Allison <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h              |   4 +
 source3/include/vfs.h                |   1 +
 source3/lib/filename_util.c          |  64 +++++++++++++
 source3/modules/vfs_acl_common.c     |  36 +++----
 source3/modules/vfs_aio_pthread.c    |  46 +++++----
 source3/modules/vfs_ceph.c           |  18 ++--
 source3/modules/vfs_default.c        |  15 +--
 source3/modules/vfs_gpfs.c           |  21 +++--
 source3/modules/vfs_linux_xfs_sgid.c |  57 ++++++-----
 source3/smbd/close.c                 |   6 +-
 source3/smbd/dir.c                   |  19 ++--
 source3/smbd/dosmode.c               |  35 +++----
 source3/smbd/file_access.c           |  31 ++----
 source3/smbd/filename.c              |  50 ++++++----
 source3/smbd/nttrans.c               |  11 ++-
 source3/smbd/open.c                  | 178 ++++++++++++++---------------------
 source3/smbd/posix_acls.c            |  16 +---
 source3/smbd/proto.h                 |  22 +++--
 source3/smbd/reply.c                 |  23 ++---
 source3/smbd/trans2.c                |  17 +++-
 source3/smbd/vfs.c                   |  94 +++++++++---------
 21 files changed, 401 insertions(+), 363 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6ac0c3d1935..0fd6e64fee3 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -392,6 +392,10 @@ char *myhostname_upper(void);
 #include "lib/util_path.h"
 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
                    const char **name);
+bool parent_smb_fname(TALLOC_CTX *mem_ctx,
+                     const struct smb_filename *path,
+                     struct smb_filename **_parent,
+                     struct smb_filename  **_name);
 bool ms_has_wild(const char *s);
 bool ms_has_wild_w(const smb_ucs2_t *s);
 bool mask_match(const char *string, const char *pattern, bool 
is_case_sensitive);
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index d0151213b0e..ce969747546 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -655,6 +655,7 @@ struct smb_filename {
        char *stream_name;
        uint32_t flags;
        SMB_STRUCT_STAT st;
+       NTTIME twrp;
 };
 
 /*
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index 1f2e4d31072..37dc6554018 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -225,9 +225,73 @@ struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
        }
        out->flags = in->flags;
        out->st = in->st;
+       out->twrp = in->twrp;
        return out;
 }
 
+/**
+ * Return allocated parent directory and basename of path
+ *
+ * Note: if requesting name, it is returned as talloc child of the
+ * parent. Freeing the parent is thus sufficient to free both.
+ */
+bool parent_smb_fname(TALLOC_CTX *mem_ctx,
+                     const struct smb_filename *path,
+                     struct smb_filename **_parent,
+                     struct smb_filename  **_name)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       struct smb_filename *parent = NULL;
+       struct smb_filename *name = NULL;
+       char *p = NULL;
+
+       parent = cp_smb_filename(frame, path);
+       if (parent == NULL) {
+               TALLOC_FREE(frame);
+               return false;
+       }
+       TALLOC_FREE(parent->stream_name);
+       SET_STAT_INVALID(parent->st);
+
+       p = strrchr_m(parent->base_name, '/'); /* Find final '/', if any */
+       if (p == NULL) {
+               TALLOC_FREE(parent->base_name);
+               parent->base_name = talloc_strdup(parent, ".");
+               if (parent->base_name == NULL) {
+                       TALLOC_FREE(frame);
+                       return false;
+               }
+               p = path->base_name;
+       } else {
+               *p = '\0';
+               p++;
+       }
+
+       if (_name == NULL) {
+               *_parent = talloc_move(mem_ctx, &parent);
+               TALLOC_FREE(frame);
+               return true;
+       }
+
+       name = cp_smb_filename(frame, path);
+       if (name == NULL) {
+               TALLOC_FREE(frame);
+               return false;
+       }
+       TALLOC_FREE(name->base_name);
+
+       name->base_name = talloc_strdup(mem_ctx, p);
+       if (name == NULL) {
+               TALLOC_FREE(frame);
+               return false;
+       }
+
+       *_parent = talloc_move(mem_ctx, &parent);
+       *_name = talloc_move(*_parent, &name);
+       TALLOC_FREE(frame);
+       return true;
+}
+
 static void assert_valid_stream_smb_fname(const struct smb_filename *smb_fname)
 {
        /* stream_name must always be NULL if there is no stream. */
diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c
index 7bed255d390..43167be77a3 100644
--- a/source3/modules/vfs_acl_common.c
+++ b/source3/modules/vfs_acl_common.c
@@ -1092,12 +1092,11 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
        struct file_id id;
        files_struct *fsp = NULL;
        int ret = 0;
-       char *parent_dir = NULL;
-       const char *final_component = NULL;
-       struct smb_filename local_fname = {0};
-       struct smb_filename parent_dir_fname = {0};
+       struct smb_filename *local_fname = NULL;
+       struct smb_filename *parent_dir_fname = NULL;
        int saved_errno = 0;
        struct smb_filename *saved_dir_fname = NULL;
+       bool ok;
 
        saved_dir_fname = vfs_GetWd(talloc_tos(),conn);
        if (saved_dir_fname == NULL) {
@@ -1105,35 +1104,35 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
                goto out;
        }
 
-       if (!parent_dirname(talloc_tos(), smb_fname->base_name,
-                       &parent_dir, &final_component)) {
+       ok = parent_smb_fname(talloc_tos(),
+                             smb_fname,
+                             &parent_dir_fname,
+                             &local_fname);
+       if (!ok) {
                saved_errno = ENOMEM;
                goto out;
        }
 
        DBG_DEBUG("removing %s %s/%s\n", is_directory ? "directory" : "file",
-                 parent_dir, final_component);
-
-       parent_dir_fname = (struct smb_filename) { .base_name = parent_dir };
+                 smb_fname_str_dbg(parent_dir_fname),
+                 smb_fname_str_dbg(local_fname));
 
        /* cd into the parent dir to pin it. */
-       ret = vfs_ChDir(conn, &parent_dir_fname);
+       ret = vfs_ChDir(conn, parent_dir_fname);
        if (ret == -1) {
                saved_errno = errno;
                goto out;
        }
 
-       local_fname.base_name = discard_const_p(char, final_component);
-
        /* Must use lstat here. */
-       ret = SMB_VFS_LSTAT(conn, &local_fname);
+       ret = SMB_VFS_LSTAT(conn, local_fname);
        if (ret == -1) {
                saved_errno = errno;
                goto out;
        }
 
        /* Ensure we have this file open with DELETE access. */
-       id = vfs_file_id_from_sbuf(conn, &local_fname.st);
+       id = vfs_file_id_from_sbuf(conn, &local_fname->st);
        for (fsp = file_find_di_first(conn->sconn, id); fsp;
                     fsp = file_find_di_next(fsp)) {
                if (fsp->access_mask & DELETE_ACCESS &&
@@ -1149,7 +1148,8 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
        if (!fsp) {
                DBG_DEBUG("%s %s/%s not an open file\n",
                          is_directory ? "directory" : "file",
-                         parent_dir, final_component);
+                         smb_fname_str_dbg(parent_dir_fname),
+                         smb_fname_str_dbg(local_fname));
                saved_errno = EACCES;
                goto out;
        }
@@ -1158,12 +1158,12 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
        if (is_directory) {
                ret = SMB_VFS_NEXT_UNLINKAT(handle,
                                conn->cwd_fsp,
-                               &local_fname,
+                               local_fname,
                                AT_REMOVEDIR);
        } else {
                ret = SMB_VFS_NEXT_UNLINKAT(handle,
                                conn->cwd_fsp,
-                               &local_fname,
+                               local_fname,
                                0);
        }
        unbecome_root();
@@ -1174,7 +1174,7 @@ static int acl_common_remove_object(vfs_handle_struct 
*handle,
 
   out:
 
-       TALLOC_FREE(parent_dir);
+       TALLOC_FREE(parent_dir_fname);
 
        if (saved_dir_fname) {
                vfs_ChDir(conn, saved_dir_fname);
diff --git a/source3/modules/vfs_aio_pthread.c 
b/source3/modules/vfs_aio_pthread.c
index 1ccf89a6d8c..45b59bcb813 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -48,8 +48,8 @@ struct aio_open_private_data {
        mode_t mode;
        uint64_t mid;
        bool in_progress;
-       const char *fname;
-       char *dname;
+       struct smb_filename *dname;
+       struct smb_filename *fname;
        connection_struct *conn;
        struct smbXsrv_connection *xconn;
        const struct security_unix_token *ux_tok;
@@ -111,8 +111,8 @@ static void aio_open_handle_completion(struct tevent_req 
*subreq)
                 * don't leak memory.
                 */
                DBG_NOTICE("aio open request for %s/%s abandoned in flight\n",
-                       opd->dname,
-                       opd->fname);
+                       opd->dname->base_name,
+                       opd->fname->base_name);
                if (opd->ret_fd != -1) {
                        close(opd->ret_fd);
                        opd->ret_fd = -1;
@@ -154,8 +154,8 @@ static void aio_open_handle_completion(struct tevent_req 
*subreq)
        DEBUG(10,("aio_open_handle_completion: mid %llu "
                "for file %s/%s completed\n",
                (unsigned long long)opd->mid,
-               opd->dname,
-               opd->fname));
+               opd->dname->base_name,
+               opd->fname->base_name));
 
        opd->in_progress = false;
 
@@ -202,7 +202,7 @@ static void aio_open_worker(void *private_data)
 static void aio_open_do(struct aio_open_private_data *opd)
 {
        opd->ret_fd = openat(opd->dir_fd,
-                       opd->fname,
+                       opd->fname->base_name,
                        opd->flags,
                        opd->mode);
 
@@ -255,7 +255,7 @@ static struct aio_open_private_data 
*create_private_open_data(TALLOC_CTX *ctx,
 {
        struct aio_open_private_data *opd = talloc_zero(ctx,
                                        struct aio_open_private_data);
-       const char *fname = NULL;
+       bool ok;
 
        if (!opd) {
                return NULL;
@@ -290,23 +290,19 @@ static struct aio_open_private_data 
*create_private_open_data(TALLOC_CTX *ctx,
         * Copy the parent directory name and the
         * relative path within it.
         */
-       if (parent_dirname(opd,
-                       fsp->fsp_name->base_name,
-                       &opd->dname,
-                       &fname) == false) {
-               opd_free(opd);
-               return NULL;
-       }
-       opd->fname = talloc_strdup(opd, fname);
-       if (opd->fname == NULL) {
+       ok = parent_smb_fname(opd,
+                             fsp->fsp_name,
+                             &opd->dname,
+                             &opd->fname);
+       if (!ok) {
                opd_free(opd);
                return NULL;
        }
 
 #if defined(O_DIRECTORY)
-       opd->dir_fd = open(opd->dname, O_RDONLY|O_DIRECTORY);
+       opd->dir_fd = open(opd->dname->base_name, O_RDONLY|O_DIRECTORY);
 #else
-       opd->dir_fd = open(opd->dname, O_RDONLY);
+       opd->dir_fd = open(opd->dname->base_name, O_RDONLY);
 #endif
        if (opd->dir_fd == -1) {
                opd_free(opd);
@@ -326,8 +322,8 @@ static int opd_inflight_destructor(struct 
aio_open_private_data *opd)
         * opd.
         */
        DBG_NOTICE("aio open request for %s/%s cancelled\n",
-               opd->dname,
-               opd->fname);
+               opd->dname->base_name,
+               opd->fname->base_name);
        opd->conn = NULL;
        /* Don't let opd go away. */
        return -1;
@@ -373,8 +369,8 @@ static int open_async(const files_struct *fsp,
 
        DEBUG(5,("open_async: mid %llu created for file %s/%s\n",
                (unsigned long long)opd->mid,
-               opd->dname,
-               opd->fname));
+               opd->dname->base_name,
+               opd->fname->base_name));
 
        /*
         * Add a destructor to protect us from connection
@@ -408,8 +404,8 @@ static bool find_completed_open(files_struct *fsp,
                        "still in progress for "
                        "file %s/%s. PANIC !\n",
                        (unsigned long long)opd->mid,
-                       opd->dname,
-                       opd->fname));
+                       opd->dname->base_name,
+                       opd->fname->base_name));
                /* Disaster ! This is an open timeout. Just panic. */
                smb_panic("find_completed_open - in_progress\n");
                /* notreached. */
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 7f4d65d4871..166fdc9feee 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -355,22 +355,24 @@ static int cephwrap_mkdirat(struct vfs_handle_struct 
*handle,
                        mode_t mode)
 {
        int result;
-       char *parent = NULL;
-       const char *path = smb_fname->base_name;
+       struct smb_filename *parent = NULL;
+       bool ok;
 
-       DBG_DEBUG("[CEPH] mkdir(%p, %s)\n", handle, path);
+       DBG_DEBUG("[CEPH] mkdir(%p, %s)\n",
+                 handle, smb_fname_str_dbg(smb_fname));
 
        SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
 
-       if (lp_inherit_acls(SNUM(handle->conn))
-           && parent_dirname(talloc_tos(), path, &parent, NULL)
-           && directory_has_default_acl(handle->conn, parent)) {
-               mode = 0777;
+       if (lp_inherit_acls(SNUM(handle->conn))) {
+               ok = parent_smb_fname(talloc_tos(), smb_fname, &parent, NULL);
+               if (ok && directory_has_default_acl(handle->conn, parent)) {
+                       mode = 0777;
+               }
        }
 
        TALLOC_FREE(parent);
 
-       result = ceph_mkdir(handle->data, path, mode);
+       result = ceph_mkdir(handle->data, smb_fname->base_name, mode);
        return WRAP_RETURN(result);
 }
 
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 2a7e04f79d1..a739b17963a 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -628,22 +628,23 @@ static int vfswrap_mkdirat(vfs_handle_struct *handle,
                        mode_t mode)
 {
        int result;
-       const char *path = smb_fname->base_name;
-       char *parent = NULL;
+       struct smb_filename *parent = NULL;
+       bool ok;
 
        START_PROFILE(syscall_mkdirat);
 
        SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
 
-       if (lp_inherit_acls(SNUM(handle->conn))
-           && parent_dirname(talloc_tos(), path, &parent, NULL)
-           && directory_has_default_acl(handle->conn, parent)) {
-               mode = (0777 & lp_directory_mask(SNUM(handle->conn)));
+       if (lp_inherit_acls(SNUM(handle->conn))) {
+               ok = parent_smb_fname(talloc_tos(), smb_fname, &parent, NULL);
+               if (ok && directory_has_default_acl(handle->conn, parent)) {
+                       mode = (0777 & lp_directory_mask(SNUM(handle->conn)));
+               }
        }
 
        TALLOC_FREE(parent);
 
-       result = mkdirat(dirfsp->fh->fd, path, mode);
+       result = mkdirat(dirfsp->fh->fd, smb_fname->base_name, mode);
 
        END_PROFILE(syscall_mkdirat);
        return result;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 26b2c52ba98..4014e92ada2 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1895,29 +1895,32 @@ static int stat_with_capability(struct 
vfs_handle_struct *handle,
 {
 #if defined(HAVE_FSTATAT)
        int fd = -1;
-       bool b;
-       char *dir_name;
-       const char *rel_name = NULL;
+       bool ok;
+       struct smb_filename *dir_name = NULL;
+       struct smb_filename *rel_name = NULL;
        struct stat st;
        int ret = -1;
 
-       b = parent_dirname(talloc_tos(), smb_fname->base_name,
-                          &dir_name, &rel_name);
-       if (!b) {
+       ok = parent_smb_fname(talloc_tos(),
+                             smb_fname,
+                             &dir_name,
+                             &rel_name);
+       if (!ok) {
                errno = ENOMEM;
                return -1;
        }
 
-       fd = open(dir_name, O_RDONLY, 0);
-       TALLOC_FREE(dir_name);
+       fd = open(dir_name->base_name, O_RDONLY, 0);
        if (fd == -1) {
+               TALLOC_FREE(dir_name);
                return -1;
        }
 
        set_effective_capability(DAC_OVERRIDE_CAPABILITY);
-       ret = fstatat(fd, rel_name, &st, flag);
+       ret = fstatat(fd, rel_name->base_name, &st, flag);
        drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
 
+       TALLOC_FREE(dir_name);
        close(fd);
 
        if (ret == 0) {
diff --git a/source3/modules/vfs_linux_xfs_sgid.c 
b/source3/modules/vfs_linux_xfs_sgid.c
index 2d62b299e1a..f112f119fae 100644
--- a/source3/modules/vfs_linux_xfs_sgid.c
+++ b/source3/modules/vfs_linux_xfs_sgid.c
@@ -27,9 +27,11 @@ static int linux_xfs_sgid_mkdirat(vfs_handle_struct *handle,
                const struct smb_filename *smb_fname,
                mode_t mode)
 {
-       struct smb_filename fname = { 0, };
+       struct smb_filename *dname = NULL;
+       struct smb_filename *fname = NULL;
        int mkdir_res;
        int res;
+       bool ok;
 
        DEBUG(10, ("Calling linux_xfs_sgid_mkdirat(%s)\n",
                smb_fname->base_name));
@@ -44,41 +46,47 @@ static int linux_xfs_sgid_mkdirat(vfs_handle_struct *handle,
                return mkdir_res;
        }
 
-       if (!parent_dirname(talloc_tos(),
-                       smb_fname->base_name,
-                       &fname.base_name,
-                       NULL)) {
-               DEBUG(1, ("parent_dirname failed\n"));
+       ok = parent_smb_fname(talloc_tos(), smb_fname, &dname, NULL);
+       if (!ok) {
+               DBG_WARNING("parent_smb_fname() failed\n");
                /* return success, we did the mkdir */
                return mkdir_res;
        }
 
-       res = SMB_VFS_NEXT_STAT(handle, &fname);
+       res = SMB_VFS_NEXT_STAT(handle, dname);
        if (res == -1) {
-               DEBUG(10, ("NEXT_STAT(%s) failed: %s\n", fname.base_name,
-                          strerror(errno)));
+               DBG_DEBUG("NEXT_STAT(%s) failed: %s\n",
+                         smb_fname_str_dbg(dname),
+                         strerror(errno));
                /* return success, we did the mkdir */
                return mkdir_res;
        }
-       TALLOC_FREE(fname.base_name);
-       if ((fname.st.st_ex_mode & S_ISGID) == 0) {
+       if ((dname->st.st_ex_mode & S_ISGID) == 0) {
                /* No SGID to inherit */
                DEBUG(10, ("No SGID to inherit\n"));
+               TALLOC_FREE(dname);
                return mkdir_res;
        }
+       TALLOC_FREE(dname);
 
-       fname.base_name = discard_const_p(char, smb_fname->base_name);
+       fname = cp_smb_filename(talloc_tos(), smb_fname);
+       if (fname == NULL) {
+               DBG_WARNING("cp_smb_filename() failed\n");


-- 
Samba Shared Repository

Reply via email to