Fix bug 7950 - Samba 3.5.x fails BASE-CREATEX_SHAREMODES_DIR smbtorture4 test
authorJeremy Allison <jra@samba.org>
Thu, 24 Feb 2011 02:24:41 +0000 (18:24 -0800)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:54 +0000 (14:34 +0100)
We need to revalidate the pathname once re-constructed from a root fsp.

Jeremy.
(cherry picked from commit 916e82823b56a70d7761644b38a250ea8c38e204)
(cherry picked from commit 203b4aa318ce2aa64812006ed94a1e4e1becf66f)

source3/include/proto.h
source3/modules/onefs_open.c
source3/smbd/open.c

index ce33b7082a24fbe1ea29a64143323b2627fcd27f..ef80b927dd8838d298bf1e20ffe9a95878db89f5 100644 (file)
@@ -6663,7 +6663,8 @@ NTSTATUS create_file_default(connection_struct *conn,
 NTSTATUS get_relative_fid_filename(connection_struct *conn,
                                   struct smb_request *req,
                                   uint16_t root_dir_fid,
-                                  struct smb_filename *smb_fname);
+                                  const struct smb_filename *smb_fname,
+                                  struct smb_filename **smb_fname_out);
 
 /* The following definitions come from smbd/oplock.c  */
 
index 2b4e106f910630be6e8fcb7e45cc1479f0cc5f3f..a3b919fac69a228d5f528f526004aee773150c59 100644 (file)
@@ -2094,11 +2094,13 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
 
        /* Get the file name if root_dir_fid was specified. */
        if (root_dir_fid != 0) {
+               struct smb_filename *smb_fname_out = NULL;
                status = get_relative_fid_filename(conn, req, root_dir_fid,
-                                                  smb_fname);
+                                                  smb_fname, &smb_fname_out);
                if (!NT_STATUS_IS_OK(status)) {
                        goto fail;
                }
+               smb_fname = smb_fname_out;
        }
 
        /* All file access must go through check_name() */
index f7ed495446345cd0b8e91934d5c3e95a9977ec68..bd748f9661af75a2c49b6f3c212232aaf7d89502 100644 (file)
@@ -3233,7 +3233,8 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
 NTSTATUS get_relative_fid_filename(connection_struct *conn,
                                   struct smb_request *req,
                                   uint16_t root_dir_fid,
-                                  struct smb_filename *smb_fname)
+                                  const struct smb_filename *smb_fname,
+                                  struct smb_filename **smb_fname_out)
 {
        files_struct *dir_fsp;
        char *parent_fname = NULL;
@@ -3321,16 +3322,23 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
                }
        }
 
-       new_base_name = talloc_asprintf(smb_fname, "%s%s", parent_fname,
+       new_base_name = talloc_asprintf(talloc_tos(), "%s%s", parent_fname,
                                        smb_fname->base_name);
        if (new_base_name == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto out;
        }
 
-       TALLOC_FREE(smb_fname->base_name);
-       smb_fname->base_name = new_base_name;
-       status = NT_STATUS_OK;
+       status = filename_convert(req,
+                               conn,
+                               req->flags2 & FLAGS2_DFS_PATHNAMES,
+                               new_base_name,
+                               0,
+                               NULL,
+                               smb_fname_out);
+       if (!NT_STATUS_IS_OK(status)) {
+               goto out;
+       }
 
  out:
        TALLOC_FREE(parent_fname);
@@ -3377,11 +3385,13 @@ NTSTATUS create_file_default(connection_struct *conn,
         */
 
        if (root_dir_fid != 0) {
+               struct smb_filename *smb_fname_out = NULL;
                status = get_relative_fid_filename(conn, req, root_dir_fid,
-                                                  smb_fname);
+                                                  smb_fname, &smb_fname_out);
                if (!NT_STATUS_IS_OK(status)) {
                        goto fail;
                }
+               smb_fname = smb_fname_out;
        }
 
        /*