]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
3 years agosmbd: Remove a "can't happen" NULL check
Volker Lendecke [Wed, 4 Jan 2023 09:13:31 +0000 (10:13 +0100)] 
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>
3 years agosmbd: Use talloc_tos() for pushing smbXsrv_open_globalB
Volker Lendecke [Wed, 4 Jan 2023 09:12:22 +0000 (10:12 +0100)] 
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>
3 years agolib: Use tdb_data_dbg() where appropriate
Volker Lendecke [Wed, 4 Jan 2023 08:52:50 +0000 (09:52 +0100)] 
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>
3 years agolib: Add tdb_data_dbg()
Volker Lendecke [Wed, 4 Jan 2023 08:40:06 +0000 (09:40 +0100)] 
lib: Add tdb_data_dbg()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Avoid explicit ZERO_STRUCT()
Volker Lendecke [Wed, 4 Jan 2023 07:50:28 +0000 (08:50 +0100)] 
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>
3 years agosmbd: Move bytes from r/w data to r/o text section
Volker Lendecke [Wed, 4 Jan 2023 05:22:55 +0000 (06:22 +0100)] 
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>
3 years agolib: Move 16 bytes to readonly .text segment
Volker Lendecke [Tue, 3 Jan 2023 18:32:41 +0000 (19:32 +0100)] 
lib: Move 16 bytes to readonly .text segment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolib: Remove unused smb_mkstemp prototype
Volker Lendecke [Tue, 3 Jan 2023 18:27:50 +0000 (19:27 +0100)] 
lib: Remove unused smb_mkstemp prototype

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolib: Move tab_depth() to reg_parse_prs.c
Volker Lendecke [Tue, 3 Jan 2023 18:14:24 +0000 (19:14 +0100)] 
lib: Move tab_depth() to reg_parse_prs.c

Wow, I did not know we still use prs_struct...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolib: Make map_share_mode_to_deny_mode() static to smbstatus
Volker Lendecke [Tue, 3 Jan 2023 17:45:14 +0000 (18:45 +0100)] 
lib: Make map_share_mode_to_deny_mode() static to smbstatus

At some point in the future this might disappear, we should really not
show DOS share modes in smbstatus. Maybe this can't be changed though.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Make get_safe_[[SI]VAL|ptr] static to smb1_lanman.c
Volker Lendecke [Tue, 3 Jan 2023 17:41:04 +0000 (18:41 +0100)] 
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>
3 years agoCVE-2022-38023 s3:rpc_server/netlogon: Avoid unnecessary loadparm_context allocations
Samuel Cabrero [Thu, 22 Dec 2022 15:32:40 +0000 (16:32 +0100)] 
CVE-2022-38023 s3:rpc_server/netlogon: Avoid unnecessary loadparm_context allocations

After s3 and s4 rpc servers merge the loadparm_context is available in
the dcesrv_context structure.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jan  9 15:17:14 UTC 2023 on sn-devel-184

3 years agoCVE-2022-38023 docs-xml/smbdotconf: The "server schannel require seal[:COMPUTERACCOUN...
Samuel Cabrero [Mon, 9 Jan 2023 11:17:48 +0000 (12:17 +0100)] 
CVE-2022-38023 docs-xml/smbdotconf: The "server schannel require seal[:COMPUTERACCOUNT]" options are also honoured by s3 netlogon server.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s3:rpc_server/netlogon: Check for global "server schannel require...
Samuel Cabrero [Thu, 22 Dec 2022 10:05:33 +0000 (11:05 +0100)] 
CVE-2022-38023 s3:rpc_server/netlogon: Check for global "server schannel require seal"

By default we'll now require schannel connections with privacy/sealing/encryption.

But we allow exceptions for specific computer/trust accounts.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s3:rpc_server/netlogon: make sure all _netr_LogonSamLogon*() calls...
Samuel Cabrero [Thu, 22 Dec 2022 08:29:04 +0000 (09:29 +0100)] 
CVE-2022-38023 s3:rpc_server/netlogon: make sure all _netr_LogonSamLogon*() calls go through dcesrv_netr_check_schannel()

Some checks are also required for _netr_LogonSamLogonEx().

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s3:rpc_server/netlogon: Use dcesrv_netr_creds_server_step_check()
Samuel Cabrero [Thu, 22 Dec 2022 15:30:26 +0000 (16:30 +0100)] 
CVE-2022-38023 s3:rpc_server/netlogon: Use dcesrv_netr_creds_server_step_check()

After s3 and s4 rpc servers merge we can avoid duplicated code.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s4:rpc_server/netlogon: Move schannel and credentials check functions...
Samuel Cabrero [Thu, 22 Dec 2022 13:03:23 +0000 (14:03 +0100)] 
CVE-2022-38023 s4:rpc_server/netlogon: Move schannel and credentials check functions to librpc

Will be used later by s3 netlogon server.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s4:rpc_server:wscript: Reformat following pycodestyle
Samuel Cabrero [Thu, 5 Jan 2023 17:13:09 +0000 (18:13 +0100)] 
CVE-2022-38023 s4:rpc_server:wscript: Reformat following pycodestyle

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 selftest:Samba3: avoid global 'server schannel = auto'
Samuel Cabrero [Thu, 22 Dec 2022 15:46:15 +0000 (16:46 +0100)] 
CVE-2022-38023 selftest:Samba3: avoid global 'server schannel = auto'

Instead of using the generic deprecated option use the specific
server require schannel:COMPUTERACCOUNT = no in order to allow
legacy tests for pass.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2022-38023 s3:rpc_server/netlogon: 'server schannel != yes' warning to dcesrv_int...
Samuel Cabrero [Wed, 21 Dec 2022 14:53:04 +0000 (15:53 +0100)] 
CVE-2022-38023 s3:rpc_server/netlogon: 'server schannel != yes' warning to dcesrv_interface_netlogon_bind

Follow s4 netlogon server changes and move the checks to the RPC bind
hook. Next commits will remove the s3 netr_creds_server_step_check()
function.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agosource3/wscript: Remove implicit int and implicit function declarations
Florian Weimer [Mon, 21 Nov 2022 13:12:43 +0000 (14:12 +0100)] 
source3/wscript: Remove implicit int and implicit function declarations

This should fix the remaining C89isms in these configure checks.

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

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jan  9 11:46:35 UTC 2023 on sn-devel-184

3 years agosource3/wscript: Fix detection of major/minor macros
Florian Weimer [Mon, 21 Nov 2022 12:53:17 +0000 (13:53 +0100)] 
source3/wscript: Fix detection of major/minor macros

These macros are only available via <sys/sysmacros.h> as of glibc
commit e16deca62e16f645213dffd4ecd1153c37765f17 ("[BZ #19239] Don't
include sys/sysmacros.h from sys/types.h."), which went into
glibc 2.28.

This is different from the usual C99 cleanups because it changes
the configure check result with existing compilers that usually
accept implicit function declarations.

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

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agobuildtools/wafsamba: Avoid calling lib_func without a prototype
Florian Weimer [Mon, 21 Nov 2022 12:37:41 +0000 (13:37 +0100)] 
buildtools/wafsamba: Avoid calling lib_func without a prototype

This is a backport of commit f4c0a750d4adebcf2342a44e85f04526c34
("WAF: Fix detection of linker features")
to buildtools/wafsamba/samba_conftests.py.  It fixes the check for
rpath support with compilers in strict C99 mode.

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

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agonsswitch: avoid calling pthread_getspecific() on an uninitialized key
Ralph Boehme [Thu, 5 Jan 2023 15:25:11 +0000 (16:25 +0100)] 
nsswitch: avoid calling pthread_getspecific() on an uninitialized key

Found by ASAN:

$ bin/stress-nss-libwbclient
...
==1639426==ERROR: AddressSanitizer: unknown-crash on address 0x7f3907d85000 at pc 0x7f3907d649fb bp 0x7ffc6545f5b0 sp 0x7ffc6545f5a8
READ of size 4 at 0x7f3907d85000 thread T0
    #0 0x7f3907d649fa in winbind_close_sock ../../nsswitch/wb_common.c:220
    #1 0x7f3907d65866 in winbind_destructor ../../nsswitch/wb_common.c:246
    #2 0x7f3907da5d3d in _dl_fini /usr/src/debug/glibc-2.35-20.fc36.x86_64/elf/dl-fini.c:142
    #3 0x7f3907241044 in __run_exit_handlers (/lib64/libc.so.6+0x41044)
    #4 0x7f39072411bf in exit (/lib64/libc.so.6+0x411bf)
    #5 0x7f3907229516 in __libc_start_call_main (/lib64/libc.so.6+0x29516)
    #6 0x7f39072295c8 in __libc_start_main_impl (/lib64/libc.so.6+0x295c8)
    #7 0x56236a2042b4 in _start (/data/git/samba/scratch3/bin/default/nsswitch/stress-nss-libwbclient+0x22b4)

Address 0x7f3907d85000 is a wild pointer inside of access range of size 0x000000000004.
SUMMARY: AddressSanitizer: unknown-crash ../../nsswitch/wb_common.c:220 in winbind_close_sock

The pthread key in wb_global_ctx.key is only initialized if
wb_thread_ctx_initialize() is called via get_wb_global_ctx() -> get_wb_thread_ctx().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jan  6 15:04:46 UTC 2023 on sn-devel-184

3 years agos4:lib/messaging: fix interaction between imessaging_context_destructor and irpc_dest...
Stefan Metzmacher [Sat, 31 Dec 2022 00:24:57 +0000 (01:24 +0100)] 
s4:lib/messaging: fix interaction between imessaging_context_destructor and irpc_destructor

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agothird_party: Update waf to version 2.0.25
Andreas Schneider [Wed, 4 Jan 2023 08:39:45 +0000 (09:39 +0100)] 
third_party: Update waf to version 2.0.25

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Fix indentation
Volker Lendecke [Thu, 5 Jan 2023 14:17:44 +0000 (15:17 +0100)] 
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

3 years agosmbd: Fix CID 1518901 Logically dead code
Volker Lendecke [Thu, 5 Jan 2023 14:17:14 +0000 (15:17 +0100)] 
smbd: Fix CID 1518901 Logically dead code

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Fix CID 1518902 Use after free
Volker Lendecke [Thu, 5 Jan 2023 14:11:10 +0000 (15:11 +0100)] 
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>
3 years agonsswitch: remove winbind_nss_mutex
Ralph Boehme [Wed, 21 Dec 2022 13:48:06 +0000 (14:48 +0100)] 
nsswitch: remove winbind_nss_mutex

We're now thread-safe by using TLS, so the global lock isn't needed anymore.

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): Thu Jan  5 12:34:35 UTC 2023 on sn-devel-184

3 years agonsswitch: leverage TLS if available in favour over global locking
Ralph Boehme [Sun, 6 Nov 2022 15:57:27 +0000 (16:57 +0100)] 
nsswitch: leverage TLS if available in favour over global locking

The global locking can lead to deadlocks when using nscd: when processing the
first request in winbind, when we know we call into code that will recurse into
winbind we call winbind_off() which sets an environment variable which is later
checked here in the nsswitch module.

But with nscd in the stack, we don't see the env variable in nsswitch, so when
we try to acquire the global lock again, it is already locked and we deadlock.

By using a thread specific winbindd_context, plus a few other thread local global
variables, we don't need a global lock anymore.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agonsswitch: prepare for removing global locking by using TLS
Ralph Boehme [Sun, 6 Nov 2022 15:57:27 +0000 (16:57 +0100)] 
nsswitch: prepare for removing global locking by using TLS

Switch to using TLS for all global variables. No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agonsswitch/stress-nss-libwbclient: also test after fork
Ralph Boehme [Mon, 31 Oct 2022 15:19:21 +0000 (16:19 +0100)] 
nsswitch/stress-nss-libwbclient: also test after fork

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agolibreplace: require TLS support if pthread support is available
Ralph Boehme [Tue, 15 Nov 2022 10:30:28 +0000 (11:30 +0100)] 
libreplace: require TLS support if pthread support is available

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agolibreplace: update comment on __thread support
Ralph Boehme [Thu, 27 Oct 2022 05:51:49 +0000 (07:51 +0200)] 
libreplace: update comment on __thread support

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agosmbd: Use get_dirent_ea_size() also for BOTH_DIRECTORY_INFO
Volker Lendecke [Mon, 2 Jan 2023 15:21:50 +0000 (16:21 +0100)] 
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

3 years agosmbd: Factor out get_dirent_ea_size()
Volker Lendecke [Mon, 2 Jan 2023 15:19:12 +0000 (16:19 +0100)] 
smbd: Factor out get_dirent_ea_size()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Add reparse tag definitions
Volker Lendecke [Mon, 2 Jan 2023 15:01:10 +0000 (16:01 +0100)] 
pylibsmb: Add reparse tag definitions

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Get reparse tag when listing directories
Volker Lendecke [Mon, 2 Jan 2023 13:29:12 +0000 (14:29 +0100)] 
pylibsmb: Get reparse tag when listing directories

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Modernize a DBG statement
Volker Lendecke [Wed, 28 Dec 2022 22:18:20 +0000 (23:18 +0100)] 
smbd: Modernize a DBG statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Shorten a few lines
Volker Lendecke [Wed, 28 Dec 2022 22:14:25 +0000 (23:14 +0100)] 
smbd: Shorten a few lines

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Remove duplicate/unused #defines
Volker Lendecke [Fri, 23 Dec 2022 08:21:25 +0000 (09:21 +0100)] 
smbd: Remove duplicate/unused #defines

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agotorture: Fix whitespace
Volker Lendecke [Sat, 24 Dec 2022 13:08:40 +0000 (14:08 +0100)] 
torture: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move SMB_QUERY_FILE_UNIX_LINK to smb1_trans2.c
Volker Lendecke [Mon, 2 Jan 2023 08:47:05 +0000 (09:47 +0100)] 
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>
3 years agosmbd: Move get_posix_fsp() to smb1_trans2.c
Volker Lendecke [Sat, 31 Dec 2022 16:41:16 +0000 (17:41 +0100)] 
smbd: Move get_posix_fsp() to smb1_trans2.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move SMB_QUERY_POSIX_ACL to smb1_trans2.c
Volker Lendecke [Sat, 31 Dec 2022 16:39:09 +0000 (17:39 +0100)] 
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>
3 years agosmbd: Move SMB_QUERY_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c
Volker Lendecke [Fri, 30 Dec 2022 15:26:38 +0000 (16:26 +0100)] 
smbd: Move SMB_QUERY_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Remove an unnecessary if-statement
Volker Lendecke [Fri, 30 Dec 2022 21:22:31 +0000 (22:22 +0100)] 
smbd: Remove an unnecessary if-statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Remove an unnecessary if-statement
Volker Lendecke [Fri, 30 Dec 2022 21:21:48 +0000 (22:21 +0100)] 
smbd: Remove an unnecessary if-statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move smb_set_posix_acl() to smb1_trans2.c
Volker Lendecke [Fri, 30 Dec 2022 19:49:11 +0000 (20:49 +0100)] 
smbd: Move smb_set_posix_acl() to smb1_trans2.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Make get_posix_fsp() public
Volker Lendecke [Fri, 30 Dec 2022 19:39:54 +0000 (20:39 +0100)] 
smbd: Make get_posix_fsp() public

This will go static again soon.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: smbd_do_qfilepathinfo() does not need lock_data anymore
Volker Lendecke [Fri, 30 Dec 2022 21:15:50 +0000 (22:15 +0100)] 
smbd: smbd_do_qfilepathinfo() does not need lock_data anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Handle SMB_QUERY_POSIX_LOCK() in call_trans2qfileinfo()
Volker Lendecke [Fri, 30 Dec 2022 21:12:23 +0000 (22:12 +0100)] 
smbd: Handle SMB_QUERY_POSIX_LOCK() in call_trans2qfileinfo()

smbd_do_qfilepathinfo() does not use the lock data anymore, we can
pass NULL/0 now.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Remove two variables never set after initialization
Volker Lendecke [Fri, 30 Dec 2022 20:43:06 +0000 (21:43 +0100)] 
smbd: Remove two variables never set after initialization

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move SMB_SET_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c
Volker Lendecke [Fri, 30 Dec 2022 15:26:38 +0000 (16:26 +0100)] 
smbd: Move SMB_SET_FILE_UNIX_[BASIC|INFO2] to smb1_trans2.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Make map_info2_flags_to_sbuf() public
Volker Lendecke [Fri, 30 Dec 2022 15:23:52 +0000 (16:23 +0100)] 
smbd: Make map_info2_flags_to_sbuf() public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Make smb_set_file_size() public
Volker Lendecke [Fri, 30 Dec 2022 15:23:27 +0000 (16:23 +0100)] 
smbd: Make smb_set_file_size() public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move handling smb_set_posix_lock() to smb1_trans2.c
Volker Lendecke [Thu, 29 Dec 2022 09:59:45 +0000 (10:59 +0100)] 
smbd: Move handling smb_set_posix_lock() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_SET_POSIX_LOCK through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setfileinfo() where we know we have a
fsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move smb_set_file_unix_hlink() to smb1_trans2.c
Volker Lendecke [Thu, 29 Dec 2022 09:47:12 +0000 (10:47 +0100)] 
smbd: Move smb_set_file_unix_hlink() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_SET_FILE_UNIX_HLINK through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setpathinfo() where we know we have a
path.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move smb_set_file_unix_link() to smb1_trans2.c
Volker Lendecke [Thu, 29 Dec 2022 09:44:33 +0000 (10:44 +0100)] 
smbd: Move smb_set_file_unix_link() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_SET_FILE_UNIX_LINK through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setpathinfo() where we know we have a
path.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move smb_posix_unlink() to smb1_trans2.c
Volker Lendecke [Wed, 28 Dec 2022 23:07:21 +0000 (00:07 +0100)] 
smbd: Move smb_posix_unlink() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_POSIX_PATH_UNLINK through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setpathinfo() where we know we have a
path.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Make smb_set_file_disposition_info() public
Volker Lendecke [Wed, 28 Dec 2022 23:06:58 +0000 (00:06 +0100)] 
smbd: Make smb_set_file_disposition_info() public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Move smb_posix_open() to smb1_trans2.c
Volker Lendecke [Wed, 28 Dec 2022 22:50:53 +0000 (23:50 +0100)] 
smbd: Move smb_posix_open() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_POSIX_PATH_OPEN through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setpathinfo() where we know we have a
path.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Make store_file_unix_basic[_info2] public
Volker Lendecke [Wed, 28 Dec 2022 22:47:42 +0000 (23:47 +0100)] 
smbd: Make store_file_unix_basic[_info2] public

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Factor out handle_trans2qfilepathinfo_result()
Volker Lendecke [Fri, 30 Dec 2022 11:23:58 +0000 (12:23 +0100)] 
smbd: Factor out handle_trans2qfilepathinfo_result()

The error handling will be used in other places.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Simplify call_trans2qfilepathinfo()
Volker Lendecke [Fri, 23 Dec 2022 17:20:15 +0000 (18:20 +0100)] 
smbd: Simplify call_trans2qfilepathinfo()

Move the file/path specific preparations to the respective callers.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Fix qfileinfo profiling
Volker Lendecke [Fri, 23 Dec 2022 16:23:36 +0000 (17:23 +0100)] 
smbd: Fix qfileinfo profiling

This ran under qpathinfo profiling

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Remove call_trans2setfilepathinfo()
Volker Lendecke [Fri, 30 Dec 2022 09:27:11 +0000 (10:27 +0100)] 
smbd: Remove call_trans2setfilepathinfo()

What's left was just a simple wrapper around smbd_do_setfilepathinfo()
and handle_trans2setfilepathinfo_result()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Factor out handle_trans2setfilepathinfo_result()
Volker Lendecke [Fri, 30 Dec 2022 09:13:08 +0000 (10:13 +0100)] 
smbd: Factor out handle_trans2setfilepathinfo_result()

This will be lifted up in the next patches. We can also remove the
REALLOC of *pparams, for this we only ever send 2 NULL bytes that we
stack-allocate now.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Simplify call_trans2setfilepathinfo()
Volker Lendecke [Fri, 23 Dec 2022 16:29:45 +0000 (17:29 +0100)] 
smbd: Simplify call_trans2setfilepathinfo()

Move the file/path specific preparations to the respective callers.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Fix setfileinfo profiling
Volker Lendecke [Fri, 23 Dec 2022 16:18:30 +0000 (17:18 +0100)] 
smbd: Fix setfileinfo profiling

This ran under setpathinfo profiling

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agos3: smbd: Strip any leading '\\' characters if the SMB2 DFS flag is set.
Jeremy Allison [Wed, 4 Jan 2023 02:28:54 +0000 (18:28 -0800)] 
s3: smbd: Strip any leading '\\' characters if the SMB2 DFS flag is set.

MacOS clients send SMB2 DFS pathnames as \server\share\file\name.

Ensure smbd can cope with this by stipping any leading '\\'
characters from an SMB2 packet with the DFS flag set.

Remove knownfail.

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

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  4 07:46:06 UTC 2023 on sn-devel-184

3 years agos3: smbtorture: Add SMB2-DFS-FILENAME-LEADING-BACKSLASH test.
Jeremy Allison [Wed, 4 Jan 2023 01:53:17 +0000 (17:53 -0800)] 
s3: smbtorture: Add SMB2-DFS-FILENAME-LEADING-BACKSLASH test.

Shows that we fail to cope with MacOSX clients that send a
(or more than one) leading '\\' character for an SMB2 DFS pathname.

I missed this in earlier tests as Windows, Linux, and
libsmbclient clients do NOT send a leading backslash
for SMB2 DFS paths. Only MacOSX (sigh:-).

Passes against Windows. Adds a knownfail for smbd.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agolib/replace - add extra check to bsd_attr_list
Andrew Walker [Tue, 27 Dec 2022 15:59:14 +0000 (10:59 -0500)] 
lib/replace - add extra check to bsd_attr_list

The FreeBSD extattr API may return success and truncated
namelist. We need to check for this in bsd_attr_list to
ensure that we don't accidentally read off the end of the
buffer. In the case of a truncated value, the pascal
strings for attr names will reflect the lengths as if
the value were not truncated. For example:
`58DosStrea`

In case of short read we now set error to ERANGE and
fail.

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

Signed-off-by: Andrew Walker <awalker@ixsystems.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Jan  2 14:27:23 UTC 2023 on sn-devel-184

3 years agoHappy New Year 2023!
Stefan Metzmacher [Sat, 31 Dec 2022 23:24:28 +0000 (23:24 +0000)] 
Happy New Year 2023!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sun Jan  1 00:24:02 UTC 2023 on sn-devel-184

3 years agos3:rpc_server/srvsvc: make sure we (re-)load all shares as root.
Stefan Metzmacher [Wed, 28 Dec 2022 12:50:45 +0000 (13:50 +0100)] 
s3:rpc_server/srvsvc: make sure we (re-)load all shares as root.

This fixes a regression in commit f03665bb7e8ea97699062630f2aa1bac4c5dfc7f

The use of reload_services() has a lot of side effects, e.g. reopen of
log files and other things, which are only useful in smbd, but not in rpcd_classic.
It was also unloading the user and registry shares we loaded a few lines
above.

We need to do all (re-)loading as root, otherwise we won't be able
to read root only smb.conf files, access registry shares, ...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Walker <awalker@ixsystems.com>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Dec 29 21:14:02 UTC 2022 on sn-devel-184

3 years agoselftest: add samba3.blackbox.registry_share
Stefan Metzmacher [Wed, 28 Dec 2022 15:18:40 +0000 (16:18 +0100)] 
selftest: add samba3.blackbox.registry_share

This demonstrates the regression introduced by
f03665bb7e8ea97699062630f2aa1bac4c5dfc7f, where
registry shares are no longer listed.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Walker <awalker@ixsystems.com>
3 years agos4:setup:tests: Use system ldbdump if we build with system ldb
Andreas Schneider [Thu, 22 Dec 2022 14:25:49 +0000 (15:25 +0100)] 
s4:setup:tests: Use system ldbdump if we build with system ldb

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Dec 23 15:31:31 UTC 2022 on sn-devel-184

3 years agopython:tests: Use system ldbsearch if we built against system libldb
Andreas Schneider [Thu, 22 Dec 2022 14:29:56 +0000 (15:29 +0100)] 
python:tests: Use system ldbsearch if we built against system libldb

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agopython:tests: Use system ldbdump if we build with system ldb
Andreas Schneider [Thu, 22 Dec 2022 14:16:04 +0000 (15:16 +0100)] 
python:tests: Use system ldbdump if we build with system ldb

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agopython:tests: Use system ldbsearch if we build with system libldb
Andreas Schneider [Thu, 22 Dec 2022 13:47:25 +0000 (14:47 +0100)] 
python:tests: Use system ldbsearch if we build with system libldb

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agonsswitch:tests: Use system_or_builddir_binary() for test_rfc2307_mapping
Andreas Schneider [Thu, 22 Dec 2022 15:54:30 +0000 (16:54 +0100)] 
nsswitch:tests: Use system_or_builddir_binary() for test_rfc2307_mapping

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for upgradeprovision-oldrelease
Andreas Schneider [Thu, 22 Dec 2022 13:43:45 +0000 (14:43 +0100)] 
testprogs: Use system_or_builddir_binary() for upgradeprovision-oldrelease

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for tombstones-expunge
Andreas Schneider [Thu, 22 Dec 2022 13:42:12 +0000 (14:42 +0100)] 
testprogs: Use system_or_builddir_binary() for tombstones-expunge

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_trust_token
Andreas Schneider [Thu, 22 Dec 2022 13:37:21 +0000 (14:37 +0100)] 
testprogs: Use system_or_builddir_binary() for test_trust_token

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_special_group
Andreas Schneider [Thu, 22 Dec 2022 13:36:29 +0000 (14:36 +0100)] 
testprogs: Use system_or_builddir_binary() for test_special_group

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_primary_group
Andreas Schneider [Thu, 22 Dec 2022 13:34:00 +0000 (14:34 +0100)] 
testprogs: Use system_or_builddir_binary() for test_primary_group

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_pkinit_simple
Andreas Schneider [Thu, 22 Dec 2022 13:32:59 +0000 (14:32 +0100)] 
testprogs: Use system_or_builddir_binary() for test_pkinit_simple

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_pkinit_pac
Andreas Schneider [Thu, 22 Dec 2022 13:31:54 +0000 (14:31 +0100)] 
testprogs: Use system_or_builddir_binary() for test_pkinit_pac

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_old_enctypes
Andreas Schneider [Thu, 22 Dec 2022 13:03:29 +0000 (14:03 +0100)] 
testprogs: Use system_or_builddir_binary() for test_old_enctypes

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_net_ads_dns
Andreas Schneider [Thu, 22 Dec 2022 13:02:04 +0000 (14:02 +0100)] 
testprogs: Use system_or_builddir_binary() for test_net_ads_dns

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_net_ads
Andreas Schneider [Thu, 22 Dec 2022 12:45:17 +0000 (13:45 +0100)] 
testprogs: Use system_or_builddir_binary() for test_net_ads

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_ldb_simple
Andreas Schneider [Thu, 22 Dec 2022 12:38:27 +0000 (13:38 +0100)] 
testprogs: Use system_or_builddir_binary() for test_ldb_simple

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_ldb
Andreas Schneider [Thu, 22 Dec 2022 12:34:39 +0000 (13:34 +0100)] 
testprogs: Use system_or_builddir_binary() for test_ldb

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_ktpass
Andreas Schneider [Thu, 22 Dec 2022 12:24:21 +0000 (13:24 +0100)] 
testprogs: Use system_or_builddir_binary() for test_ktpass

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_kinit_mit
Andreas Schneider [Thu, 22 Dec 2022 12:22:36 +0000 (13:22 +0100)] 
testprogs: Use system_or_builddir_binary() for test_kinit_mit

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_kinit_heimdal
Andreas Schneider [Thu, 22 Dec 2022 12:21:18 +0000 (13:21 +0100)] 
testprogs: Use system_or_builddir_binary() for test_kinit_heimdal

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for test_client_kerberos
Andreas Schneider [Thu, 22 Dec 2022 12:19:27 +0000 (13:19 +0100)] 
testprogs: Use system_or_builddir_binary() for test_client_kerberos

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for renamedc
Andreas Schneider [Thu, 22 Dec 2022 12:10:34 +0000 (13:10 +0100)] 
testprogs: Use system_or_builddir_binary() for renamedc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
3 years agotestprogs: Use system_or_builddir_binary() for ldapcmp_restoredc
Andreas Schneider [Thu, 22 Dec 2022 12:06:55 +0000 (13:06 +0100)] 
testprogs: Use system_or_builddir_binary() for ldapcmp_restoredc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>