samba.git
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: defer downgrade check until we found the accou...
Stefan Metzmacher [Fri, 25 Nov 2022 09:31:08 +0000 (10:31 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: defer downgrade check until we found the account in our SAM

We'll soon make it possible to use 'reject md5 servers:CLIENTACCOUNT$ = no',
which means we'll need use the account name from our SAM.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 docs-xml/smbdotconf: change 'reject md5 clients' default to yes
Stefan Metzmacher [Thu, 24 Nov 2022 17:26:18 +0000 (18:26 +0100)]
CVE-2022-38023 docs-xml/smbdotconf: change 'reject md5 clients' default to yes

AES is supported by Windows Server >= 2008R2, Windows (Client) >= 7 and Samba >= 4.0,
so there's no reason to allow md5 clients by default.
However some third party domain members may need it.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: require aes if weak crypto is disabled
Stefan Metzmacher [Fri, 25 Nov 2022 09:10:33 +0000 (10:10 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: require aes if weak crypto is disabled

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: split out dcesrv_netr_ServerAuthenticate3_chec...
Stefan Metzmacher [Fri, 25 Nov 2022 08:54:17 +0000 (09:54 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: split out dcesrv_netr_ServerAuthenticate3_check_downgrade()

We'll soon make it possible to use 'reject md5 servers:CLIENTACCOUNT$ = no',
which means we'll need the downgrade detection in more places.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:torture: use NETLOGON_NEG_SUPPORTS_AES by default
Stefan Metzmacher [Mon, 28 Nov 2022 14:02:13 +0000 (15:02 +0100)]
CVE-2022-38023 s4:torture: use NETLOGON_NEG_SUPPORTS_AES by default

For generic tests we should use the best available features.

And AES will be required by default soon.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 selftest:Samba4: avoid global 'server schannel = auto'
Stefan Metzmacher [Wed, 30 Nov 2022 11:26:01 +0000 (12:26 +0100)]
CVE-2022-38023 selftest:Samba4: 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: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: improve CVE-2020-1472(ZeroLogon) debug messages
Stefan Metzmacher [Wed, 30 Nov 2022 11:37:03 +0000 (12:37 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: improve CVE-2020-1472(ZeroLogon) debug messages

In order to avoid generating useless debug messages during make test,
we will use 'CVE_2020_1472:warn_about_unused_debug_level = 3'
and 'CVE_2020_1472:error_debug_level = 2' in order to avoid schannel warnings.

Review with: git show -w

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: re-order checking in dcesrv_netr_creds_server_...
Stefan Metzmacher [Wed, 30 Nov 2022 11:37:03 +0000 (12:37 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: re-order checking in dcesrv_netr_creds_server_step_check()

This will simplify the following changes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: add talloc_stackframe() to dcesrv_netr_creds_s...
Stefan Metzmacher [Mon, 12 Dec 2022 13:03:50 +0000 (14:03 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: add talloc_stackframe() to dcesrv_netr_creds_server_step_check()

This will simplify the following changes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: add a lp_ctx variable to dcesrv_netr_creds_ser...
Stefan Metzmacher [Mon, 12 Dec 2022 13:03:50 +0000 (14:03 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: add a lp_ctx variable to dcesrv_netr_creds_server_step_check()

This will simplify the following changes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s4:rpc_server/netlogon: 'server schannel != yes' warning to dcesrv_int...
Stefan Metzmacher [Tue, 6 Dec 2022 09:56:29 +0000 (10:56 +0100)]
CVE-2022-38023 s4:rpc_server/netlogon: 'server schannel != yes' warning to dcesrv_interface_netlogon_bind

This will simplify the following changes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 docs-xml/smbdotconf: change 'reject md5 servers' default to yes
Stefan Metzmacher [Thu, 24 Nov 2022 17:22:23 +0000 (18:22 +0100)]
CVE-2022-38023 docs-xml/smbdotconf: change 'reject md5 servers' default to yes

AES is supported by Windows >= 2008R2 and Samba >= 4.0 so there's no
reason to allow md5 servers by default.

Note the change in netlogon_creds_cli_context_global() is only cosmetic,
but avoids confusion while reading the code. Check with:

 git show -U35 libcli/auth/netlogon_creds_cli.c

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s3:winbindd: also allow per domain "winbind sealed pipes:DOMAIN" and...
Stefan Metzmacher [Wed, 30 Nov 2022 13:59:36 +0000 (14:59 +0100)]
CVE-2022-38023 s3:winbindd: also allow per domain "winbind sealed pipes:DOMAIN" and "require strong key:DOMAIN"

This avoids advising insecure defaults for the global options.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 s3:net: add and use net_warn_member_options() helper
Stefan Metzmacher [Wed, 30 Nov 2022 15:16:05 +0000 (16:16 +0100)]
CVE-2022-38023 s3:net: add and use net_warn_member_options() helper

This makes sure domain member related 'net' commands print warnings
about unsecure smb.conf options.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 libcli/auth: add/use netlogon_creds_cli_warn_options()
Stefan Metzmacher [Wed, 30 Nov 2022 13:47:33 +0000 (14:47 +0100)]
CVE-2022-38023 libcli/auth: add/use netlogon_creds_cli_warn_options()

This warns the admin about insecure options

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 libcli/auth: pass lp_ctx to netlogon_creds_cli_set_global_db()
Stefan Metzmacher [Wed, 30 Nov 2022 13:46:59 +0000 (14:46 +0100)]
CVE-2022-38023 libcli/auth: pass lp_ctx to netlogon_creds_cli_set_global_db()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agoCVE-2022-38023 docs-xml: improve wording for several options: "yields precedence...
Ralph Boehme [Tue, 6 Dec 2022 15:05:26 +0000 (16:05 +0100)]
CVE-2022-38023 docs-xml: improve wording for several options: "yields precedence" -> "is over-riden"

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
17 months agoCVE-2022-38023 docs-xml: improve wording for several options: "takes precedence"...
Ralph Boehme [Tue, 6 Dec 2022 15:00:36 +0000 (16:00 +0100)]
CVE-2022-38023 docs-xml: improve wording for several options: "takes precedence" -> "overrides"

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
17 months agoselftest: make filter-subunit much more efficient for large knownfail lists
Andrew Bartlett [Tue, 6 Dec 2022 04:16:00 +0000 (17:16 +1300)]
selftest: make filter-subunit much more efficient for large knownfail lists

By compiling the knownfail lists ahead of time we change a 20min test
into a 90sec test.

This could be improved further by combining this into a single regular expression,
but this is enough for now.  The 'reason' is thankfully not used.

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

Pair-programmed-with: Joseph Sutton <josephsutton@catalyst.net.nz>

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
17 months agos4/torture/smb2: avoid possibly closing undefined handle
Douglas Bagnall [Mon, 12 Dec 2022 21:11:17 +0000 (10:11 +1300)]
s4/torture/smb2: avoid possibly closing undefined handle

From OSS-Fuzz compilation:

Step #3 - "compile-honggfuzz-address-x86_64": ../../source4/torture/smb2/dir.c:1456:2: error: variable 'dir_handle' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
Step #3 - "compile-honggfuzz-address-x86_64":         torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
Step #3 - "compile-honggfuzz-address-x86_64":         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step #3 - "compile-honggfuzz-address-x86_64": ../../lib/torture/torture.h:748:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto'
Step #3 - "compile-honggfuzz-address-x86_64":                 torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
Step #3 - "compile-honggfuzz-address-x86_64":                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step #3 - "compile-honggfuzz-address-x86_64": ../../lib/torture/torture.h:316:6: note: expanded from macro 'torture_assert_ntstatus_equal_goto'
Step #3 - "compile-honggfuzz-address-x86_64":         if (!NT_STATUS_EQUAL(__got, __expected)) { \
Step #3 - "compile-honggfuzz-address-x86_64":             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step #3 - "compile-honggfuzz-address-x86_64": ../../source4/torture/smb2/dir.c:1582:24: note: uninitialized use occurs here
Step #3 - "compile-honggfuzz-address-x86_64":         smb2_util_close(tree, dir_handle);
Step #3 - "compile-honggfuzz-address-x86_64":                               ^~~~~~~~~~
Step #3 - "compile-honggfuzz-address-x86_64": ../../source4/torture/smb2/dir.c:1456:2: note: remove the 'if' if its condition is always false
Step #3 - "compile-honggfuzz-address-x86_64":         torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
Step #3 - "compile-honggfuzz-address-x86_64":         ^
Step #3 - "compile-honggfuzz-address-x86_64": ../../lib/torture/torture.h:748:3: note: expanded from macro 'torture_assert_ntstatus_ok_goto'
Step #3 - "compile-honggfuzz-address-x86_64":                 torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
Step #3 - "compile-honggfuzz-address-x86_64":                 ^
Step #3 - "compile-honggfuzz-address-x86_64": ../../lib/torture/torture.h:316:2: note: expanded from macro 'torture_assert_ntstatus_equal_goto'
Step #3 - "compile-honggfuzz-address-x86_64":         if (!NT_STATUS_EQUAL(__got, __expected)) { \
Step #3 - "compile-honggfuzz-address-x86_64":         ^
Step #3 - "compile-honggfuzz-address-x86_64": ../../source4/torture/smb2/dir.c:1434:2: note: variable 'dir_handle' is declared here
Step #3 - "compile-honggfuzz-address-x86_64":         struct smb2_handle dir_handle;
Step #3 - "compile-honggfuzz-address-x86_64":         ^

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec 13 07:45:20 UTC 2022 on sn-devel-184

17 months agosmbd: Remove a few "extern userdom_struct current_user_info"
Volker Lendecke [Wed, 30 Nov 2022 17:47:21 +0000 (18:47 +0100)]
smbd: Remove a few "extern userdom_struct current_user_info"

get_current_username() returns current_user_info.smb_name

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): Mon Dec 12 22:14:20 UTC 2022 on sn-devel-184

17 months agolib: Add get_current_user_info_domain()
Volker Lendecke [Wed, 30 Nov 2022 17:45:06 +0000 (18:45 +0100)]
lib: Add get_current_user_info_domain()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agolib: Make substitute.c's "remote_proto" static
Volker Lendecke [Wed, 30 Nov 2022 15:28:56 +0000 (16:28 +0100)]
lib: Make substitute.c's "remote_proto" static

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agovfs: Remove an unnecessary if statement
Volker Lendecke [Wed, 30 Nov 2022 14:14:08 +0000 (15:14 +0100)]
vfs: Remove an unnecessary if statement

get_local_machine_name() already does exactly this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agolib: Remove unused octal_string()
Volker Lendecke [Wed, 30 Nov 2022 13:17:29 +0000 (14:17 +0100)]
lib: Remove unused octal_string()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agolib: Remove fstring_sub() that was used just once
Volker Lendecke [Wed, 30 Nov 2022 13:14:43 +0000 (14:14 +0100)]
lib: Remove fstring_sub() that was used just once

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: Simplify dos_mode_msdfs()
Volker Lendecke [Tue, 6 Dec 2022 09:54:48 +0000 (10:54 +0100)]
smbd: Simplify dos_mode_msdfs()

Use ISDOT[DOT]

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agocldap_server: Align integer types
Volker Lendecke [Fri, 9 Dec 2022 15:25:25 +0000 (16:25 +0100)]
cldap_server: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: Simplify is_visible_fsp()
Volker Lendecke [Wed, 7 Dec 2022 09:49:47 +0000 (10:49 +0100)]
smbd: Simplify is_visible_fsp()

We don't need the wrapping if-statement, we check for the individual
flags. The compiler should be smart enough so that this is not a
difference in execution speed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotsocket: Fix the build on FreeBSD
Volker Lendecke [Fri, 9 Dec 2022 13:48:06 +0000 (14:48 +0100)]
tsocket: Fix the build on FreeBSD

FreeBSD does not have TCP_USER_TIMEOUT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agonsswitch: Align integer types
Volker Lendecke [Fri, 9 Dec 2022 13:36:04 +0000 (14:36 +0100)]
nsswitch: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: Fix whitespace
Volker Lendecke [Mon, 12 Dec 2022 11:53:22 +0000 (12:53 +0100)]
smbd: Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: test that a find with a mangled name works
Ralph Boehme [Thu, 1 Dec 2022 05:13:22 +0000 (06:13 +0100)]
torture: test that a find with a mangled name works

This was spawned by https://bugzilla.samba.org/show_bug.cgi?id=13472 back
then. Samba implement this correctly, just add this test found in the attic.

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): Sat Dec 10 00:07:09 UTC 2022 on sn-devel-184

17 months agotorture: convert mangling test to a suite
Ralph Boehme [Thu, 1 Dec 2022 05:09:09 +0000 (06:09 +0100)]
torture: convert mangling test to a suite

More tests to come...

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: add an interactive test that works out maximum name and path lenghts
Ralph Boehme [Tue, 29 Nov 2022 17:30:35 +0000 (18:30 +0100)]
torture: add an interactive test that works out maximum name and path lenghts

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: remove oplock paranoia check from file_find_dif()
Ralph Boehme [Thu, 1 Dec 2022 20:38:32 +0000 (21:38 +0100)]
smbd: remove oplock paranoia check from file_find_dif()

Since 4.16 stat opens will have a real fd, the only case where currently the fd
can still be -1 is a POSIX request on a symlink.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: add a test veryfing timestamps across rename
Ralph Boehme [Tue, 29 Nov 2022 05:20:31 +0000 (06:20 +0100)]
torture: add a test veryfing timestamps across rename

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agolib/torture: fix tctx arg usage in torture_assert_nttime_equal() macro
Ralph Boehme [Tue, 29 Nov 2022 11:07:19 +0000 (12:07 +0100)]
lib/torture: fix tctx arg usage in torture_assert_nttime_equal() macro

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: add another large directory enumeration performance test
Ralph Boehme [Fri, 25 Nov 2022 16:05:26 +0000 (17:05 +0100)]
torture: add another large directory enumeration performance test

This one renames one file per iteration and can also be used to torture any
directory caching the server may employ.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: print duration of smb2.dir.test_large_files
Ralph Boehme [Mon, 28 Nov 2022 17:05:28 +0000 (18:05 +0100)]
torture: print duration of smb2.dir.test_large_files

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: increase find buffer to 1 MB in multiple_smb2_search()
Ralph Boehme [Fri, 25 Nov 2022 16:03:37 +0000 (17:03 +0100)]
torture: increase find buffer to 1 MB in multiple_smb2_search()

This is used by performance tests that don't want to measure network latency but
fileserver IO latency.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agotorture: add another simple DOS attributes test
Ralph Boehme [Fri, 25 Nov 2022 15:02:27 +0000 (16:02 +0100)]
torture: add another simple DOS attributes test

- create file with ARCHIVE
- open file with ARCHIVE+HIDDEN+...
- check DOS attrs are still only ARCHIVE from the initial create

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agos4:torture: remove remaining checks if alloc_size is 0 on empty files
Ralph Boehme [Fri, 25 Nov 2022 10:33:30 +0000 (11:33 +0100)]
s4:torture: remove remaining checks if alloc_size is 0 on empty files

commit 55b2f247f9ba56516efba52481418966a777343e already remove a few of these,
but a few remained.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agovfs_zfsacl: fix mixed declaration and code error
Ralph Boehme [Thu, 28 Jul 2022 14:04:38 +0000 (16:04 +0200)]
vfs_zfsacl: fix mixed declaration and code error

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agovfs_zfsacl: remove unused function
Ralph Boehme [Thu, 28 Jul 2022 14:04:26 +0000 (16:04 +0200)]
vfs_zfsacl: remove unused function

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agolib/cmdline/tests: add missing includes
Ralph Boehme [Thu, 28 Jul 2022 14:04:09 +0000 (16:04 +0200)]
lib/cmdline/tests: add missing includes

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agos3:locking: split out del_share_mode_open_id()
Stefan Metzmacher [Fri, 11 Oct 2019 15:42:18 +0000 (17:42 +0200)]
s3:locking: split out del_share_mode_open_id()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: introduce 'delete_on_close' helper variables
Ralph Boehme [Fri, 25 Nov 2022 05:26:52 +0000 (06:26 +0100)]
smbd: introduce 'delete_on_close' helper variables

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agog_lock: check for zero timeout in g_lock_lock()
Ralph Boehme [Fri, 25 Mar 2022 14:50:54 +0000 (15:50 +0100)]
g_lock: check for zero timeout in g_lock_lock()

If the record is already locked check if the requested timeout is zero
and fail directly with NT_STATUS_LOCK_NOT_GRANTED.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: debug in smbd_smb2_close_send()
Ralph Boehme [Fri, 25 Nov 2022 05:02:31 +0000 (06:02 +0100)]
smbd: debug in smbd_smb2_close_send()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agos3/locking: Revert "s3:locking: Remove dead code"
Ralph Boehme [Thu, 7 Apr 2022 09:10:15 +0000 (11:10 +0200)]
s3/locking: Revert "s3:locking: Remove dead code"

This reverts commit de493a3e3b5b8d54f62c45072e27f2fefd4af43a:

    s3:locking: Remove dead code

    Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Isaac Boukris <iboukris@samba.org>
dbwrap_do_locked() correctly returns saved_errno which is a possible
errno returned by close() inside fd_close_posix_fn().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agos3:locking: re-add saved_errno handling to fd_close_posix()
Stefan Metzmacher [Fri, 11 Oct 2019 15:57:29 +0000 (17:57 +0200)]
s3:locking: re-add saved_errno handling to fd_close_posix()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: use fsp_getinfo_ask_sharemode() in open_file_ntcreate()
Ralph Boehme [Wed, 11 May 2022 16:14:11 +0000 (18:14 +0200)]
smbd: use fsp_getinfo_ask_sharemode() in open_file_ntcreate()

Note: this is a behaviour change in the non-default case when the user
has disabled "getinfo ask sharemode".

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()
Ralph Boehme [Wed, 11 May 2022 16:13:13 +0000 (18:13 +0200)]
smbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: add fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()
Ralph Boehme [Wed, 11 May 2022 16:09:10 +0000 (18:09 +0200)]
smbd: add fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: use reference_smb_fname_fsp_link() in rename_internals_fsp()
Ralph Boehme [Fri, 8 Apr 2022 09:54:01 +0000 (11:54 +0200)]
smbd: use reference_smb_fname_fsp_link() in rename_internals_fsp()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agosmbd: factor out reference_smb_fname_fsp_link() from parent_pathref()
Ralph Boehme [Fri, 8 Apr 2022 09:44:28 +0000 (11:44 +0200)]
smbd: factor out reference_smb_fname_fsp_link() from parent_pathref()

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agoFix memleak in _nss_winbind_initgroups_dyn
Sushmita Bhattacharya [Fri, 9 Dec 2022 10:55:53 +0000 (10:55 +0000)]
Fix memleak in _nss_winbind_initgroups_dyn

Free the response at the end of _nss_winbind_initgroups_dyn

Signed-off-by: Sushmita Bhattacharya <sushmita.bhattacharya@oracle.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agos3:libads: Fix debug message
Pavel Filipenský [Thu, 8 Dec 2022 14:19:09 +0000 (15:19 +0100)]
s3:libads: Fix debug message

652c8ce1 has introduced talloc_move() which zeroes kdc_str

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Dec  8 16:06:48 UTC 2022 on sn-devel-184

17 months agosmbd: Close the opened file in smbd_smb2_create_after_exec() error case
Volker Lendecke [Sat, 3 Dec 2022 20:43:06 +0000 (21:43 +0100)]
smbd: Close the opened file in smbd_smb2_create_after_exec() error case

smbd_smb2_create_after_exec() is only called when the file has
successfully been opened. When this fails in the middle, we can't
leave the fsp around. Hard to test with current code, but with reparse
point handling we'll have a reproducable case soon.

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 Dec  6 23:37:52 UTC 2022 on sn-devel-184

17 months agosmbd: Centralize error handling in smbd_smb2_create_after_exec()
Volker Lendecke [Sat, 3 Dec 2022 20:42:49 +0000 (21:42 +0100)]
smbd: Centralize error handling in smbd_smb2_create_after_exec()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 months agoCVE-2022-44640 HEIMDAL: asn1: invalid free in ASN.1 codec
Nicolas Williams [Wed, 10 Mar 2021 22:49:04 +0000 (16:49 -0600)]
CVE-2022-44640 HEIMDAL: asn1: invalid free in ASN.1 codec

Heimdal's ASN.1 compiler generates code that allows specially
crafted DER encodings of CHOICEs to invoke the wrong free function
on the decoded structure upon decode error.  This is known to impact
the Heimdal KDC, leading to an invalid free() of an address partly
or wholly under the control of the attacker, in turn leading to a
potential remote code execution (RCE) vulnerability.

This error affects the DER codec for all CHOICE types used in
Heimdal, though not all cases will be exploitable.  We have not
completed a thorough analysis of all the Heimdal components
affected, thus the Kerberos client, the X.509 library, and other
parts, may be affected as well.

This bug has been in Heimdal since 2005.  It was first reported by
Douglas Bagnall, though it had been found independently by the
Heimdal maintainers via fuzzing a few weeks earlier.

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

(cherry-picked from Heimdal commit 9c9dac2b169255bad9071eea99fa90b980dde767)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Dec  6 13:41:05 UTC 2022 on sn-devel-184

17 months agoCVE-2022-44640 selftest: Exclude Heimdal fuzz-inputs from source_chars test
Andrew Bartlett [Tue, 6 Dec 2022 02:11:05 +0000 (15:11 +1300)]
CVE-2022-44640 selftest: Exclude Heimdal fuzz-inputs from source_chars test

A new file will shorlty fail as it is binary input

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
17 months agolib/compression: Include missing stat header file
Anoop C S [Mon, 5 Dec 2022 10:54:46 +0000 (16:24 +0530)]
lib/compression: Include missing stat header file

<sys/stat.h> was missing from compression library tests which resulted
in the following compile time error:

../../lib/compression/tests/test_lzx_huffman.c: In function
                                                   ‘datablob_from_file’:
../../lib/compression/tests/test_lzx_huffman.c:383:21: error:
                                         storage size of ‘s’ isn’t known
  383 |         struct stat s;
      |                     ^
../../lib/compression/tests/test_lzx_huffman.c:389:15: warning:
    implicit declaration of function ‘fstat’ [-Wimplicit-function-declaration]
  389 |         ret = fstat(fileno(fh), &s);
      |               ^~~~~

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec  6 11:39:16 UTC 2022 on sn-devel-184

17 months agopython/samba: use s3 param samba config parsing
Noel Power [Fri, 25 Nov 2022 13:04:17 +0000 (13:04 +0000)]
python/samba: use s3 param samba config parsing

follup to commit: b4d7540bb4798e6801accf34a26fc0f2636bdd1f
fix another instance to use s3 config parsing which is more
forgiving (e.g. include directives that point to non existing
files are ignored)

Signed-off-by: Noel Power <npower@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Tue Dec  6 10:38:56 UTC 2022 on sn-devel-184

17 months agosmbd: Simplify symlink_target_below_conn()
Volker Lendecke [Sun, 4 Dec 2022 11:16:39 +0000 (12:16 +0100)]
smbd: Simplify symlink_target_below_conn()

readlink_talloc() deals exactly the same way with a NULL relname

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Dec  5 16:06:51 UTC 2022 on sn-devel-184

17 months agosmbd: Simplify readlink_talloc()
Volker Lendecke [Sun, 4 Dec 2022 11:14:12 +0000 (12:14 +0100)]
smbd: Simplify readlink_talloc()

SMB_VFS_READLINKAT() just looks at the basename, we can avoid the
relname being talloc'ed

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agosmbd: No dfs_filename_convert() in filename_convert_smb1_search_path()
Volker Lendecke [Mon, 24 Oct 2022 17:56:31 +0000 (19:56 +0200)]
smbd: No dfs_filename_convert() in filename_convert_smb1_search_path()

We further down call filename_convert_dirfsp(), which also has this
call. No need to copy that code here as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agolibsmb: Remove sync cli_posix_readlink() wrapper
Volker Lendecke [Sun, 4 Dec 2022 10:07:09 +0000 (11:07 +0100)]
libsmb: Remove sync cli_posix_readlink() wrapper

cli_readlink() now covers smb1 posix extensions as well

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agosmbclient: Use cli_readlink
Volker Lendecke [Wed, 12 Oct 2022 18:38:14 +0000 (20:38 +0200)]
smbclient: Use cli_readlink

Make smbclient's readlink command also work for SMB2 reparse style
symlink.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agolibsmb: Make readlink issue posix_readlink
Volker Lendecke [Wed, 12 Oct 2022 18:35:10 +0000 (20:35 +0200)]
libsmb: Make readlink issue posix_readlink

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agosmbd: Fix a comment
Volker Lendecke [Tue, 11 Oct 2022 15:01:28 +0000 (17:01 +0200)]
smbd: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agosmbd: Slightly simplify smb_posix_unlink()
Volker Lendecke [Wed, 12 Oct 2022 05:27:36 +0000 (07:27 +0200)]
smbd: Slightly simplify smb_posix_unlink()

We did check VALID_STAT() above.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
17 months agotests: Test error codes for SET_REPARSE_POINT
Volker Lendecke [Fri, 2 Dec 2022 09:34:55 +0000 (10:34 +0100)]
tests: Test error codes for SET_REPARSE_POINT

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: Try setting a 0-sized reparse point
Volker Lendecke [Fri, 2 Dec 2022 09:20:06 +0000 (10:20 +0100)]
tests: Try setting a 0-sized reparse point

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: Ignore symlink trusts flags in symlink error returns
Volker Lendecke [Fri, 2 Dec 2022 09:17:15 +0000 (10:17 +0100)]
tests: Ignore symlink trusts flags in symlink error returns

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agopylibsmb: Add symlink flags
Volker Lendecke [Fri, 2 Dec 2022 09:10:12 +0000 (10:10 +0100)]
pylibsmb: Add symlink flags

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agolib: Add symlink trust flags from dochelp
Volker Lendecke [Fri, 2 Dec 2022 09:06:31 +0000 (10:06 +0100)]
lib: Add symlink trust flags from dochelp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: Fix use of self.assertRaises()
Volker Lendecke [Fri, 2 Dec 2022 08:26:56 +0000 (09:26 +0100)]
tests: Fix use of self.assertRaises()

The with statement creates a new variable. I thought it opens a block
where "e" is only valid in that block. But instead it runs the whole
thing, expecting an exception somewhere. Learning python....

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: Show that we can write to a reparse point file
Volker Lendecke [Thu, 1 Dec 2022 14:14:03 +0000 (15:14 +0100)]
tests: Show that we can write to a reparse point file

Works against Windows 2016

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: Show that a directory with a reparse point can't be populated
Volker Lendecke [Thu, 1 Dec 2022 13:49:37 +0000 (14:49 +0100)]
tests: Show that a directory with a reparse point can't be populated

Works against Windows 2016

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agotests: IO_REPARSE_TAG_NOT_HANDLED is acceptable for unlink
Volker Lendecke [Thu, 1 Dec 2022 13:48:46 +0000 (14:48 +0100)]
tests: IO_REPARSE_TAG_NOT_HANDLED is acceptable for unlink

This happens when a path has an unknown reparse point in the middle

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
17 months agos3:utils: Fix stack smashing in net offlinejoin
Andreas Schneider [Mon, 5 Dec 2022 10:18:10 +0000 (11:18 +0100)]
s3:utils: Fix stack smashing in net offlinejoin

Cast from 'uint32_t *' (aka 'unsigned int *') to 'size_t *' (aka
'unsigned long *') increases required alignment from 4 to 8

==10343==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdc6784fc0 at pc 0x7f339f1ea500 bp 0x7ffdc6784ed0 sp 0x7ffdc6784ec8
WRITE of size 8 at 0x7ffdc6784fc0 thread T0
    #0 0x7f339f1ea4ff in fd_load ../../lib/util/util_file.c:220
    #1 0x7f339f1ea5a4 in file_load ../../lib/util/util_file.c:245
    #2 0x56363209a596 in net_offlinejoin_requestodj ../../source3/utils/net_offlinejoin.c:267
    #3 0x56363209a9d0 in net_offlinejoin ../../source3/utils/net_offlinejoin.c:74
    #4 0x56363208f61c in net_run_function ../../source3/utils/net_util.c:453
    #5 0x563631fe8a9f in main ../../source3/utils/net.c:1358
    #6 0x7f339b22c5af in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #7 0x7f339b22c678 in __libc_start_main_impl ../csu/libc-start.c:381
    #8 0x563631faf374 in _start ../sysdeps/x86_64/start.S:115

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Dec  5 12:05:24 UTC 2022 on sn-devel-184

17 months agonsswitch:tests: Use ldb(modify|search) from the system
Andreas Schneider [Thu, 1 Dec 2022 14:49:43 +0000 (15:49 +0100)]
nsswitch:tests: Use ldb(modify|search) from the system

If Samba is built against the system libldb, use the system tools.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Dec  5 09:36:40 UTC 2022 on sn-devel-184

17 months agomanpages: samba-dcerpcd: fix typo (add missing space)
Mikhail Novosyolov [Fri, 21 Oct 2022 09:08:39 +0000 (12:08 +0300)]
manpages: samba-dcerpcd: fix typo (add missing space)

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agotestprogs: Do not run tests if undump.sh is not available
Andreas Schneider [Sat, 3 Dec 2022 17:06:43 +0000 (18:06 +0100)]
testprogs: Do not run tests if undump.sh is not available

We don't include source4/selftest/provisions/ in source tarballs!

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Dec  5 08:22:29 UTC 2022 on sn-devel-184

17 months agotestprogs: If built against system db use the system tools in ldapcmp_restoredc.sh
Andreas Schneider [Sun, 4 Dec 2022 18:46:36 +0000 (19:46 +0100)]
testprogs: If built against system db use the system tools in ldapcmp_restoredc.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agotestprogs: If built against system db use the system tools in test_net_ads_dns.sh
Andreas Schneider [Sun, 4 Dec 2022 18:44:52 +0000 (19:44 +0100)]
testprogs: If built against system db use the system tools in test_net_ads_dns.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agotestprogs: If built against system db use the system tools in test_trust_token.sh
Andreas Schneider [Sun, 4 Dec 2022 18:34:35 +0000 (19:34 +0100)]
testprogs: If built against system db use the system tools in test_trust_token.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agotestprogs: If built against system db use the system tools in test_primary_group.sh
Andreas Schneider [Sat, 3 Dec 2022 16:48:33 +0000 (17:48 +0100)]
testprogs: If built against system db use the system tools in test_primary_group.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agolib:compression: Initialize variables
Andreas Schneider [Sat, 3 Dec 2022 17:20:53 +0000 (18:20 +0100)]
lib:compression: Initialize variables

lib/compression/tests/test_lzx_huffman.c: In function ‘test_lzxpress_huffman_overlong_matches’:
lib/compression/tests/test_lzx_huffman.c:1013:35: error: ‘j’ may be used uninitialized [-Werror=maybe-uninitialized]
 1013 |         assert_int_equal(score, i * j);
      |                                   ^
lib/compression/tests/test_lzx_huffman.c:979:19: note: ‘j’ was declared here
  979 |         size_t i, j;
      |                   ^
lib/compression/tests/test_lzx_huffman.c: In function ‘test_lzxpress_huffman_overlong_matches_abc’:
lib/compression/tests/test_lzx_huffman.c:1059:39: error: ‘k’ may be used uninitialized [-Werror=maybe-uninitialized]
 1059 |         assert_int_equal(score, i * j * k);
      |                                       ^
lib/compression/tests/test_lzx_huffman.c:1020:22: note: ‘k’ was declared here
 1020 |         size_t i, j, k;
      |                      ^
lib/compression/tests/test_lzx_huffman.c:1059:35: error: ‘j’ may be used uninitialized [-Werror=maybe-uninitialized]
 1059 |         assert_int_equal(score, i * j * k);
      |                                   ^
lib/compression/tests/test_lzx_huffman.c:1020:19: note: ‘j’ was declared here
 1020 |         size_t i, j, k;
      |                   ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Sun Dec  4 09:12:30 UTC 2022 on sn-devel-184

17 months agonfs4_acl: Add comment for setting ACL as root
Christof Schmitt [Tue, 29 Nov 2022 23:51:10 +0000 (16:51 -0700)]
nfs4_acl: Add comment for setting ACL as root

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Dec  2 08:02:13 UTC 2022 on sn-devel-184

17 months agoposix_acls: Make try_chown and unpack_nt_owners static
Christof Schmitt [Tue, 12 Jul 2022 23:35:37 +0000 (16:35 -0700)]
posix_acls: Make try_chown and unpack_nt_owners static

These functions are now only called from check_chown in posix_acls.c

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agonfs4_acls: Call chown_if_needed function to remove duplicate code
Christof Schmitt [Tue, 12 Jul 2022 23:32:08 +0000 (16:32 -0700)]
nfs4_acls: Call chown_if_needed function to remove duplicate code

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agoposix_acl: Move chown checks to new function
Christof Schmitt [Tue, 29 Nov 2022 23:46:24 +0000 (16:46 -0700)]
posix_acl: Move chown checks to new function

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agoposix_acls: Remove redundant call to save mode
Christof Schmitt [Tue, 12 Jul 2022 23:08:07 +0000 (16:08 -0700)]
posix_acls: Remove redundant call to save mode

The same assignment is already done earlier, and nothing is changed in
between.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
17 months agolib/compression/lzxpress: fix our slow compression
Douglas Bagnall [Thu, 24 Nov 2022 23:46:08 +0000 (12:46 +1300)]
lib/compression/lzxpress: fix our slow compression

This uses the same hash table method as lzxpress_huffman, though the
code can't be directly reused as the sizes of the offsets is
different, and there is not a block processing step here.

This will worsen the compression ratio compared to the exhaustive
search we previously used, though we still perform better than
Windows. To put numbers on it, the test files used to compress to 0.91
of Windows' compression size, and now they compress to 0.96.

On the other hand this is many orders of magnitude faster. It is
difficult to say exactly how much faster -- while the testsuite time
has only improved 200-fold (from 7 minutes to 2 seconds), most of the
remaining 2 seconds is used in data generation and management, not
compression. OSSFuzz consistently finds new vectors that time out
after a minute; on these we'll see nearly an order of magnitude of
orders of magnitude inprovement.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Autobuild-User(master): Joseph Sutton <jsutton@samba.org>
Autobuild-Date(master): Fri Dec  2 00:00:04 UTC 2022 on sn-devel-184

17 months agolib/compression/lzxpress: shift encoding into helper functions
Douglas Bagnall [Thu, 24 Nov 2022 23:38:11 +0000 (12:38 +1300)]
lib/compression/lzxpress: shift encoding into helper functions

This makes it easier to rework the encoding decision to depend on a
hash table match rather than the current exhaustive search.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
17 months agolib/compression/lzxpress compression: use a write context struct
Douglas Bagnall [Thu, 17 Nov 2022 03:15:00 +0000 (16:15 +1300)]
lib/compression/lzxpress compression: use a write context struct

This will make it possible to move encoding operations into helper
functions, which will make it easier to restructure the code to use a
hash table for faster matching.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
17 months agolib/compression: more tests for lzxpress plain compression
Douglas Bagnall [Wed, 23 Nov 2022 22:44:35 +0000 (11:44 +1300)]
lib/compression: more tests for lzxpress plain compression

These are based on (i.e. copied and pasted from) the LZ77 + Huffman
tests.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>