s3: smbd: Remove bool dfs_pathnames paramter from resolve_dfspath_wcard().
authorJeremy Allison <jra@samba.org>
Thu, 18 May 2017 18:34:33 +0000 (11:34 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 22 May 2017 16:41:15 +0000 (18:41 +0200)
Start cleaning up the pathname parsing to move flags2 checks into UCF_FLAGS
function.

NB. This now only sets *ppath_contains_wcard inside resolve_dfspath_wcard()
if dfs_redirect() sets path_contains_wcard to true, which is a change
from the previous code which could potentially set *ppath_contains_wcard
to an uninitialized value if dfs_redirect() returned without setting
path_contains_wcard.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/smbd/filename.c
source3/smbd/msdfs.c
source3/smbd/proto.h
source3/smbd/trans2.c

index 2d85e8de0b550df4483bee384eabd20d0aa49aad..174f0b057a6c31415cf9810c4986611a9501f937 100644 (file)
@@ -1550,19 +1550,22 @@ static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
 
        *pp_smb_fname = NULL;
 
-       status = resolve_dfspath_wcard(ctx, conn,
-                               dfs_path,
+       if (dfs_path) {
+               status = resolve_dfspath_wcard(ctx, conn,
                                name_in,
                                ucf_flags,
                                !conn->sconn->using_smb2,
                                &fname,
                                ppath_contains_wcard);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10,("filename_convert_internal: resolve_dfspath failed "
-                       "for name %s with %s\n",
-                       name_in,
-                       nt_errstr(status) ));
-               return status;
+               if (!NT_STATUS_IS_OK(status)) {
+                       DEBUG(10,("filename_convert_internal: resolve_dfspath "
+                               "failed for name %s with %s\n",
+                               name_in,
+                               nt_errstr(status) ));
+                       return status;
+               }
+       } else {
+               fname = discard_const_p(char, name_in);
        }
 
        if (is_fake_file_path(name_in)) {
index 61538cec8329447d02e891d9db091de3d0e1c19e..c22cd1e77b85aab6d92a29113b0717c74fb3128c 100644 (file)
@@ -1669,35 +1669,27 @@ struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn)
 
 NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
                                connection_struct *conn,
-                               bool dfs_pathnames,
                                const char *name_in,
                                uint32_t ucf_flags,
                                bool allow_broken_path,
                                char **pp_name_out,
                                bool *ppath_contains_wcard)
 {
-       bool path_contains_wcard;
+       bool path_contains_wcard = false;
        NTSTATUS status = NT_STATUS_OK;
 
-       if (dfs_pathnames) {
-               status = dfs_redirect(ctx,
-                                       conn,
-                                       name_in,
-                                       ucf_flags,
-                                       allow_broken_path,
-                                       pp_name_out,
-                                       &path_contains_wcard);
-
-               if (NT_STATUS_IS_OK(status) && ppath_contains_wcard != NULL) {
-                       *ppath_contains_wcard = path_contains_wcard;
-               }
-       } else {
-               /*
-                * Cheat and just return a copy of the in ptr.
-                * Once srvstr_get_path() uses talloc it'll
-                * be a talloced ptr anyway.
-                */
-               *pp_name_out = discard_const_p(char, name_in);
+       status = dfs_redirect(ctx,
+                               conn,
+                               name_in,
+                               ucf_flags,
+                               allow_broken_path,
+                               pp_name_out,
+                               &path_contains_wcard);
+
+       if (NT_STATUS_IS_OK(status) &&
+                               ppath_contains_wcard != NULL &&
+                               path_contains_wcard) {
+               *ppath_contains_wcard = path_contains_wcard;
        }
        return status;
 }
index 19abf7e044943c6ca84395d8543a551b0c861901..770c3c24994933c2ac1414f910dc1c2210761130 100644 (file)
@@ -490,7 +490,6 @@ bool remove_msdfs_link(const struct junction_map *jucn);
 struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
 NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
                                connection_struct *conn,
-                               bool dfs_pathnames,
                                const char *name_in,
                                uint32_t ucf_flags,
                                bool allow_broken_path,
index 01df2ee0d86c3301d4c6815ebbf55f52a3a374d6..14f605210999f3886850abfd788db4db4bcc91e6 100644 (file)
@@ -6968,15 +6968,16 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
        DEBUG(10,("smb_file_rename_information: got name |%s|\n",
                                newname));
 
-       status = resolve_dfspath_wcard(ctx, conn,
-                                      req->flags2 & FLAGS2_DFS_PATHNAMES,
+       if (req->flags2 & FLAGS2_DFS_PATHNAMES) {
+               status = resolve_dfspath_wcard(ctx, conn,
                                       newname,
                                       UCF_COND_ALLOW_WCARD_LCOMP,
                                       !conn->sconn->using_smb2,
                                       &newname,
                                       &dest_has_wcard);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
        }
 
        /* Check the new name has no '/' characters. */