[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Sat Dec 11 08:08:01 UTC 2021


The branch, master has been updated
       via  25c87b70c07 s3: smbd: Remove 'struct uc_state' name_has_wildcard element.
       via  0ecb5e3e3fb s3: smbd: In unix_convert_step_stat() remove use of state->name_was_wildcard.
       via  e6f0269817e s3: smbd: In unix_convert_step() remove all use of 'state->name_was_wildcard'
       via  ce6b3ba4099 s3: smbd: In unix_convert() remove the now unneeded block indentation.
       via  b21ba035bf3 s3: smbd: In unix_convert(), remove all references to state->name_has_wildcard.
       via  1d52a4a4677 s3: smbd: Inside unix_convert(), never set state->name_is_wildcard.
       via  6493d39b679 s3: smbd: UCF_ALWAYS_ALLOW_WCARD_LCOMP 0x00000002 is no longer used.
       via  6f15f8b68a5 s3: smbd: We no longer need determine_path_error().
       via  e1cc3e3a673 s3: smbd: Inside 'struct uc_state', remove allow_wcard_last_component.
       via  da1417fb37b s3: smbd: filename_convert() no longer deals with wildcards.
       via  24002be5883 s3: smbd: parse_dfs_path() can ignore wildcards.
       via  52ca4bf6d5a s3: smbd: Remove 'bool search_wcard_flag' from parse_dfs_path().
       via  18125747483 s3: smbd: dfs_path_lookup() no longer deals with wildcards.
       via  fa45c91cb45 s3: smbd: Fix call_trans2findfirst() to use filename_convert_smb1_search_path().
       via  1658fad32cb s3: smbd: Convert reply_search() to use filename_convert_smb1_search_path().
       via  3ca82218643 s3: smbd: Add filename_convert_smb1_search_path() - deals with SMB1 search pathnames.
       via  addbf4cc3ba s3: smbd: Allow dfs_redirect() to return a TWRP token it got from a parsed pathname.
       via  a568e92e51a s3: smbd: In dfs_path_lookup(). If we have a DFS path including a @GMT-token, don't throw away the twrp value when parsing the path.
       via  14e0dd43d56 s3: smbd: filename_convert() is now a one-to-one wrapper around filename_convert_internal().
       via  5425f2aa43d s3: smbd: Remove now unused check_reduced_name_with_privilege().
       via  02f840308d5 s3: smbd: Remove unused check_name_with_privilege().
       via  b18c2abae99 s3: smbd: In filename_convert_internal(), remove call to check_name_with_privilege().
       via  59b7101ac9e s3: smbd: Remove filename_convert_with_privilege(). No longer used.
       via  18a1cc632b4 s3: smbd: In call_trans2findfirst() we don't need filename_convert_with_privilege() anymore.
       via  a3acb8698bb s3: smbd: Remove split_fname_dir_mask().
       via  a325cb09552 s3: smbd: In rename_internals(), remove the name spliting and re-combining code.
       via  449aa4153a6 s3: smbd: check_name() is now static to filename.c
       via  07df94ade1e s3: smbd: In rename_internals_fsp(), remove unneeded call to check_name().
       via  d58b9094f7b s3: smbd: Handling SMB_FILE_RENAME_INFORMATION, the destination name is a single component.
       via  6db08012e99 s3: smbd: Remove the old unlink_internals() implementation.
       via  b2a0664d4c1 s3: smbd: Comment out the old unlink_internals(). Rename do_unlink() -> unlink_internals().
       via  e60360c4868 s3: smbd: Move to modern debug calls inside do_unlink().
       via  0333348239d s3: smbd: Move setting of dirtype if FILE_ATTRIBUTE_NORMAL to do_unlink().
      from  f7e1a81cc05 s3:torture: Initialize pointer with NULL

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


- Log -----------------------------------------------------------------
commit 25c87b70c07647896c9e7c4c1132835dbe318b61
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 13:06:27 2021 -0800

    s3: smbd: Remove 'struct uc_state' name_has_wildcard element.
    
    It is never set or looked at.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Sat Dec 11 08:07:14 UTC 2021 on sn-devel-184

commit 0ecb5e3e3fb45c119c9cb933cc8479b6d33de1ad
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 13:05:55 2021 -0800

    s3: smbd: In unix_convert_step_stat() remove use of state->name_was_wildcard.
    
    It can never be true.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit e6f0269817ef121f55b212bcec8ed9fad40a6ffd
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 13:03:47 2021 -0800

    s3: smbd: In unix_convert_step() remove all use of 'state->name_was_wildcard'
    
    We know it is never true.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ce6b3ba4099cf1fd35ccd5b85c59f1e76918fb3b
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 12:59:50 2021 -0800

    s3: smbd: In unix_convert() remove the now unneeded block indentation.
    
    We removed the 'if (state->name_has_wildcard) {' clause, so
    the block no longer needs indenting.
    
    Best seen with git show -b.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b21ba035bf364400c74385c1364ea93387903c7f
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 12:55:41 2021 -0800

    s3: smbd: In unix_convert(), remove all references to state->name_has_wildcard.
    
    It is never set.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 1d52a4a46779244950f7ca911364b92166117b4b
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 12:53:36 2021 -0800

    s3: smbd: Inside unix_convert(), never set state->name_is_wildcard.
    
    We error out immediately if it's set anyway.
    Preparing to remove 'state->name_is_wildcard' structure element.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 6493d39b6796a7997c078902e7dcf71493bf8d9c
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 12:40:43 2021 -0800

    s3: smbd: UCF_ALWAYS_ALLOW_WCARD_LCOMP 0x00000002 is no longer used.
    
    Hurrah !
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 6f15f8b68a56fca559604a83d30b659b301d2a43
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 12:37:15 2021 -0800

    s3: smbd: We no longer need determine_path_error().
    
    Now we don't have to consider wildcards just
    return NT_STATUS_OBJECT_PATH_NOT_FOUND for
    the cases we used to call it.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit e1cc3e3a6737d8c238abd111264dd6c3490ddc9a
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:33:42 2021 -0800

    s3: smbd: Inside 'struct uc_state', remove allow_wcard_last_component.
    
    This is never allowed.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit da1417fb37b88b975c22dba8276723e05f2ea282
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:30:42 2021 -0800

    s3: smbd: filename_convert() no longer deals with wildcards.
    
    These are already errored out with NT_STATUS_OBJECT_NAME_INVALID
    in the unix_convert() code.
    
    Remove the check.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 24002be5883692fa6a586f66bf46f30cee72d4ba
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:48:23 2021 -0800

    s3: smbd: parse_dfs_path() can ignore wildcards.
    
    If one is passed to filename_convert(), it will error out there
    with NT_STATUS_OBJECT_NAME_INVALID.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 52ca4bf6d5adcb4a40fb0b660779760c1f876cbd
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:42:23 2021 -0800

    s3: smbd: Remove 'bool search_wcard_flag' from parse_dfs_path().
    
    Never set.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 181257474833745c78de00a54daef3ac88d43719
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:31:40 2021 -0800

    s3: smbd: dfs_path_lookup() no longer deals with wildcards.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fa45c91cb45afc1a2e11e8569b4564d49000ae34
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:28:40 2021 -0800

    s3: smbd: Fix call_trans2findfirst() to use filename_convert_smb1_search_path().
    
    filename_convert() no longer has to handle wildcards.
    UCF_ALWAYS_ALLOW_WCARD_LCOMP is now unused.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 1658fad32cbc30f9bd9e5fa3620762f47821bf7b
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 11:22:03 2021 -0800

    s3: smbd: Convert reply_search() to use filename_convert_smb1_search_path().
    
    Cleans up this code path nicely !
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3ca822186435d917913f4163532ad5a0f306215f
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 10:35:09 2021 -0800

    s3: smbd: Add filename_convert_smb1_search_path() - deals with SMB1 search pathnames.
    
    SMB1search and trans2 findfirst are unique in that
    they are the only passed in pathnames that can contain
    a terminal wildcard component.
    
    Deal with these two special cases with this new function
    that strips off the terminal wildcard and returns as
    the mask, and pass the non-wildcard parent directory
    component through the standard filename_convert().
    
    Uses new helper function strip_gmt_from_raw_dfs().
    
    When SMB1search and trans2 findfirst have been
    converted to use this function, we can strip all
    wildcard handling out of filename_convert() as
    we now know it will only ever be given valid
    pathnames.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit addbf4cc3ba3a7a72c35118cf71bbed0e6d2c7f7
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 16:14:08 2021 -0800

    s3: smbd: Allow dfs_redirect() to return a TWRP token it got from a parsed pathname.
    
    This one is subtle. If an SMB1 request has both a DFS path and a @GMT token,
    the unix_convert() inside the DFS path processing will remove the @GMT
    token, not allowing the subsequent unix_convert() inside filename_convert()
    to see it. By returning it from dfs_redirect() we can ensure it's correctly
    added to the smb_filename returned from filename_convert().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a568e92e51a7229a3a370daa95f066413ab2b293
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 16:00:26 2021 -0800

    s3: smbd: In dfs_path_lookup(). If we have a DFS path including a @GMT-token, don't throw away the twrp value when parsing the path.
    
    Not yet used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 14e0dd43d56f5daad12af87a373db78d2b2a709a
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 10:19:38 2021 -0800

    s3: smbd: filename_convert() is now a one-to-one wrapper around filename_convert_internal().
    
    Remove filename_convert() and rename filename_convert_internal() -> filename_convert().
    Move the old DEBUG(..) statements to DBG_XXX() so they don't print the wrong name.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 5425f2aa43d289b3fc57d55441992500e6cf6661
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 10:14:03 2021 -0800

    s3: smbd: Remove now unused check_reduced_name_with_privilege().
    
    We now only have one function that does this check (check_reduced_name()),
    used everywhere.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 02f840308d5e265eab7dcc90029f7defb3f79809
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 10:13:13 2021 -0800

    s3: smbd: Remove unused check_name_with_privilege().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b18c2abae99563e411b0dd798e1c4a59e87c2ccc
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Dec 3 10:10:45 2021 -0800

    s3: smbd: In filename_convert_internal(), remove call to check_name_with_privilege().
    
    We now always pass NULL as struct smb_request *smbreq,
    so this code path can never be taken.
    
    Comment out check_name_with_privilege() as it's now
    no longer used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 59b7101ac9ebc001f3ad9f03b5607e1db577e9e4
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 2 17:55:26 2021 -0800

    s3: smbd: Remove filename_convert_with_privilege(). No longer used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 18a1cc632b4b799e0219554c8873024cb45f1b6a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 2 17:51:42 2021 -0800

    s3: smbd: In call_trans2findfirst() we don't need filename_convert_with_privilege() anymore.
    
    It was extra-paranoid code now not needed as the new VFS
    version of filename_convert() does the same job.
    
    There are now no remaining callers of filename_convert_with_privilege().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a3acb8698bb0f4fa00a0084ca66cd58b6561aa1a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:51:45 2021 -0800

    s3: smbd: Remove split_fname_dir_mask().
    
    No longer used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a325cb095527054a8b57a7ffe6c93052c6d2bd09
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:49:46 2021 -0800

    s3: smbd: In rename_internals(), remove the name spliting and re-combining code.
    
    filename_convert() handles mangled names just fine, so we don't
    need to split the last component and check for mangle.
    
    Now we don't take wildcard names this is not needed. This was the
    last caller of split_fname_dir_mask(), so ifdef it out.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 449aa4153a65177eb15f8dcb77f4a6615d5690b3
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:47:13 2021 -0800

    s3: smbd: check_name() is now static to filename.c
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 07df94ade1efaa4f261df672ebe6d460063338d6
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:45:13 2021 -0800

    s3: smbd: In rename_internals_fsp(), remove unneeded call to check_name().
    
    All callers have gone through filename_convert(), which has
    already called check_name() on the destination.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d58b9094f7bffec7b59f30229c8ee925fdd7581a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:35:17 2021 -0800

    s3: smbd: Handling SMB_FILE_RENAME_INFORMATION, the destination name is a single component.
    
    No errors should be allowed from filename_convert().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 6db08012e999b59cc92ae0ba9ac864d4bf59694d
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:16:52 2021 -0800

    s3: smbd: Remove the old unlink_internals() implementation.
    
    No longer used. filename_convert() already handles mangled
    names just fine, so we don't need this logic.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b2a0664d4c1a91e98e5b1c3b15480c157525280f
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:14:40 2021 -0800

    s3: smbd: Comment out the old unlink_internals(). Rename do_unlink() -> unlink_internals().
    
    One parameter needs changing position. The logic inside unlink_internals()
    is no longer needed if it doesn't accept wildcards. filename_convert()
    already handles mangled names just fine, so we don't need this logic.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit e60360c4868190633debc6bc31b98af2b74ad7cd
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:11:20 2021 -0800

    s3: smbd: Move to modern debug calls inside do_unlink().
    
    We will be changing its name next.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0333348239d422fe6a99aaaf4ac5cd9e32169e05
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Dec 9 16:08:07 2021 -0800

    s3: smbd: Move setting of dirtype if FILE_ATTRIBUTE_NORMAL to do_unlink().
    
    Now we don't use wildcards when calling in unlink_internals()
    the logic inside it serves no purpose and can be replaced with
    a direct call to do_unlink() (which we will rename to unlink_internals()).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 source3/smbd/filename.c | 635 +++++++++++++++++++++++++++---------------------
 source3/smbd/msdfs.c    |  30 +--
 source3/smbd/proto.h    |  18 +-
 source3/smbd/reply.c    | 279 +++------------------
 source3/smbd/smbd.h     |   2 +-
 source3/smbd/trans2.c   | 125 +---------
 source3/smbd/vfs.c      | 173 -------------
 7 files changed, 411 insertions(+), 851 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 6ea0687d763..19eea2d6a77 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -96,45 +96,6 @@ static bool mangled_equal(const char *name1,
 	return strequal(name1, mname);
 }
 
-/****************************************************************************
- Cope with the differing wildcard and non-wildcard error cases.
-****************************************************************************/
-
-static NTSTATUS determine_path_error(const char *name,
-			bool allow_wcard_last_component,
-			bool posix_pathnames)
-{
-	const char *p;
-	bool name_has_wild = false;
-
-	if (!allow_wcard_last_component) {
-		/* Error code within a pathname. */
-		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-	}
-
-	/* We're terminating here so we
-	 * can be a little slower and get
-	 * the error code right. Windows
-	 * treats the last part of the pathname
-	 * separately I think, so if the last
-	 * component is a wildcard then we treat
-	 * this ./ as "end of component" */
-
-	p = strchr(name, '/');
-
-	if (!posix_pathnames) {
-		name_has_wild = ms_has_wild(name);
-	}
-
-	if (!p && (name_has_wild || ISDOT(name))) {
-		/* Error code at the end of a pathname. */
-		return NT_STATUS_OBJECT_NAME_INVALID;
-	} else {
-		/* Error code within a pathname. */
-		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
-	}
-}
-
 static NTSTATUS check_for_dot_component(const struct smb_filename *smb_fname)
 {
 	/* Ensure we catch all names with in "/."
@@ -512,9 +473,6 @@ Note NT_STATUS_OK doesn't mean the name exists or is valid, just that we
 didn't get any fatal errors that should immediately terminate the calling SMB
 processing whilst resolving.
 
-If UCF_ALWAYS_ALLOW_WCARD_LCOMP is passed in, then a MS wildcard
-should be allowed in the last component of the path only.
-
 If the orig_path was a stream, smb_filename->base_name will point to the base
 filename, and smb_filename->stream_name will point to the stream name.  If
 orig_path was not a stream, then smb_filename->stream_name will be NULL.
@@ -536,9 +494,7 @@ struct uc_state {
 	char *dirpath;
 	char *stream;
 	bool component_was_mangled;
-	bool name_has_wildcard;
 	bool posix_pathnames;
-	bool allow_wcard_last_component;
 	bool done;
 	bool case_sensitive;
 	bool case_preserve;
@@ -731,8 +687,8 @@ static NTSTATUS unix_convert_step_stat(struct uc_state *state)
 	if (state->posix_pathnames) {
 		/*
 		 * For posix_pathnames, we're done.
-		 * Don't blunder into the name_has_wildcard OR
-		 * get_real_filename() codepaths as they may
+		 * Don't blunder into the
+		 * get_real_filename() codepath as they may
 		 * be doing case insensitive lookups. So when
 		 * creating a new POSIX directory Foo they might
 		 * match on name foo.
@@ -781,10 +737,6 @@ static NTSTATUS unix_convert_step_stat(struct uc_state *state)
 	 * Try to find this part of the path in the directory.
 	 */
 
-	if (state->name_has_wildcard) {
-		return unix_convert_step_search_fail(state);
-	}
-
 	dname = (struct smb_filename) {
 		.base_name = state->dirpath,
 		.twrp = state->smb_fname->twrp,
@@ -895,28 +847,7 @@ static NTSTATUS unix_convert_step(struct uc_state *state)
 			/* Error code at the end of a pathname. */
 			return NT_STATUS_OBJECT_NAME_INVALID;
 		}
-		return determine_path_error(state->end+1,
-					    state->allow_wcard_last_component,
-					    state->posix_pathnames);
-	}
-
-	/* The name cannot have a wildcard if it's not
-	   the last component. */
-
-	if (!state->posix_pathnames) {
-		state->name_has_wildcard = ms_has_wild(state->name);
-	}
-
-	/* Wildcards never valid within a pathname. */
-	if (state->name_has_wildcard && state->end != NULL) {
-		return NT_STATUS_OBJECT_NAME_INVALID;
-	}
-
-	/* Skip the stat call if it's a wildcard end. */
-	if (state->name_has_wildcard) {
-		DBG_DEBUG("Wildcard [%s]\n", state->name);
-		state->done = true;
-		return NT_STATUS_OK;
+		return NT_STATUS_OBJECT_PATH_NOT_FOUND;
 	}
 
 	status = unix_convert_step_stat(state);
@@ -951,9 +882,9 @@ static NTSTATUS unix_convert_step(struct uc_state *state)
 
 	/*
 	 * Cache the dirpath thus far. Don't cache a name with mangled
-	 * or wildcard components as this can change the size.
+	 * components as this can change the size.
 	 */
-	if(!state->component_was_mangled && !state->name_has_wildcard) {
+	if(!state->component_was_mangled) {
 		stat_cache_add(state->orig_path,
 			       state->dirpath,
 			       state->smb_fname->twrp,
@@ -981,6 +912,7 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 	struct uc_state *state = &uc_state;
 	NTSTATUS status;
 	int ret = -1;
+	int parent_stat_errno = 0;
 
 	*state = (struct uc_state) {
 		.mem_ctx = mem_ctx,
@@ -988,7 +920,6 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 		.orig_path = orig_path,
 		.ucf_flags = ucf_flags,
 		.posix_pathnames = (ucf_flags & UCF_POSIX_PATHNAMES),
-		.allow_wcard_last_component = (ucf_flags & UCF_ALWAYS_ALLOW_WCARD_LCOMP),
 		.case_sensitive = conn->case_sensitive,
 		.case_preserve = conn->case_preserve,
 		.short_case_preserve = conn->short_case_preserve,
@@ -1073,9 +1004,7 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 		if (state->orig_path[1] == '\0' || state->orig_path[2] == '\0') {
 			status = NT_STATUS_OBJECT_NAME_INVALID;
 		} else {
-			status =determine_path_error(&state->orig_path[2],
-			    state->allow_wcard_last_component,
-			    state->posix_pathnames);
+			status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
 		}
 		goto err;
 	}
@@ -1200,8 +1129,8 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 
 	if (!state->posix_pathnames) {
 		/* POSIX pathnames have no wildcards. */
-		state->name_has_wildcard = ms_has_wild(state->smb_fname->base_name);
-		if (state->name_has_wildcard && !state->allow_wcard_last_component) {
+		bool name_has_wildcard = ms_has_wild(state->smb_fname->base_name);
+		if (name_has_wildcard) {
 			/* Wildcard not valid anywhere. */
 			status = NT_STATUS_OBJECT_NAME_INVALID;
 			goto fail;
@@ -1211,132 +1140,43 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 	DBG_DEBUG("Begin: name [%s] dirpath [%s] name [%s]\n",
 		  state->smb_fname->base_name, state->dirpath, state->name);
 
-	if (!state->name_has_wildcard) {
-		int parent_stat_errno = 0;
-
-		/*
-		 * stat the name - if it exists then we can add the stream back (if
-		 * there was one) and be done!
-		 */
-
-		ret = vfs_stat(state->conn, state->smb_fname);
-		if (ret == 0) {
-			status = check_for_dot_component(state->smb_fname);
-			if (!NT_STATUS_IS_OK(status)) {
-				goto fail;
-			}
-			/* Add the path (not including the stream) to the cache. */
-			stat_cache_add(state->orig_path,
-				       state->smb_fname->base_name,
-				       state->smb_fname->twrp,
-				       state->case_sensitive);
-			DBG_DEBUG("Conversion of base_name finished "
-				  "[%s] -> [%s]\n",
-				  state->orig_path, state->smb_fname->base_name);
-			goto done;
-		}
-
-		/* Stat failed - ensure we don't use it. */
-		SET_STAT_INVALID(state->smb_fname->st);
-
-		/*
-		 * Note: we must continue processing a path if we get EACCES
-		 * from stat. With NFS4 permissions the file might be lacking
-		 * READ_ATTR, but if the parent has LIST permissions we can
-		 * resolve the path in the path traversal loop down below.
-		 */
+	/*
+	 * stat the name - if it exists then we can add the stream back (if
+	 * there was one) and be done!
+	 */
 
-		if (errno == ENOENT) {
-			/* Optimization when creating a new file - only
-			   the last component doesn't exist.
-			   NOTE : check_parent_exists() doesn't preserve errno.
-			*/
-			int saved_errno = errno;
-			status = check_parent_exists(state->mem_ctx,
-						state->conn,
-						state->posix_pathnames,
-						state->smb_fname,
-						&state->dirpath,
-						&state->name,
-						&parent_stat_errno);
-			errno = saved_errno;
-			if (!NT_STATUS_IS_OK(status)) {
-				goto fail;
-			}
+	ret = vfs_stat(state->conn, state->smb_fname);
+	if (ret == 0) {
+		status = check_for_dot_component(state->smb_fname);
+		if (!NT_STATUS_IS_OK(status)) {
+			goto fail;
 		}
+		/* Add the path (not including the stream) to the cache. */
+		stat_cache_add(state->orig_path,
+			       state->smb_fname->base_name,
+			       state->smb_fname->twrp,
+			       state->case_sensitive);
+		DBG_DEBUG("Conversion of base_name finished "
+			  "[%s] -> [%s]\n",
+			  state->orig_path, state->smb_fname->base_name);
+		goto done;
+	}
 
-		/*
-		 * A special case - if we don't have any wildcards or mangling chars and are case
-		 * sensitive or the underlying filesystem is case insensitive then searching
-		 * won't help.
-		 *
-		 * NB. As POSIX sets state->case_sensitive as
-		 * true we will never call into mangle_is_mangled() here.
-		 */
-
-		if ((state->case_sensitive || !(state->conn->fs_capabilities &
-					FILE_CASE_SENSITIVE_SEARCH)) &&
-				!mangle_is_mangled(state->smb_fname->base_name, state->conn->params)) {
-
-			status = check_for_dot_component(state->smb_fname);
-			if (!NT_STATUS_IS_OK(status)) {
-				goto fail;
-			}
-
-			/*
-			 * The stat failed. Could be ok as it could be
- 			 * a new file.
- 			 */
+	/* Stat failed - ensure we don't use it. */
+	SET_STAT_INVALID(state->smb_fname->st);
 
-			if (errno == ENOTDIR || errno == ELOOP) {
-				status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
-				goto fail;
-			} else if (errno == ENOENT) {
-				/*
-				 * Was it a missing last component ?
-				 * or a missing intermediate component ?
-				 *
-				 * Optimization.
-				 *
-				 * For this code path we can guarantee that
-				 * we have gone through check_parent_exists()
-				 * and it returned NT_STATUS_OK.
-				 *
-				 * Either there was no parent component (".")
-				 * parent_stat_errno == 0 and we have a missing
-				 * last component here.
-				 *
-				 * OR check_parent_exists() called STAT/LSTAT
-				 * and if it failed parent_stat_errno has been
-				 * set telling us if the parent existed or not.
-				 *
-				 * Either way we can avoid another STAT/LSTAT
-				 * system call on the parent here.
-				 */
-				if (parent_stat_errno == ENOTDIR ||
-						parent_stat_errno == ENOENT ||
-						parent_stat_errno == ELOOP) {
-					status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
-					goto fail;
-				}
+	/*
+	 * Note: we must continue processing a path if we get EACCES
+	 * from stat. With NFS4 permissions the file might be lacking
+	 * READ_ATTR, but if the parent has LIST permissions we can
+	 * resolve the path in the path traversal loop down below.
+	 */
 
-				/*
-				 * Missing last component is ok - new file.
-				 * Also deal with permission denied elsewhere.
-				 * Just drop out to done.
-				 */
-				goto done;
-			}
-		}
-	} else {
-		/*
-		 * We have a wildcard in the pathname.
-		 *
-		 * Optimization for common case where the wildcard
-		 * is in the last component and the client already
-		 * sent the correct case.
-		 * NOTE : check_parent_exists() doesn't preserve errno.
-		 */
+	if (errno == ENOENT) {
+		/* Optimization when creating a new file - only
+		   the last component doesn't exist.
+		   NOTE : check_parent_exists() doesn't preserve errno.
+		*/
 		int saved_errno = errno;
 		status = check_parent_exists(state->mem_ctx,
 					state->conn,
@@ -1344,13 +1184,77 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 					state->smb_fname,
 					&state->dirpath,
 					&state->name,
-					NULL);
+					&parent_stat_errno);
 		errno = saved_errno;
 		if (!NT_STATUS_IS_OK(status)) {
 			goto fail;
 		}
 	}
 
+	/*
+	 * A special case - if we don't have any wildcards or mangling chars and are case
+	 * sensitive or the underlying filesystem is case insensitive then searching
+	 * won't help.
+	 *
+	 * NB. As POSIX sets state->case_sensitive as
+	 * true we will never call into mangle_is_mangled() here.
+	 */
+
+	if ((state->case_sensitive || !(state->conn->fs_capabilities &
+				FILE_CASE_SENSITIVE_SEARCH)) &&
+			!mangle_is_mangled(state->smb_fname->base_name, state->conn->params)) {
+
+		status = check_for_dot_component(state->smb_fname);
+		if (!NT_STATUS_IS_OK(status)) {
+			goto fail;
+		}
+
+		/*
+		 * The stat failed. Could be ok as it could be
+		 * a new file.
+		 */
+
+		if (errno == ENOTDIR || errno == ELOOP) {
+			status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+			goto fail;
+		} else if (errno == ENOENT) {
+			/*
+			 * Was it a missing last component ?
+			 * or a missing intermediate component ?
+			 *
+			 * Optimization.
+			 *
+			 * For this code path we can guarantee that
+			 * we have gone through check_parent_exists()
+			 * and it returned NT_STATUS_OK.
+			 *
+			 * Either there was no parent component (".")
+			 * parent_stat_errno == 0 and we have a missing
+			 * last component here.
+			 *
+			 * OR check_parent_exists() called STAT/LSTAT
+			 * and if it failed parent_stat_errno has been
+			 * set telling us if the parent existed or not.
+			 *
+			 * Either way we can avoid another STAT/LSTAT
+			 * system call on the parent here.
+			 */
+			if (parent_stat_errno == ENOTDIR ||
+					parent_stat_errno == ENOENT ||
+					parent_stat_errno == ELOOP) {
+				status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+				goto fail;
+			}
+
+			/*
+			 * Missing last component is ok - new file.
+			 * Also deal with permission denied elsewhere.
+			 * Just drop out to done.
+			 */
+			goto done;
+		}
+	}
+
 	/*
 	 * is_mangled() was changed to look at an entire pathname, not
 	 * just a component. JRA.
@@ -1394,7 +1298,7 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx,
 	 * components as this can change the size.
 	 */
 
-	if(!state->component_was_mangled && !state->name_has_wildcard) {
+	if(!state->component_was_mangled) {
 		stat_cache_add(state->orig_path,
 			       state->smb_fname->base_name,
 			       state->smb_fname->twrp,
@@ -1477,7 +1381,7 @@ static NTSTATUS check_veto_path(connection_struct *conn,
  a valid one for the user to access.
 ****************************************************************************/
 
-NTSTATUS check_name(connection_struct *conn,
+static NTSTATUS check_name(connection_struct *conn,
 			const struct smb_filename *smb_fname)
 {
 	NTSTATUS status = check_veto_path(conn, smb_fname);
@@ -1499,25 +1403,6 @@ NTSTATUS check_name(connection_struct *conn,
 	return NT_STATUS_OK;
 }
 
-/****************************************************************************
- Must be called as root. Creates the struct privilege_paths
- attached to the struct smb_request if this call is successful.
-****************************************************************************/
-
-static NTSTATUS check_name_with_privilege(connection_struct *conn,
-		struct smb_request *smbreq,
-		const struct smb_filename *smb_fname)
-{
-	NTSTATUS status = check_veto_path(conn, smb_fname);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		return status;
-	}
-	return check_reduced_name_with_privilege(conn,
-			smb_fname,
-			smbreq);
-}
-
 /****************************************************************************
  Check if two filenames are equal.
  This needs to be careful about whether we are case sensitive.
@@ -1890,6 +1775,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
 	char *last_slash = NULL;
 	char *orig_lcomp;
 	char *fname = NULL;
+	NTTIME twrp = 0;
 	NTSTATUS status;
 
 	if (ucf_flags & UCF_DFS_PATHNAME) {
@@ -1898,6 +1784,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
 				filename_in,
 				ucf_flags,
 				!conn->sconn->using_smb2,
+				&twrp,
 				&fname);
 		if (!NT_STATUS_IS_OK(status)) {
 			DBG_DEBUG("dfs_redirect "
@@ -1926,7 +1813,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
 					filename_in,
 					NULL,
 					NULL,
-					0,
+					twrp,
 					0);
 		if (smb_fname == NULL) {
 			TALLOC_FREE(fname);
@@ -1934,7 +1821,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
 		}
 		status = canonicalize_snapshot_path(smb_fname,
 						    ucf_flags,
-						    0);
+						    twrp);
 		if (!NT_STATUS_IS_OK(status)) {
 			TALLOC_FREE(fname);
 			TALLOC_FREE(smb_fname);
@@ -1979,36 +1866,39 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
  * @return NT_STATUS_OK if all operations completed successfully, appropriate
  * 	   error otherwise.
  */
-static NTSTATUS filename_convert_internal(TALLOC_CTX *ctx,
-				connection_struct *conn,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list