1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00
Commit Graph

311 Commits

Author SHA1 Message Date
Jeremy Allison
3f0935b369 s3: smbd: get_real_filename() is actually static to filename.c
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-11-16 20:21:37 +00:00
Volker Lendecke
240addaed7 smbd: Convert ret==false into !ret
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Nov 11 19:59:03 UTC 2021 on sn-devel-184
2021-11-11 19:59:03 +00:00
Ralph Boehme
52a4211112 smbd: return correct timestamps for quota fake file
Prior to 572d4e3a56 it was sufficient to
initialize struct timespec to zero to return NTTIME 0 (ie not set) over
SMB.

This fixes the same problem from bug 14714 where the timestamps in an SMB2 CLOSE
response.

Windows of course does return *some* timestamps, but as it's neither documented
nor was I able to figure out where they would be coming from, as well as the
Windows client apparently doesn't care, I didn't bother with implementing some
sophisticated heuristic to return some timestamps.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14731

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jun  9 20:38:02 UTC 2021 on sn-devel-184
2021-06-09 20:38:02 +00:00
Jeremy Allison
33f45491f8 s3: smbd: Remove a STAT/LSTAT call on the parent pathname in a hot code path.
This optimization uses the stored errno result from check_parent_exists()
which already did a STAT/LSTAT if needed.

Best viewed with 'git show -b'.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue May 11 22:52:58 UTC 2021 on sn-devel-184
2021-05-11 22:52:58 +00:00
Jeremy Allison
6e0680ce07 s3: smbd: Allow check_parent_exists() to return the errno from STAT/LSTAT on the parent name.
Not yet used.

This will allow us to avoid an duplicate STAT/LSTAT system call
on the parent pathname in a hot code path of the caller in the next commit.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2021-05-11 22:08:36 +00:00
Noel Power
8331852d6b s3/smbd: filename: vfs_streaminfo -> vfs_fstreaminfo
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11 15:49:28 +00:00
Ralph Boehme
11aac9d043 smbd: reduce loglevel for failed openat_pathref_fsp() calls
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14685
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1884
RN: Log clutter from filename_convert_internal()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Apr  6 14:39:46 UTC 2021 on sn-devel-184
2021-04-06 14:39:46 +00:00
Noel Power
ecd9b751f1 s3/modules: Ensure vfs_streaminfo gets passed valid pathref smb_filename
the smb_filename/smb_filename->fsp passed to vfs_streaminfo
eventually is passed to SMB_VFS_FLISTXATTR, we need to ensure this is
properly setup and not NULL

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-02-26 21:28:33 +00:00
Ralph Boehme
977f37643b smbd: don't return NT_STATUS_STOPPED_ON_SYMLINK in openat_pathref_fsp()
NT_STATUS_STOPPED_ON_SYMLINK is returned when trying to open a symlink, most
callers are not interested in this.

Some callers that would want to know whether openat_pathref_fsp() failed
specifically on a symlink are setup_close_full_information(),
smbd_dirptr_get_entry(), unlink_internals() and filename_convert_internal(), so
we fix those callers to handle the symlink case themselves.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-02-05 06:22:35 +00:00
Ralph Boehme
c3fb27d92b smbd: check for absolute paths in full_path_from_dirfsp_atname()
If the "atname" is an absolute path we can ignore the dirfsp and just return a
copy of the atname.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:29 +00:00
Ralph Boehme
985c1be5cc smbd: use vfs_stat() in more places
This replaces the code in a bunch of places where we choose between stat() and
lstat() based on req->posix_pathname. The new code inside vfs_stat() is based on
checking the smb_fname flag SMB_FILENAME_POSIX_PATH.

req->posix_pathname is inherited from the global POSIX pathnames state and the
smb_fname flags is also inherited from that indirectly via the UCF flags.

Tl;dr: no change in behaviour. :)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
9a5a1fe148 smbd: use open_pathref_fsp() in filename_convert_internal()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
4d29ab04d8 smbd: use common exit in filename_convert_internal()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
a14db893c1 s3: add full_path_from_dirfsp_atname()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
29e212dd6a smbd: use UCF_POSIX_PATHNAMES flag for path validation logic in filename_convert_internal()
This change means that if a client path is a symlink, we *always* only call
check_veto_path() for POSIX clients using a POSIX pathname, not just when a
POSIX info-level was used in an SMB request.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-23 07:56:33 +00:00
Jeremy Allison
b7bb348bfe s3: smbd: Remove wrapper resolve_dfspath_wcard(). Just call dfs_redirect() directly.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:42 +00:00
Jeremy Allison
e59c810f26 s3: smbd: Remove unused 'bool *ppath_contains_wcard' parameter from resolve_dfspath_wcard()
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:42 +00:00
Jeremy Allison
b3334eb9d8 s3: smbd: Remove the 'bool *ppath_contains_wcard' parameter from filename_convert_internal()
It's always ignored.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:42 +00:00
Jeremy Allison
eb60ed6b5e s3: smbd: The only caller of filename_convert_with_privilege() passes in NULL for the 'bool *ppath_contains_wcard' parameter.
Remove it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:42 +00:00
Jeremy Allison
ff4e8b2c84 s3: smbd: All callers to filename_convert() pass in NULL for the 'bool *ppath_contains_wcard' parameter.
Remove it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:42 +00:00
Jeremy Allison
e188b74aa9 s3: smbd: SMB1 Remove the crazy semantics in filename_convert_internal() using UCF_COND_ALLOW_WCARD_LCOMP.
In the places where wildcards are allowed in SMB1
we always pass in UCF_ALWAYS_ALLOW_WCARD_LCOMP.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-09-30 20:46:39 +00:00
Volker Lendecke
d304341ea3 smbd: Apply a bit of README.Coding to unix_convert()
Looking at that more closely right now...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-06-15 17:59:39 +00:00
Volker Lendecke
38814784cf smbd: Fix typos
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-06-15 17:59:39 +00:00
Ralph Boehme
60c47a5d13 smbd: remove unused variable twrp_name from filename_convert_internal()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-21 05:23:29 +00:00
Ralph Boehme
0b31a9ce9a smbd: update function documentation header to match actual function argument names
Leaving p_cont_wcard unchanges as updating that would break the nice
indentation... :)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-21 05:23:29 +00:00
Ralph Boehme
aa5f19ddf1 smbd: make get_real_filename_full_scan() public
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14350

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-06 10:18:38 +00:00
Jeremy Allison
2992891e27 s3: smbd: Move the initialization of the filename and the call to canonicalize_snapshot_path() *before* zero-length string checks.
canonicalize_snapshot_path() may eat the incoming pathname in total
for SMB1, so we need to check after that call.

Fix the zero-length string check to look at state->smb_fname->base_name
instead of state->orig_path.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 19:18:43 +00:00
Jeremy Allison
8019b3d0af smbd: Update description of canonicalize_snapshot_path().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 19:18:43 +00:00
Ralph Boehme
f689f3cb22 smbd: pass ucf_flags to canonicalize_snapshot_path()
No change in behaviour. ucf_flags are just now checked *inside*
canonicalize_snapshot_path() instead of the caller.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:43 +00:00
Ralph Boehme
6e364c5453 smbd: strip @GMT token in canonicalize_snapshot_path()
smbd and all previous-versions implementing VFS modules have been patched to
work with struct smb_filename.NTTIME twrp, so we can now safely strip @GMT
tokens from paths.

This also means that "@GMT-something/foo" and "foo" will both come out as "foo",
so we have to take care of the stat-cache now and change it to take and use an
additional twrp arg.

At the same time remove @GMT stripping from shadow_copy2. In theory this could
be made a seperate commit, but due to the absolute path and pstripped logic, it
felt too cumbersome to attempt this.

Leaving the exercize of removing the now unneeded stripped logic to a future
patchset.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:43 +00:00
Ralph Boehme
1130c64f49 smbd: realign stat_cache_add() args in unix_convert()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:43 +00:00
Ralph Boehme
6e8ffcff46 smbd: realigning a complex if expression in unix_convert()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:42 +00:00
Ralph Boehme
d912999394 smbd: move a DEBUG in unix_convert()
Ensure a successfull conversion via early exit also logs a message.

While at it, use smb_fname_str_dbg() to print the string which ensure any stream
component or twrp value is also printed.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:42 +00:00
Ralph Boehme
96921b6f5b smbd: make canonicalize_snapshot_path() public
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:41 +00:00
Ralph Boehme
f9c6706080 smbd: convert SMB_VFS_GET_REAL_FILENAME() arg path to be a struct smb_filename
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:41 +00:00
Ralph Boehme
82daff3efd smbd: pass struct smb_filename to get_real_filename()
Prepares for passing struct smb_filename to SMB_VFS_GET_REAL_FILENAME().

This also makes it necessary to move the NULL or empty path checks to
unix_convert_step_stat().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
09b841aa1c smbd: realign args of get_real_filename() and friends
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
1e5164afaf smbd: pass twrp as NTTIME to filename_convert() and all the way down to canonicalize_snapshot_path()
Also pass by value rather then by reference.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
8a8fe887f5 smbd: let canonicalize_snapshot_path() fill in struct smb_filename.twrp
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
f8bb2f59e1 smbd: move time_t twrp to @GMT string token conversion to canonicalize_snapshot_path()
Prepares for canonicalize_snapshot_path() being the one-stop shop for
previous-versions related stuff in subsequent commits.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
69458cc22a smbd: refactor canonicalize_snapshot_path()
This prepares for adding additional code after calling rearrange_snapshot_path().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
b74653f2cd smbd: add twrp arg to synthetic_smb_fname()
Most places take twrp from a local struct smb_filename variable that the
function is working on. Some don't for various reasons:

o synthetic_smb_fname_split() is only called in very few places where we don't
  expect twrp paths

o implementations of SMB_VFS_GETWD(), SMB_VFS_FS_CAPABILITIES() and
  SMB_VFS_REALPATH() return the systems view of cwd and realpath without twrp info

o VFS modules implementing previous-versions support (vfs_ceph_snapshots,
  vfs_shadow_copy2, vfs_snapper) synthesize raw paths that are passed to VFS NEXT
  functions and therefor do not use twrp

o vfs_fruit: macOS doesn't support VSS

o vfs_recycle: in recycle_create_dir() we need a raw OS path to create a directory

o vfs_virusfilter: a few places where we need raw OS paths

o vfs_xattr_tdb: needs a raw OS path for SMB_VFS_NEXT_STAT()

o printing and rpc server: don't support VSS

o vfs_default_durable_reconnect: no Durable Handles on VSS handles, this might
  be enhances in the future. No idea if Windows supports this.

o get_real_filename_full_scan: hm.... FIXME??

o get_original_lcomp: working on a raw path

o msdfs: doesn't support VSS

o vfs_get_ntquota: synthesizes an smb_filename from ".", so doesn't support VSS
  even though VFS modules implement it

o fd_open: conn_rootdir_fname is a raw path

o msg_file_was_renamed: obvious

o open_np_file: pipes don't support VSS

o Python bindings: get's a raw path from the caller

o set_conn_connectpath: raw path

o set_conn_connectpath: raw path

o torture: gets raw paths from the caller

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-05 19:18:40 +00:00
Ralph Boehme
c0a9c8698c smbd: use parent_smb_fname() in unix_convert()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-29 16:39:39 +00:00
Ralph Boehme
3cc0dcad35 smbd: use synthetic_smb_fname() in check_parent_exists()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-29 16:39:39 +00:00
Ralph Boehme
2f55b662a3 smbd: add missing done check from unix_convert_step_stat() refactoring
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-28 18:09:39 +00:00
Jeremy Allison
e7dfe87ac6 smbd: unix_convert_step(). Fix use of state->end as a boolean, always compare with NULL.
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): Fri Apr 24 23:21:16 UTC 2020 on sn-devel-184
2020-04-24 23:21:16 +00:00
Ralph Boehme
90713cbd63 smbd: add some logging to unix_convert()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-24 21:46:27 +00:00
Ralph Boehme
e8fc196513 smbd: factor out unix_convert_step_search_fail()
Again, just moving code from unix_convert_step_stat() without any logic changes.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-24 21:46:27 +00:00
Ralph Boehme
a5b0271e0c smbd: use an early exit if stat succeeds in unix_convert_step_stat()
Allows decreasing the indentation level of the bulk of the code that handles
stat failure. Best viewed with `git show -w`.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-24 21:46:27 +00:00
Ralph Boehme
a2f4528290 smbd: factor out unix_convert_step_stat() from unix_convert_step()
The diff looks more complicated that it is: everything in the new
unix_convert_step_stat() is moved *as is* from unix_convert_step() without
further changes.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-24 21:46:27 +00:00