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

71 Commits

Author SHA1 Message Date
Volker Lendecke
15648b5da5 smbd: Modernize a DEBUG statement
Avoid casts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-11-15 05:10:35 +00:00
Volker Lendecke
c3c5e6c3dd smbd: Pass vfs_open_how through fd_openat
Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-08-06 01:43:50 +00:00
Jeremy Allison
fe7daae8c4 s3: smbd: Allow a durable handle on a leased stat-open.
Remove knownfail.

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

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): Fri Apr 29 15:50:21 UTC 2022 on sn-devel-184
2022-04-29 15:50:21 +00:00
Volker Lendecke
aacb3618c1 smbd: Use fsp_is_alternate_stream() where an fsp is available
Make it clear that being an alternate data stream handle is much more
a fsp property than a file name property.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-11 20:54:37 +00:00
Volker Lendecke
529e6718c0 smbd: Replace SMB_VFS_CLOSE() calls with fd_close()
fd_close() mostly wraps SMB_VFS_CLOSE() but also takes care of refcounting
fsp->fh properly and also makes sure that fsp->fh->fd is set to -1 after close.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-12-30 11:03:35 +00:00
Christof Schmitt
d8972d9201 smbd: Update comment for durable handles
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-09-21 18:47:38 +00:00
Samuel Cabrero
1196903231 s3: smbd: Pass full fsp to file_ntimes()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-19 12:28:30 +00:00
Stefan Metzmacher
81b6931be0 s3:smbd: let vfs_default_durable_reconnect() use file_free()
We should always go through file_free(), which calls fsp_free() at the end.

Most things in file_free() may not apply to all
vfs_default_durable_reconnect() cases, but we want fsp_free() to become
static to files.c

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-01-14 11:30:38 +00:00
Ralph Boehme
7c5476baad smbd: mark fsp as valid FSA fsp after Durable Handle reconnect succeeded
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-17 18:56:28 +00:00
Ralph Boehme
bde16030a2 smbd: use fdos_mode() in vfs_default_durable_reconnect()
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
abc00b959b smbd: pass a dirfsp to fd_open() and rename it to fd_openat()
For now no change in behaviour as all callers still pass conn->cwd_fsp. This
just prepared fd_openat() to deal with real dirfsp's pass by callers later on
when adding calls to fd_openat(dirfspm ...) in the directory enumeration loop.

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
da786ccd1d smbd: use fh_[get|set]_private_options()
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
059dee953d smbd: use fh_[get|set]_gen_id()
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
0d9afd7ab8 smbd: use fh_[get|set]_pos() and fh_[get|set]_position_information()
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
9db3ff2573 smbd: use fsp_get_io_fd() when accessing a file or it's associated metadata
In all places where we access or modify a file or it's associated metadata, we
use fsp_get_io_fd() to fetch the low-level fd from the fsp. This ensures we
don't accidentally use a pathref fsp where the fd would be opened as root on
systems lacking O_PATH.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Volker Lendecke
60f24079a9 smbd: Use share_mode_changed_write_time() in durable_disconnect()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-10 19:49:34 +00:00
Volker Lendecke
3f54fcaffd smbd: Move setting d->modified=true to reset_share_mode_entry()
This function is only called from
vfs_default_durable_reconnect(). It is really the lower-level routine
that triggers the write of the locking.tdb record.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-10 19:49:34 +00:00
Volker Lendecke
15e9e2945c smbd: Give locking/share_mode_lock.c its own header file
To me this is then easier to figure out what is defined there, and
where it's exactly used.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-10 19:49:34 +00:00
Ralph Boehme
1c444f9c37 smbd: remove fsp->dirfsp
This was supposed to be a shortcut to avoid passing dirfsp around as an explicit
function argument throughout the whole codebase when the new VFS design idea was
based on using *AT functions throughout the VFS.

Now that we've opted for basing the VFS on handles and *AT functions will only
be used in a much more limitted extent, it makes sense to remove this internal
dirfsp reference, otherwise the combination of internal fsp->dirfsp and
smb_fname->fsp is going to be a tough to wrap your head around.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-02 19:39:44 +00:00
Ralph Boehme
187353d91c smbd: switch caller of fd_openat() to fd_open()
fd_openat() was added to be used with real dirfsp, but after adding pathref fd
support we will never use this.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-02 19:39:43 +00:00
Ralph Boehme
c68133d41c smbd: prepare DH disconnect for AT-names
This ensure cookie.base_name is set to the full path to deal with fsp->fsp_name
being an atname in the future.

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): Thu May 21 22:01:25 UTC 2020 on sn-devel-184
2020-05-21 22:01:25 +00:00
Ralph Boehme
75d6943ed8 smbd: use fd_openat()
This leaves basically two callers of fd_open():

* open_internal_dirfsp_at()
* smbd_smb2_query_directory_send()

Those will be the only codepaths that use full paths relative to the share root
and so require and use the symlink race protection provided by
non_widelink_open().

Of course, until we actuall start passing real dirfsps to fd_openat(),
fd_openat() internally calls fd_open().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-21 20:38:35 +00:00
Ralph Boehme
f4b3719191 smbd: remove redundant conn arg from fd_open()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-21 05:23:32 +00:00
Ralph Boehme
4ae6e5f054 smbd: set dirfsp in the SMB2 DH reconnect
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-21 05:23:32 +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
930b7525a6 smbd: move files_struct.delete_on_close to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
b0824cf35f smbd: move files_struct.initial_delete_on_close to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
1ccd335af5 smbd: move files_struct.aio_write_behind to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
cb996cd5a3 smbd: move files_struct.is_directory to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
65a4302474 smbd: move files_struct.modified to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
b95c62bc90 smbd: move files_struct.can_write to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
8b48969241 smbd: move files_struct.can_read to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:44 +00:00
Ralph Boehme
d22096961b smbd: move files_struct.can_lock to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:43 +00:00
Ralph Boehme
4d70e92a91 smbd: move files_struct.write_time_forced to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:43 +00:00
Ralph Boehme
9c2809c517 smbd: move files_struct.update_write_time_on_close to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:43 +00:00
Ralph Boehme
adaca9597c smbd: move files_struct.update_write_time_triggered to a bitfield
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-03 19:05:43 +00:00
Ralph Boehme
69691dd0cd smbd: fix handling of sentinel timestamp values
This implements two core changes:

* use NTTIME instead of struct timespec at the database layer

* use struct timespec { .tv_nsec = SAMBA_UTIME_OMIT } as special sentinel
  value in smbd when processing timestamps

Using NTTIME at the database layer is only done to avoid storing the special
struct timespec sentinel values on disk. Instead, with NTTIME the sentinel value
for an "unset" timestamp is just 0 on-disk.

The NTTIME value of 0 gets translated by nt_time_to_full_timespec() to the
struct timespec sentinel value { .tv_nsec = SAMBA_UTIME_OMIT }.

The function is_omit_timespec() can be used to check this.

Beside nt_time_to_full_timespec(), there are various other new time conversion
functions with *full* in their name that can be used to safely convert between
different types with the changed sentinel value.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-12-06 00:17:36 +00:00
Ralph Boehme
b5c6964a50 s3:param: make "servicename" a substituted option
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-11-27 10:25:37 +00:00
Volker Lendecke
2d9bb67d25 smbd: Use share_mode_forall_entries() in vfs_default_durable_reconnect()
The durable reconnect mainly has to check that there is one and only one
entry, and it has to reset it with the new values.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-17 22:49:38 +00:00
Volker Lendecke
e0aa1e0998 smbd: Fix a debug message hickup
Mind the missing space before "(e.g. another...". While there, avoid
casts.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-17 22:49:36 +00:00
Volker Lendecke
e00e53344d smbd: Make fsp->fh->gen_id unique per process
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-09-17 22:49:35 +00:00
Ralph Boehme
95655fe683 vfs: restore stat fields in vfs_stat_fsp()
This ensures we preserve btime, itime and File-ID.

As the Durable Handles code calls vfs_stat_fsp() in the DH disconnect function,
previously the btime was lost and NOT stored in the cookie. With this change the
cookie will store the correct btime (and iflags), which requires us to call
dos_mode() in the reconnect function to ensure we pass
vfs_default_durable_reconnect_check_stat().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Sep 10 20:22:21 UTC 2019 on sn-devel-184
2019-09-10 20:22:21 +00:00
Volker Lendecke
13921645c4 smbd: Remove "share_access" from files_struct
Nobody used this (except vfs_gpfs, which did not need it really). If
you *really* need this, you can always look in locking.tdb, but this
should never happen in any hot code path, as no runtime decisions are
made on the share access after the open is done.

Bump VFS interface number to 42.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-08-06 21:49:29 +00:00
Ralph Boehme
d18bdc1c43 s3: convert struct stat_ex st_ex_calculated_birthtime bool to flags
Subsequent commits will add more flags, this paves the way.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-01 21:43:23 +00:00
Ralph Boehme
a5f4e33f87 s3: remove unused st_ex_mask from struct stat_ex
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-07-01 21:43:23 +00:00
Volker Lendecke
8ff60fcc06 smbd: Use leases_db in vfs_default_durable_reconnect()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:32 +00:00
Volker Lendecke
b9b35947c7 smbd: Use share_mode_entry's lease data in vfs_default_durable_reconnect()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:31 +00:00
Volker Lendecke
a69db298d4 smbd: Pass lease parameters explicitly to find_fsp_lease
This avoids a use of "struct share_mode_lease"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-04-14 04:01:30 +00:00
Volker Lendecke
5e4f34e707 smbd: Add some structure protection for durable reconnect
We should consume all data, and the ndr_pull function fills in all
fields. Thus the ZERO_STRUCT(cookie) is not required.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2018-09-14 07:49:13 +02:00
Ralph Boehme
0a91ade527 s3: smbd/durable: remove dev and inode check from vfs_default_durable_reconnect_check_stat()
On a cluster filesystem the device numbers may differ on the cluster
nodes. We already verify the file_id in vfs_default_durable_reconnect(),
so we can safely remove the dev/inode checks.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13318

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2018-07-07 13:41:09 +02:00