summaryrefslogtreecommitdiff
path: root/source3/smbd/msdfs.c
Commit message (Collapse)AuthorAgeFilesLines
* smbd: squash check_path_syntax() variantsRalph Boehme2023-03-311-3/+3
| | | | | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Fri Mar 31 21:21:57 UTC 2023 on atb-devel-224
* s3: smbd: Remove now unused dfs_filename_convert().Jeremy Allison2023-03-311-295/+0
| | | | | | | And all the static functions it called. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:smbd: Don't assign variable to itselfAndreas Schneider2023-02-061-2/+0
| | | | | | | | | | source3/smbd/msdfs.c:367:14: error: explicitly assigning value of variable of type 'char *' to itself [-Werror,-Wself-assign] servicename = servicename; ~~~~~~~~~~~ ^ ~~~~~~~~~~~ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix spelling mistakes.Michael Tokarev2022-09-121-1/+1
| | | | | | | | | Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Sep 12 02:29:32 UTC 2022 on sn-devel-184
* s3: smbd: parse_dfs_path() - Fix comment explaining where this is called ↵Jeremy Allison2022-08-281-4/+4
| | | | | | | | | | from and with what kind of path. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sun Aug 28 20:58:57 UTC 2022 on sn-devel-184
* s3: smbd: Remove allow_broken_path parameter from parse_dfs_path().Jeremy Allison2022-08-281-2/+0
| | | | | | | Nothing now looks at it. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Now parse_dfs_path() is only called from dfs_filename_convert() ↵Jeremy Allison2022-08-281-3/+9
| | | | | | | | | | | | replace allow_broken_path with an SMB1 check. dfs_filename_convert() always sets allow_broken_path = !smb2, so just move this bool inside of parse_dfs_path(). We can now remove allow_broken_path. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove allow_broken_path from create_junction().Jeremy Allison2022-08-281-1/+0
| | | | | | | | We no longer look at it, we know we must have a canonicalized DFS path here. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove allow_broken_path from get_referred_path() and it's callers.Jeremy Allison2022-08-281-1/+0
| | | | | | | | It no longer looks at this bool, we must already have a canonicalized path here. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove unneeded NULL check inside ↵Jeremy Allison2022-08-281-5/+0
| | | | | | | | | | msdfs_servicename_matches_connection(). This is now only called from is from parse_dfs_path(), and for that we know conn is non-NULL. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In create_junction() don't read hostname from parse_dfs_path_strict().Jeremy Allison2022-08-281-2/+1
| | | | | | | It isn't used anymore inside create_junction(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In create_junction() remove hostname check. ↵Jeremy Allison2022-08-281-8/+0
| | | | | | | parse_dfs_path_strict() already does this. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Change create_junction() to use parse_dfs_path_strict().Jeremy Allison2022-08-281-3/+2
| | | | | | | Note we no longer use allow_broken_path. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Change get_referred_path() to use parse_dfs_path_strict().Jeremy Allison2022-08-281-6/+3
| | | | | | | | | | Remove #ifdef's around parse_dfs_path_strict() as we're now using it. Note we no longer use allow_broken_path. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add a comment explaing why dfs_filename_convert() must continue to ↵Jeremy Allison2022-08-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | | use parse_dfs_path(). libsmbclient libraries will always set the FLAGS2_DFS_PATHNAMES bit when talking to a DFS share, but don't always canonicalize the incoming pathname to a DFS one (see the code for cli_list() that puts a non-DFS pathname into SMB2trans2_FindFirst for example). This is a problem in our client libraries for both SMB1 and SMB2+ As we still must cope with these older clients we must keep the lenient parsing for DFS filenames sent over SMB1/2/3. A future task - change the use of parse_dfs_path() in dfs_filename_convert() to parse_dfs_path_strict() for SMB2 only and then try and get all our torture tests to pass. This is not an easy fix (and would still break old clients out there as well :-( ). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In dfs_filename_convert(), don't ask for hostname, sharename and ↵Jeremy Allison2022-08-281-11/+2
| | | | | | | | | then just free them. Wastes a talloc/free. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add a new function parse_dfs_path_strict().Jeremy Allison2022-08-281-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #ifdef'ed out as not yet used. This will replace parse_dfs_path() for all client sent names via DFS RPC calls and for SMB_VFS_GET_DFS_REFERRALS(). The paths sent in these calls are guaranteed to be of canonical form: \SERVER\share\pathname. Both for SMB1 and SMB2+ so we can be more strict when parsing them. Checks DFS path starts with separator. Checks hostname is ours. Ensures servicename (share) is sent, and if so, terminates the name or is followed by \pathname. Errors out if any checks fail. Reserve parse_dfs_path() for DFS names sent via "ordinary" SMB 1/2/3 calls where we must be more lenient in parsing. Note parse_dfs_path_strict() does not have bool allow_broken_path or 'struct connection_struct' as it will not be called from places that use these. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove the old dfs_path_lookup() code.Jeremy Allison2022-08-121-191/+0
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Switch get_referred_path() over to use the new dfs_path_lookup().Jeremy Allison2022-08-121-25/+6
| | | | | | | | | | | | | | New function doesn't need a TWRP argument and returns NT_STATUS_OK on successful redirect, not NT_STATUS_PATH_NOT_COVERED. Comment out the old dfs_path_lookup(). There are now no more users of unix_convert(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add new version of dfs_path_lookup() that uses ↵Jeremy Allison2022-08-121-0/+261
| | | | | | | | | | | | filename_convert_dirfsp(). Commented out as not yet used but it's easier to see the new logic this way. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove dfs_redirect().Jeremy Allison2022-08-121-115/+0
| | | | | | | | | A moment of silence please. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In get create_junction(), make sure check_path_syntax() is called ↵Jeremy Allison2022-08-121-0/+6
| | | | | | | | | on returned reqpath. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In get referred_path(), make sure check_path_syntax() is called on ↵Jeremy Allison2022-08-121-0/+7
| | | | | | | | | returned reqpath. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add dfs_filename_convert(). Simple wrapper around parse_dfs_path().Jeremy Allison2022-08-121-0/+62
| | | | | | | | | | | | | | Not yet used. This is what we will use to replace dfs_redirect() in the filename conversion code. Keep as a wrapper for now as we might want to add some error checking around the 'hostname' and 'service' returns. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Use helper function msdfs_servicename_matches_connection() in ↵Jeremy Allison2022-08-121-7/+6
| | | | | | | | | | | dfs_redirect(). Replaces ugly complex logic. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Use helper function msdfs_servicename_matches_connection() in ↵Jeremy Allison2022-08-121-8/+7
| | | | | | | | | | | parse_dfs_path(). Replaces ugly complex logic. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add helper function msdfs_servicename_matches_connection().Jeremy Allison2022-08-121-0/+46
| | | | | | | | | Not yet used so commented out. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove use of 'struct dfs_path'. Not needed for a (hostname, ↵Jeremy Allison2022-08-121-80/+87
| | | | | | | | | servicename, path) tuple. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Add TALLOC_CTX * parameter to parse_dfs_path().Jeremy Allison2022-08-121-5/+17
| | | | | | | | | Not yet used. Preparing to remove 'struct dfs_path'. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Oops. DBG_ERR messages I used to debug parse_dfs_path(), should ↵Jeremy Allison2022-08-081-4/+4
| | | | | | | | | | have been DBG_DEBUG. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Aug 8 09:07:24 UTC 2022 on sn-devel-184
* s3: smbd: Cleanup - integer align. consumedcnt should be a size_t.Jeremy Allison2022-08-051-5/+5
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Minor cleanup in parse_dfs_path().Jeremy Allison2022-08-051-4/+3
| | | | | | | | | allow_wcards parameter is not used or looked at. Remove it. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Change srvstr_get_path_internal() to always call ↵Jeremy Allison2022-08-051-68/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check_path_syntaxXXX(), even on DFS pathnames. The original design decision to just copy a DFS path and let parse_dfs_path() take care of it was a horrible mistake. Fix srvstr_get_path_internal() to always return a /server/share/path (i.e. a path separated with '/', not '\'). This is a more complex change than I like to allow DFS path procesing in srvstr_get_path_internal() but needed as clients (including Samba smbclient) have a rather "fuzzy" idea of what constitutes a valid DFS path. If we detect the DFS path isn't valid here we have to fall back to treating it as a local path. I also need to modify the DFS parsing in filename_convert_smb1_search_path() to cope with only '/' separators. This also means parse_dfs_path() needs changing to cope. The changes here are best reviewed by just applying the fix and looking at the modified functions: srvstr_get_path_internal() parse_dfs_path() For parse_dfs_path() it's mostly removing bad code and makes parse_dfs_path() much easier to read. These changes will enable me to remove some ugly mistakes made adding ucf_flags to extract_snapshot_token(), as we can now always assume canonicalized paths. This is a little messy, but has to be done in one chunk as the change to srvstr_get_path_internal() depends on the change to parse_dfs_path(). Thanks to Volker for the insight that made this cleanup possible. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Rename OpenDir_ntstatus() -> OpenDir().Jeremy Allison2022-03-021-12/+12
| | | | | | | | | | We now have a single OpenDir() function that returns an NTSTATUS. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Mar 2 21:58:32 UTC 2022 on sn-devel-184
* s3: smbd: In form_junctions(), Move one more use of OpenDir() -> ↵Jeremy Allison2022-03-021-2/+8
| | | | | | | | | OpenDir_nstatus() Eventually we can replace OpenDir() with OpenDir_ntatatus(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: In count_dfs_links(), Move one more use of OpenDir() -> ↵Jeremy Allison2022-03-021-2/+8
| | | | | | | | | OpenDir_nstatus() Eventually we can replace OpenDir() with OpenDir_ntatatus(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: parse_dfs_path() can ignore wildcards.Jeremy Allison2021-12-111-6/+0
| | | | | | | | If one is passed to filename_convert(), it will error out there with NT_STATUS_OBJECT_NAME_INVALID. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Remove 'bool search_wcard_flag' from parse_dfs_path().Jeremy Allison2021-12-111-2/+1
| | | | | | | Never set. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: dfs_path_lookup() no longer deals with wildcards.Jeremy Allison2021-12-111-13/+0
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: Allow dfs_redirect() to return a TWRP token it got from a parsed ↵Jeremy Allison2021-12-111-1/+2
| | | | | | | | | | | | | 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@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In dfs_path_lookup(). If we have a DFS path including a ↵Jeremy Allison2021-12-111-0/+7
| | | | | | | | | @GMT-token, don't throw away the twrp value when parsing the path. Not yet used. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* source3: move lib/substitute.c functions out of proto.hRalph Boehme2021-11-111-0/+1
| | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3: smbd: In create_conn_struct_cwd(), don't TALLOC_FREE() an unallocated ↵Jeremy Allison2021-08-251-6/+1
| | | | | | | | | | | | | | | pointer on error. Just return the status - if create_conn_struct_as_root() fails the connection struct never gets returned. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14809 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Aug 25 17:09:23 UTC 2021 on sn-devel-184
* s3: smbd: In dfs_path_lookup(), use relative dirfsp, atname lookups in ↵Jeremy Allison2021-07-141-19/+40
| | | | | | | | | | | | | SMB_VFS_READ_DFS_PATHAT() for the pathname walk fallback. Note that parent_pathref() must succeed before we call SMB_VFS_READ_DFS_PATHAT(). If parent_pathref() fails, just step back a component without calling SMB_VFS_READ_DFS_PATHAT(). There are no longer any non-relative uses of SMB_VFS_READ_DFS_PATHAT(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In dfs_path_lookup(), use relative dirfsp, atname lookups in ↵Jeremy Allison2021-07-141-21/+36
| | | | | | | | | | SMB_VFS_READ_DFS_PATHAT() for the whole path optimization. Note parent_pathref() must succeed before we can call SMB_VFS_READ_DFS_PATHAT(). Otherwise, just skip the whole path optimization and go onto the path walk code. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: In is_msdfs_link(), change to dirfsp, atname parameters.Jeremy Allison2021-07-141-6/+6
| | | | | | | | Remember to update the smb_fname->st struct inside check_msdfs_link(), as we now pass the atname to is_msdfs_link(), not the smb_fname. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: add create_conn_struct_cwd()Ralph Boehme2021-06-161-0/+38
| | | | | | | | | | | Compared to create_conn_struct_tos_cwd() this takes a TALLOC_CTX and tevent_context as additional arguments and the resulting connection_struct is stable across the lifetime of mem_ctx and ev. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: pass tevent context to create_conn_struct_as_root()Ralph Boehme2021-06-161-6/+10
| | | | | | | | | | The next commit will add another caller of create_conn_struct_as_root() that is going to pass a long-lived tevent context. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: use real dirfsp for SMB_VFS_UNLINKAT() in remove_msdfs_link()Ralph Boehme2021-01-281-2/+15
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: use real dirfsp for SMB_VFS_CREATE_DFS_PATHAT() in create_msdfs_link()Ralph Boehme2021-01-281-4/+4
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>