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

11959 Commits

Author SHA1 Message Date
Volker Lendecke
1bd16bc6d4 smbd: Use dbwrap_do_locked() in smb2srv_open_recreate()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Stefan Metzmacher
fede6b9f46 smbd: rename 'op' into 'global' in smbXsrv_open_cleanup_fn()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
ca872ad6ba smbd: let smbXsrv_open_cleanup() delete broken records
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
a69950db4a smbd: Use dbwrap_do_locked() in smbXsrv_open_cleanup()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
62a6633193 smbd: Use dbwrap_do_locked() in smbXsrv_open_close()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
26b29ecbb9 smbd: Use dbwrap_do_locked() in smbXsrv_open_update()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
bfede670bd smbd: Use dbwrap_do_locked() in smbXsrv_open_global_allocate()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
84d22dc5f5 smbd: Make smbXsrv_open_global_allocate() store the record
Micro-step towards using dbwrap_do_locked()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
95e3ad7e43 smbd: Simplify smbXsrv_open_global_store()
Avoid the dependency on global->db_rec. This makes the callers more
verbose, but it makes the data dependencies much more obvious. This
will enable removing smbXsrv_open_global0->db_rec at some point.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
fafebc46c8 smbd: Move smbXsrv_open_global_verify_record() down in smbXsrv_open.c
Avoid prototypes

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Volker Lendecke
a93d93a97d smbd: Use generate_nonce_buffer() in smbXsrv_open_global_allocate()
We don't need anything cryptographic for persistent file handle ids

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-02-13 09:53:38 +00:00
Jeremy Allison
e8abe52df2 s3: smbd: Fix log spam. Change a normal error message from DBG_ERR (level 0) to DBG_INFO (level 5).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15302

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat Feb 11 08:48:05 UTC 2023 on atb-devel-224
2023-02-11 08:48:05 +00:00
Andreas Schneider
91e7351db3 s3:smbd: Don't assign variable to itself
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>
2023-02-06 22:51:31 +00:00
Volker Lendecke
f7b50bc059 smbd: Use smbXsrv_open_global_parse_record() in .._verify_record()
Signed-off-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Jan 24 09:15:26 UTC 2023 on atb-devel-224
2023-01-24 09:15:26 +00:00
Volker Lendecke
132b83d065 smbd: Simplify smbXsrv_open_global_parse_record()
It does not need a db_record.

Signed-off-by: Volker Lendecke <vl@samba.org>
2023-01-24 08:19:34 +00:00
Volker Lendecke
2f6776741d smbd: Move smbXsrv_open_global_parse_record() up in smbXsrv_open.c
Avoid a prototype in the next patches

Signed-off-by: Volker Lendecke <vl@samba.org>
2023-01-24 08:19:34 +00:00
Volker Lendecke
3c779de8cf smbd: Simplify smbXsrv_open_global_verify_record()
Don't depend on the record to be passed in, return NTSTATUS. The two
flags were a bit confusing to me, now NT_STATUS_OK means "found a
valid record with a live process", and NT_STATUS_FATAL_APP_EXIT means
we found a stale record from a crashed smbd

Signed-off-by: Volker Lendecke <vl@samba.org>
2023-01-24 08:19:34 +00:00
Volker Lendecke
f1a66267bc smbd: Save a few lines in smb2srv_open_lookup_replay_cache()
Directly initialize variables, don't leave dangling pointers in TDB_DATA

Signed-off-by: Volker Lendecke <vl@samba.org>
2023-01-24 08:19:34 +00:00
Volker Lendecke
35a32171b5 smbd: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-24 08:19:34 +00:00
Volker Lendecke
99de0cf6ff smbd: Modernize DBG statements in smbXsrv_open_global_store()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
c6f1e3a6a2 smbd: Make smbXsrv_open_global_id_to_key() a bit more type-safe
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
824b54174d smbd: Directly initialize key in smbXsrv_open_global_fetch_locked()
Don't leave the key.dptr pointer uninitialized

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
6deee159f1 smbd: Remove unused smbXsrv_open_global_key_to_id()
This isn't exactly rocket science we would need to keep around

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
a39a3400ba smbd: Slightly simplify smbXsrv_open_create()
Move allocation of smbXsrv_open_global0 out of
smbXsrv_open_global_allocate()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
b88db811db smbd: Remove smbXsrv_open_global_destructor()
This did not do much.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Volker Lendecke
d55880d93d smbd: Slightly simplify smb2srv_open_recreate()
This moves the bit-fiddling right next to the check we do,
"global_zeros" was only used for this one purpose and its assignment
was a few lines away.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-18 11:49:38 +00:00
Jeremy Allison
3d3d01cda8 s3: smbd: Tweak openat_pathref_dirfsp_nosymlink() to NULL out fsp->fsp_name after calling fd_close() on intermediate directories, rather than before.
vfs_virusfilter expects a non-NULL fsp->fsp_name to use for printing debugs
(it always indirects fsp->fsp_name). vfs_fruit also does the same, so would
also crash in fruit_close() with 'debug level = 10' and vfs_default:VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS = no
set (we don't test with that which is why we haven't noticed
this before).

Remove knownfail.

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

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): Fri Jan 13 08:33:47 UTC 2023 on sn-devel-184
2023-01-13 08:33:47 +00:00
Jeremy Allison
7ffa732d82 s3: smbd: Move check_fsp_open() and check_fsp() to smb1_reply.c
As these functions can implicitly call reply_nterror(..., NT_STATUS_INVALID_HANDLE)
they should never be available to SMB2 code paths.

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 Jan 11 08:17:04 UTC 2023 on sn-devel-184
2023-01-11 08:17:04 +00:00
Jeremy Allison
2fe95f6a30 s3: smbd: Ensure check_fsp_ntquota_handle() doesn't send SMB1 error packets.
check_fsp_ntquota_handle() is called from SMB2 codepaths as
well as from SMB1. Even in the SMB1 cases the callers of
check_fsp_ntquota_handle() handle sendng the error packet when
check_fsp_ntquota_handle returns false so on a 'return false'
we'd end up sending an error packet twice.

The SMB2 callers of check_fsp_ntquota_handle()
already check that fsp is valid, so there's
no danger of us sending an SMB1 error packet
over the SMB2 stream (so I'm not classing
this as a bug to be back-ported).

Fix check_fsp_ntquota_handle() by inlineing
the check_fsp_open() functionality without
the reply_nterror() calls.

This will allow the next commit to move check_fsp_open()
with the implicit reply_nterror() and also check_fsp()
(which calls check_fsp_open()) into the SMB1 smb1_reply.c
file as SMB1-only code.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2023-01-11 07:13:29 +00:00
Jeremy Allison
55f4ac65f9 s3: smbd: SMB1 check_fsp_open() implicitly calls reply_nterror(.., NT_STATUS_INVALID_HANDLE) on error so don't duplicate in reply_close().
We'd end up sending 2 SMB1 error packets in this case.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2023-01-11 07:13:29 +00:00
Volker Lendecke
8ee2034674 smbd: Use an idtree for local IDs
Volatile file handle IDs are purely per-process, in fact we used a
dbwrap_rbt for this. To get a unique ID we however have the
specialized idtree data structure, we don't need to repeat the
allocation algorithm that already exists there.

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): Tue Jan 10 01:23:38 UTC 2023 on sn-devel-184
2023-01-10 01:23:38 +00:00
Volker Lendecke
743df9009b smbd: Simplify smbXsrv_open_set_replay_cache() with dbwrap_store_bystring()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
bac265689a smbd: Simplify smbXsrv_open_set_replay_cache() with a struct assignment
Use a direct struct assignment instead of a function call

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
a71288e86b smbd: Remove smbXsrv_open->db_rec
This was only referenced in smbXsrv_open_close, but it was never
assigned anything but NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
fdca0558ef smbd: Remove a "can't happen" NULL check
This should really not happen, crashing would be the right response.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
0c709cb6b7 smbd: Use talloc_tos() for pushing smbXsrv_open_globalB
Use the toplevel talloc pool

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
88191630d2 lib: Use tdb_data_dbg() where appropriate
This changes the talloc hierarchy for a few callers, but as
talloc_tos() was initially designed exactly for this purpose (printing
SIDs in DEBUG), it should be okay.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
ea7abdc130 smbd: Avoid explicit ZERO_STRUCT()
Saves a few bytes of .text

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
db25f0a07c smbd: Move bytes from r/w data to r/o text section
Even const arrays of const strings need to be relocated at startup time.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
158314e0b1 smbd: Make get_safe_[[SI]VAL|ptr] static to smb1_lanman.c
SMB1-specific, only used there.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-01-10 00:28:37 +00:00
Volker Lendecke
dd86376294 smbd: Fix indentation
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jan  5 18:00:17 UTC 2023 on sn-devel-184
2023-01-05 18:00:17 +00:00
Volker Lendecke
17e9758b53 smbd: Fix CID 1518901 Logically dead code
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-05 17:04:34 +00:00
Volker Lendecke
c1be654988 smbd: Fix CID 1518902 Use after free
The SMB_REALLOC macro properly deals with failure to realloc, so
overwriting the target variable is correct here.

Signed-off-by: Volker Lendecke <vl@samba.org>
2023-01-05 17:04:34 +00:00
Volker Lendecke
9636b40b05 smbd: Use get_dirent_ea_size() also for BOTH_DIRECTORY_INFO
This is a bit more involved as readdir_attr_data needs to be looked
at. The meaning of this if-statements should be the same though,
readdir_attr_data can only be non-NULL if we don't have a reparse
point around. See the beginning of smbd_marshall_dir_entry().

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Jan  4 09:48:37 UTC 2023 on sn-devel-184
2023-01-04 09:48:37 +00:00
Volker Lendecke
dc98e56460 smbd: Factor out get_dirent_ea_size()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00
Volker Lendecke
d4f47d4b86 smbd: Modernize a DBG statement
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00
Volker Lendecke
eb0e911c73 smbd: Shorten a few lines
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00
Volker Lendecke
71610e3633 smbd: Move SMB_QUERY_FILE_UNIX_LINK to smb1_trans2.c
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00
Volker Lendecke
f48e2489ad smbd: Move get_posix_fsp() to smb1_trans2.c
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00
Volker Lendecke
6fc64f53a8 smbd: Move SMB_QUERY_POSIX_ACL to smb1_trans2.c
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2023-01-04 08:54:32 +00:00