]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
13 months agosmbd: check negotiate before the create context is handled
Jule Anger [Tue, 3 Sep 2024 12:42:03 +0000 (14:42 +0200)] 
smbd: check negotiate before the create context is handled

So far, the create context is used as it is sent by the client.
Now we first check whether posix extensions are negotiated.

Pair-Programmed-With: Ralph Boehme <slow@samba.org>
Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agolibsmb: add cli_get_posix_fs_info() for smb2
Jule Anger [Tue, 3 Sep 2024 12:41:40 +0000 (14:41 +0200)] 
libsmb: add cli_get_posix_fs_info() for smb2

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agosmbd: add SMB2_FS_POSIX_INFORMATION
Ralph Boehme [Wed, 26 Jun 2024 11:11:18 +0000 (13:11 +0200)] 
smbd: add SMB2_FS_POSIX_INFORMATION

Needed as in_file_info_class type to query posix filesystem information.
Used in the subsequent commit.

Pair-Programmed-With: Jule Anger <janger@samba.org>
Signed-off-by: Jule Anger <janger@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agolibsmb: make cli_get_posix_fs_info() asynchronous
Jule Anger [Mon, 30 Sep 2024 13:48:16 +0000 (15:48 +0200)] 
libsmb: make cli_get_posix_fs_info() asynchronous

Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agosmbtorture: Allow debugging output to be configured using smb.conf parameters
Pavel Filipenský [Sun, 13 Oct 2024 19:57:27 +0000 (21:57 +0200)] 
smbtorture: Allow debugging output to be configured using smb.conf parameters

It might be useful to see timestamps for some smbtorture tests.

Timestamps can be printed via 'debug syslog format=always'.
It can be specified either in smb.conf or directly via smbtorture option
-T 'OPTION=VALUE'     smb.conf option line

However, smbtorture is not evaluating the option. It needs to call
reopen_logs()->debug_set_settings() to copy
'Globals.debug_syslog_format' to 'state->settings.debug_syslog_format'

$ bin/smbtorture3 //foo/bar -U% LOCAL-G-LOCK4 -d10 -T 'debug syslog format=always'

Before:

dbwrap_lock_order_unlock: release lock order 3 for /home/pfilipen/ws/projects/samba/smbtorture/st/client/lockdir/g_lock.tdb
waited
child 2473726 exited with 0
g_lock_lock_retry: watch_recv returned NT_STATUS_OK

After (see 1 sec delay):

2024-10-13T21:26:56.476859+00:00 addc.addom.samba.example.com smbtorture[2473806]: dbwrap_lock_order_unlock: release lock order 3 for /home/pfilipen/ws/projects/samba/smbtorture/st/client/lockdir/g_lock.tdb
waited
child 2473807 exited with 0
2024-10-13T21:26:57.487363+00:00 addc.addom.samba.example.com smbtorture[2473806]: g_lock_lock_retry: watch_recv returned NT_STATUS_OK

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
13 months agodcesrv_core: better fault codes dcesrv_auth_prepare_auth3()
Stefan Metzmacher [Fri, 13 Nov 2020 01:47:51 +0000 (02:47 +0100)] 
dcesrv_core: better fault codes dcesrv_auth_prepare_auth3()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Oct 10 15:17:46 UTC 2024 on atb-devel-224

13 months agodcesrv_core: fix the auth3 for large ntlmssp messages
Stefan Metzmacher [Fri, 13 Nov 2020 09:55:43 +0000 (10:55 +0100)] 
dcesrv_core: fix the auth3 for large ntlmssp messages

I know finding any real logic in reading the patch,
doesn't really show what's going on. I tried hard
to simplify it, but this is the only way I found
that fixed the test_auth_pad_ntlm_2889_auth3 test
without breaking other tests...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agogensec:spnego: ignore trailing bytes in SPNEGO_SERVER_START state
Stefan Metzmacher [Wed, 11 Nov 2020 16:03:29 +0000 (17:03 +0100)] 
gensec:spnego: ignore trailing bytes in SPNEGO_SERVER_START state

This matches Windows (at least Server 2012_R2).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agogensec:ntlmssp: only allow messages up to 2888 bytes
Stefan Metzmacher [Thu, 12 Nov 2020 09:00:07 +0000 (10:00 +0100)] 
gensec:ntlmssp: only allow messages up to 2888 bytes

This matches Windows (at least Server 2012_R2).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: alter_context logon failures should result in DCERPC_FAULT_ACCESS_DENIED
Stefan Metzmacher [Thu, 12 Nov 2020 15:41:21 +0000 (16:41 +0100)] 
dcesrv_core: alter_context logon failures should result in DCERPC_FAULT_ACCESS_DENIED

We should use DCERPC_FAULT_ACCESS_DENIED as default for
gensec status results of e.g. NT_STATUS_LOGON_FAILURE or
NT_STATUS_INVALID_PARAMTER.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: a failure from gensec_update results in NAK_REASON_INVALID_CHECKSUM
Stefan Metzmacher [Thu, 12 Nov 2020 15:41:05 +0000 (16:41 +0100)] 
dcesrv_core: a failure from gensec_update results in NAK_REASON_INVALID_CHECKSUM

We already report that for gensec_start_mech_by_authtype() failures,
but we also need to do that for any invalid authentication.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcerpc_util: let dcerpc_pull_auth_trailer() ignore data_and_pad for bind, alter,...
Stefan Metzmacher [Wed, 11 Nov 2020 16:07:54 +0000 (17:07 +0100)] 
dcerpc_util: let dcerpc_pull_auth_trailer() ignore data_and_pad for bind, alter, auth3

Sometimes Windows sends 3 presentation contexts (NDR32, NDR64,
BindTimeFeatureNegotiation) in the first BIND of an association.

Binding an additional connection to the association seems to
reuse the BIND buffer and just changes the num_contexts field from
3 to 2 and leaves the BindTimeFeatureNegotiation context as padding
in places.

Note, the auth_pad_length field is send as 0 in that case,
which means we need to ignore it completely, as well as any
padding before the auth header.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcerpc_util: let dcerpc_pull_auth_trailer() expose the reject reason
Stefan Metzmacher [Wed, 11 Nov 2020 16:59:45 +0000 (17:59 +0100)] 
dcerpc_util: let dcerpc_pull_auth_trailer() expose the reject reason

If dcerpc_pull_auth_trailer() returns NT_STATUS_RPC_PROTOCOL_ERROR
it will return the BIND reject code in auth->auth_context_id.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcerpc_util: let dcerpc_pull_auth_trailer() check that auth_offset is 4 bytes aligned
Stefan Metzmacher [Wed, 11 Nov 2020 16:05:21 +0000 (17:05 +0100)] 
dcerpc_util: let dcerpc_pull_auth_trailer() check that auth_offset is 4 bytes aligned

That what Windows also asserts.

It also makes sure that ndr_pull_dcerpc_auth() will
start with ndr->offset = 0 and don't tries to eat
possible padding.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: test invalid schannel binds
Stefan Metzmacher [Thu, 12 Nov 2020 10:10:46 +0000 (11:10 +0100)] 
tests/dcerpc/raw_protocol: test invalid schannel binds

Note the ad_member will keep these as expected failures,
as it doesn't provide the netlogon service,
while the knownfail for the ADDC is only temporary.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: add more tests for auth_pad alignment
Stefan Metzmacher [Thu, 12 Nov 2020 16:22:19 +0000 (17:22 +0100)] 
tests/dcerpc/raw_protocol: add more tests for auth_pad alignment

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: add tests for max auth_padding, auth_len or auth_offset
Stefan Metzmacher [Wed, 11 Nov 2020 00:19:23 +0000 (01:19 +0100)] 
tests/dcerpc/raw_protocol: add tests for max auth_padding, auth_len or auth_offset

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: fix comment in test_spnego_change_auth_type1
Stefan Metzmacher [Tue, 17 Nov 2020 16:44:51 +0000 (17:44 +0100)] 
tests/dcerpc/raw_protocol: fix comment in test_spnego_change_auth_type1

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: test_no_auth_ctx_request
Stefan Metzmacher [Tue, 17 Nov 2020 09:05:41 +0000 (10:05 +0100)] 
tests/dcerpc/raw_protocol: test_no_auth_ctx_request

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: introduce dcesrv_connection->transport_max_recv_frag
Stefan Metzmacher [Thu, 12 Nov 2020 15:38:32 +0000 (16:38 +0100)] 
dcesrv_core: introduce dcesrv_connection->transport_max_recv_frag

The max fragment size depends on the transport.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: run test_neg_xmit_ffff_ffff over tcp and smb
Stefan Metzmacher [Mon, 16 Nov 2020 14:01:49 +0000 (15:01 +0100)] 
tests/dcerpc/raw_protocol: run test_neg_xmit_ffff_ffff over tcp and smb

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: add more verbose debugging for missing association groups
Stefan Metzmacher [Mon, 16 Nov 2020 15:58:35 +0000 (16:58 +0100)] 
dcesrv_core: add more verbose debugging for missing association groups

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agoRawDCERPCTest: add some more auth_length related asserts
Stefan Metzmacher [Wed, 11 Nov 2020 15:49:25 +0000 (16:49 +0100)] 
RawDCERPCTest: add some more auth_length related asserts

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agoRawDCERPCTest: split prepare_pdu() and send_pdu_blob() out of send_pdu()
Stefan Metzmacher [Mon, 9 Nov 2020 13:00:43 +0000 (14:00 +0100)] 
RawDCERPCTest: split prepare_pdu() and send_pdu_blob() out of send_pdu()

This will make it possible to alter pdus before sending them to the
server.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agos4:librpc: provide py_schannel bindings
Stefan Metzmacher [Thu, 12 Nov 2020 09:34:38 +0000 (10:34 +0100)] 
s4:librpc: provide py_schannel bindings

This will be used in the dcerpc.raw_protocol test.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcerpc_util: don't allow auth_padding for BIND, ALTER_CONTEXT and AUTH3 pdus
Stefan Metzmacher [Tue, 24 Sep 2024 07:32:24 +0000 (09:32 +0200)] 
dcerpc_util: don't allow auth_padding for BIND, ALTER_CONTEXT and AUTH3 pdus

This is how Windows 2022 (and 2025 preview) behaves...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: add more test for auth padding during ALTER_CONTEXT/AUTH3
Stefan Metzmacher [Tue, 24 Sep 2024 07:56:05 +0000 (09:56 +0200)] 
tests/dcerpc/raw_protocol: add more test for auth padding during ALTER_CONTEXT/AUTH3

The aim is to keep testing the code paths, which are no longer
testing because allow_bind_auth_pad is false now, which
means the existing tests fail directly at the BIND,
but we also want to test the error handling on
ALTER_CONTEXT (and AUTH3).

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: return NAK_REASON_PROTOCOL_VERSION_NOT_SUPPORTED for binds without contexts
Stefan Metzmacher [Tue, 24 Sep 2024 07:05:15 +0000 (09:05 +0200)] 
dcesrv_core: return NAK_REASON_PROTOCOL_VERSION_NOT_SUPPORTED for binds without contexts

This is the error Windows 2022 (and 2025 preview) return.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agodcesrv_core: disconnect after a fault with non AUTH_LEVEL_CONNECT bind
Stefan Metzmacher [Mon, 23 Sep 2024 14:09:39 +0000 (16:09 +0200)] 
dcesrv_core: disconnect after a fault with non AUTH_LEVEL_CONNECT bind

Without an auth context using DCERPC_AUTH_LEVEL_PACKET or higher
the fault to reject requests with an invalid auth level
should trigger a disconnect after sending the fault to
the client.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agos4:selftest: only run ad_member with AUTH_LEVEL_CONNECT_LSA=1
Stefan Metzmacher [Mon, 23 Sep 2024 13:13:59 +0000 (15:13 +0200)] 
s4:selftest: only run ad_member with AUTH_LEVEL_CONNECT_LSA=1

We only want to test against
'allow dcerpc auth level connect:lsarpc = yes' once
in order to have the related code tests.
We use the ad_memeber for that special test and
use the default on the tested ADDC.

This reveals some knownfails, which will be fixed in
the next commit...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agotests/dcerpc/raw_protocol: pass against Windows 2022 and require special env vars...
Stefan Metzmacher [Mon, 23 Sep 2024 13:13:59 +0000 (15:13 +0200)] 
tests/dcerpc/raw_protocol: pass against Windows 2022 and require special env vars for legacy servers

Test works against Windows 2022 and works like this:

SMB_CONF_PATH=/dev/null SERVER=172.31.9.118 \
  TARGET_HOSTNAME=w2022-118.w2022-l7.base IGNORE_RANDOM_PAD=1 \
  DOMAIN=W2022-L7 REALM=W2022-L7.BASE \
  USERNAME=administrator PASSWORD=A1b2C3d4 \
  python/samba/tests/dcerpc/raw_protocol.py -v -f TestDCERPC_BIND

Against a legacy Windows2012R2 server this still works:

SMB_CONF_PATH=/dev/null SERVER=172.31.9.188 \
  TARGET_HOSTNAME=w2012r2-188.w2012r2-l6.base ALLOW_BIND_AUTH_PAD=1 \
  LEGACY_BIND_NACK_NO_REASON=1 AUTH_LEVEL_CONNECT_LSA=1 \
  IGNORE_RANDOM_PAD=1 DOMAIN=W2012R2-L6 REALM=W2012R2-L6.BASE \
  USERNAME=administrator PASSWORD=A1b2C3d4 \
  python/samba/tests/dcerpc/raw_protocol.py -v -f TestDCERPC_BIND

Currently Samba behaves like 2012R2, but the next commits
will change that...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agoRawDCERPCTest: ignore errors in smb_pipe_socket.close()
Stefan Metzmacher [Sat, 21 Sep 2024 10:32:55 +0000 (12:32 +0200)] 
RawDCERPCTest: ignore errors in smb_pipe_socket.close()

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agos4:tortore/rpc: let rpc.backupkey without privacy pass against Windows 2022
Stefan Metzmacher [Wed, 25 Sep 2024 21:10:25 +0000 (23:10 +0200)] 
s4:tortore/rpc: let rpc.backupkey without privacy pass against Windows 2022

The server disconnects after the first fault.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
13 months agos3:smbd: avoid false positives for got_oplock and have_other_lease in delay_for_oplock_fn
Stefan Metzmacher [Fri, 30 Aug 2024 12:16:12 +0000 (14:16 +0200)] 
s3:smbd: avoid false positives for got_oplock and have_other_lease in delay_for_oplock_fn

stat opens should not cause a oplock/lease downgrade if
they don't have a lease attached to itself.

Note that opens broken to NONE still count if they are
non-stat opens...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Oct 10 13:59:18 UTC 2024 on atb-devel-224

13 months agos3:smbd: allow reset_share_mode_entry() to handle more than one durable handle
Stefan Metzmacher [Thu, 29 Aug 2024 16:43:14 +0000 (18:43 +0200)] 
s3:smbd: allow reset_share_mode_entry() to handle more than one durable handle

This means that multiple durable handles with RH leases can
co-exist now... Before only the last remaining durable handle
was able to pass the SMB_VFS_DURABLE_DISCONNECT() step.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos3:smbd: let durable_reconnect_fn already check for a disconnected handle with the...
Stefan Metzmacher [Thu, 29 Aug 2024 18:20:23 +0000 (20:20 +0200)] 
s3:smbd: let durable_reconnect_fn already check for a disconnected handle with the correct file_id

We'll soon allow more than one disconnected durable handle, so
we need to find the correct one instead of assuming only a single
one.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: add smb2.durable-v2-open.{keep,purge}-disconnected-* tests
Stefan Metzmacher [Wed, 4 Sep 2024 16:18:43 +0000 (18:18 +0200)] 
s4:torture/smb2: add smb2.durable-v2-open.{keep,purge}-disconnected-* tests

These demonstrate which durables handles are kept and which are purged
because of various opens, writes or renames.

smb2.durable-v2-open.keep-disconnected-rh-with-stat-open
smb2.durable-v2-open.keep-disconnected-rh-with-rh-open
smb2.durable-v2-open.keep-disconnected-rh-with-rwh-open
smb2.durable-v2-open.keep-disconnected-rwh-with-stat-open

smb2.durable-v2-open.purge-disconnected-rwh-with-rwh-open
smb2.durable-v2-open.purge-disconnected-rwh-with-rh-open
smb2.durable-v2-open.purge-disconnected-rh-with-share-none-open
smb2.durable-v2-open.purge-disconnected-rh-with-write
smb2.durable-v2-open.purge-disconnected-rh-with-rename

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15649
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15651
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15708

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: add smb2.durable-v2-open.{[non]stat[RH]-and,two-same,two-different...
Stefan Metzmacher [Wed, 28 Aug 2024 14:48:27 +0000 (16:48 +0200)] 
s4:torture/smb2: add smb2.durable-v2-open.{[non]stat[RH]-and,two-same,two-different}-lease

These show that it's possible to have durable handles in addition
of stat opens, as well as multiple durable opens with RH leases.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos3:smbd: only store durable handles with byte range locks when having WRITE lease
Stefan Metzmacher [Fri, 30 Aug 2024 16:10:16 +0000 (18:10 +0200)] 
s3:smbd: only store durable handles with byte range locks when having WRITE lease

This simplifies the reconnect assumptions, when we want to allow
more than one durable handle on a file for multiple clients with
READ+HANDLE leases.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: add smb2.durable-v2-open.lock-{oplock,lease,noW-lease}
Stefan Metzmacher [Fri, 30 Aug 2024 15:38:02 +0000 (17:38 +0200)] 
s4:torture/smb2: add smb2.durable-v2-open.lock-{oplock,lease,noW-lease}

This demonstrates that a W lease is required for a
durable handle to be durable when it has byte range locks.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: add smb2.durable-open.lock-noW-lease
Stefan Metzmacher [Fri, 30 Aug 2024 15:38:02 +0000 (17:38 +0200)] 
s4:torture/smb2: add smb2.durable-open.lock-noW-lease

This demonstrates that a W lease is required for a
durable handle to be durable when it has byte range locks.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: improve error handling in durable_v2_open.c
Stefan Metzmacher [Fri, 30 Aug 2024 12:22:24 +0000 (14:22 +0200)] 
s4:torture/smb2: improve error handling in durable_v2_open.c

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos4:torture/smb2: improve error handling in durable_open.c
Stefan Metzmacher [Fri, 30 Aug 2024 12:22:24 +0000 (14:22 +0200)] 
s4:torture/smb2: improve error handling in durable_open.c

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agoctdb-build: Add missing ctdb-tcp dependency
Anoop C S [Tue, 8 Oct 2024 06:50:45 +0000 (12:20 +0530)] 
ctdb-build: Add missing ctdb-tcp dependency

Since 02c9e7a63f00998bb0dae2e8c6bd8e020e9408da, common/path.h is
included within ctdb/tcp/tcp_connect.c. Therefore add ctdb-util
as a dependency for ctdb-tcp.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Oct  8 12:27:17 UTC 2024 on atb-devel-224

13 months agoctdb-server: Use find_public_ip_vnn() in a couple of extra places
Martin Schwenke [Thu, 29 Aug 2024 08:38:58 +0000 (18:38 +1000)] 
ctdb-server: Use find_public_ip_vnn() in a couple of extra places

Reorder code to use early returns, modernise debug.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Oct  8 06:42:04 UTC 2024 on atb-devel-224

13 months agoctdb-server: Clean up find_public_ip_vnn()
Martin Schwenke [Thu, 29 Aug 2024 08:27:54 +0000 (18:27 +1000)] 
ctdb-server: Clean up find_public_ip_vnn()

Fix the comment (NULL versus -1), apply some README.Coding.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Ensure CTDB_BASE is set, don't fetch it
Martin Schwenke [Fri, 9 Aug 2024 00:53:46 +0000 (10:53 +1000)] 
ctdb-daemon: Ensure CTDB_BASE is set, don't fetch it

Uses of CTDB_BASE in the subsequent code are now handled by the path
module, so there is no point getting the value of CTDB_BASE.  Instead,
check that the attempt to set it worked, noting that:

  [...] if overwrite is zero, then the value of name is not
  changed (and setenv() returns a success status).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Use path_etcdir_append() to construct some paths
Martin Schwenke [Tue, 6 Aug 2024 03:49:01 +0000 (13:49 +1000)] 
ctdb-daemon: Use path_etcdir_append() to construct some paths

No need to use CTDB_BASE directly.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Replace remaining uses of CTDB_NO_MEMORY() in this file
Martin Schwenke [Fri, 26 Jul 2024 01:38:07 +0000 (11:38 +1000)] 
ctdb-daemon: Replace remaining uses of CTDB_NO_MEMORY() in this file

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Clean up error handling and debug
Martin Schwenke [Fri, 26 Jul 2024 01:29:43 +0000 (11:29 +1000)] 
ctdb-daemon: Clean up error handling and debug

Add some missing error handling and error messages.

Remove a use of CTDB_NO_MEMORY(), which then renders the caller's use
of ctdb_errstr() pointless, so remove that too.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Use ctdb_vnn_address_string() in old-style debugging
Martin Schwenke [Thu, 25 Jul 2024 04:50:32 +0000 (14:50 +1000)] 
ctdb-daemon: Use ctdb_vnn_address_string() in old-style debugging

Modernise the debug macros along the way.

These are done separately because they will require a little more
patience to review.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Add ctdb_vnn_address_string() and use in trivial places
Martin Schwenke [Thu, 25 Jul 2024 04:47:06 +0000 (14:47 +1000)] 
ctdb-daemon: Add ctdb_vnn_address_string() and use in trivial places

Define a static function to return the string.  This clearly doesn't
need a ctdb_ prefix, but it matches ctdb_vnn_iface_string(), so
doesn't look out of place.

Use it in the places where review is trivial.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Store public address string in VNN
Martin Schwenke [Thu, 25 Jul 2024 04:40:18 +0000 (14:40 +1000)] 
ctdb-daemon: Store public address string in VNN

These are currently converted to strings constantly in log messages
and other places.  This clutters the code and probably has a minor
performance impact.

Add a new string field to the VNN structure.  Populate it when a
public address is added and the VNN structure is allocated.  This is
consistent with how node addresses are handled.

Don't use it yet, or this commit becomes huge.

A short-term goal is that each VNN public address will be converted to
a string only once.  A longer-term goal is to reduce use of
ctdb_addr_to_str().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Fix a comment
Martin Schwenke [Thu, 25 Jul 2024 03:41:35 +0000 (13:41 +1000)] 
ctdb-daemon: Fix a comment

The word "no" was accidentally dropped in commit
1e47a1b3f6ab1e2ad9d86dfb28c3e086c99a97e5.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Drop unused arguments
Martin Schwenke [Tue, 18 Jun 2024 05:54:26 +0000 (15:54 +1000)] 
ctdb-daemon: Drop unused arguments

Unused since commit a10545ab6bd8a1b9ca87b0fdba8381cb8af0e284.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-daemon: Improve error handling when releasing all IPs
Martin Schwenke [Tue, 18 Jun 2024 05:38:18 +0000 (15:38 +1000)] 
ctdb-daemon: Improve error handling when releasing all IPs

Currently, event failures are completely ignored in favour of checking
if the IP is on an interface.  This misses the case where event
scripts up to and including 10.interface succeed, but something later
fails.  When that occurs, count is incremented, so the failure is
counted as a success in the summary that is logged.

Fail when releaseip fails even though 10.interface succeeded in
releasing the IP.  This may result in the IP address coming back, but
that's a different problem.

Underlying this is a design question about when releaseip is
successful.  Should releaseip be a distinct operation, with subsequent
reconfigurations considered separately?

Update logging to clearly identify each of the 3 possible errors.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-tcp: Modernise a DEBUG
Martin Schwenke [Thu, 3 Oct 2024 05:13:30 +0000 (15:13 +1000)] 
ctdb-tcp: Modernise a DEBUG

This is last old-style one in this file.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Mon Oct  7 17:12:18 UTC 2024 on atb-devel-224

13 months agoctdb-tcp: Only attempt to automatically bind to local IPs
Martin Schwenke [Thu, 3 Oct 2024 05:07:40 +0000 (15:07 +1000)] 
ctdb-tcp: Only attempt to automatically bind to local IPs

Automatic node address selection in the TCP transport does not work if
net.ipv4.ip_nonlocal_bind=1 because all nodes will be able to bind()
to the first address in the nodes list.

Before getting to the bind() step, add a check to see if an address is
local (i.e. on an interface).  If not, it is not considered.

This is defensively coded so that this step is skipped if local
addresses can not be retrieved.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-server: Optimise local IP verification
Martin Schwenke [Sun, 29 Sep 2024 04:10:22 +0000 (14:10 +1000)] 
ctdb-server: Optimise local IP verification

It is more efficient calling ctdb_sys_local_ip_check() inside a loop
compared to calling ctdb_sys_have_ip().  There is a chance that this
is premature optimisation... but it sure is easy.  Fall back to
checking with bind().

I think these checks really exist because of the weirdness fixed by
commit 4b4e4d8870475d994fe42a7b2c57dc69842d91f6.  However, we might as
well do what we can.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-common: Reimplement ctdb_sys_have_ip() using new infrastructure
Martin Schwenke [Sun, 29 Sep 2024 02:05:31 +0000 (12:05 +1000)] 
ctdb-common: Reimplement ctdb_sys_have_ip() using new infrastructure

It can now be used when net.ipv4.ip_nonlocal_bind=1.

This makes the recovery daemon's local IP verification inefficient.
It can be optimised in a subsequent commit.

Fall back to bind() if unable to fetch IPs.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-common: Make the argument to ctdb_sys_have_ip() const
Martin Schwenke [Fri, 4 Oct 2024 12:08:46 +0000 (22:08 +1000)] 
ctdb-common: Make the argument to ctdb_sys_have_ip() const

Arguably, this would have made sense back in commit
bf86562144fe4e9541bd993519aca958c2bdb794.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-server: Add some local variables
Martin Schwenke [Sun, 29 Sep 2024 04:06:51 +0000 (14:06 +1000)] 
ctdb-server: Add some local variables

Improve readability by not repeating the complex expression now
assigned to addr.  ctdb_sys_have_ip() is called in both arms of the
if/else, so call it once when declaring the new variable.

Modernise debug macros while touching lines.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-tests: Add test code for ctdb_sys_have_ip()
Martin Schwenke [Sun, 29 Sep 2024 02:04:20 +0000 (12:04 +1000)] 
ctdb-tests: Add test code for ctdb_sys_have_ip()

Do not add any automated test cases because they will always be racy.
This allows manual testing of the function.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-common: Add functions for local IP address checking
Martin Schwenke [Sun, 29 Sep 2024 01:57:58 +0000 (11:57 +1000)] 
ctdb-common: Add functions for local IP address checking

This is a wrapper around getifaddrs(2), which is in libreplace, so
should always be available.

Some users want to set net.ipv4.ip_nonlocal_bind = 1.  So, CTDB needs
a way of testing if public IPs are present, without using bind(2).

Doing all of this unconditionally in ctdb_sys_have_ip() will be
inefficient in the recovery daemon's local IP verification if there
are a lot of IP addresses.  Split it this way so the interface
information can be retrieved once and used multiple times.

This doesn't appear to need IP canonicalisation for IPv4-mapped IPv6
addresses.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoctdb-protocol: Add function ctdb_sock_addr_from_sockaddr()
Martin Schwenke [Sun, 29 Sep 2024 01:55:52 +0000 (11:55 +1000)] 
ctdb-protocol: Add function ctdb_sock_addr_from_sockaddr()

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agovfs_glusterfs: Retrieve fs capabilities using vfs_get_fs_capabilities
Anoop C S [Tue, 17 Sep 2024 18:28:50 +0000 (23:58 +0530)] 
vfs_glusterfs: Retrieve fs capabilities using vfs_get_fs_capabilities

vfs_glusterfs is supposed to be the last entry when listed with
other vfs modules. This is due to the fact that the connection path
is not local to the server but relative to the virtual remote file
system beneath it. Especially SMB_VFS_FS_CAPABILITIES implementation
from vfs_default is likely to return incorrect results based on the
connection path assumed to be local to the server which might not be
the case with glusterfs module stacked. Therefore it doesn't make sense
to pass through any vfs interface implementations further down the line
to vfs_default.

Instead make use of get_fs_capabilties to start with already known fs
capabilties from connect phase.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Oct  7 13:36:11 UTC 2024 on atb-devel-224

13 months agovfs_ceph_new: Retrieve fs capabilties using vfs_get_fs_capabilities
Anoop C S [Thu, 3 Oct 2024 07:02:04 +0000 (12:32 +0530)] 
vfs_ceph_new: Retrieve fs capabilties using vfs_get_fs_capabilities

Make use of get_fs_capabilties to start with already known fs
capabilties from connect phase.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agovfs_ceph_new: Populate fs capabilities within vfs_ceph_statvfs
Anoop C S [Thu, 3 Oct 2024 06:59:58 +0000 (12:29 +0530)] 
vfs_ceph_new: Populate fs capabilities within vfs_ceph_statvfs

SMB_VFS_STATVFS implementation for vfs_ceph_new failed to fill in the
FsCapabilities field for vfs_statvfs_struct. Insert the minimum
required values for defining the capabilties of a ceph file system.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agovfs_ceph: Retrieve fs capabilties using vfs_get_fs_capabilities
Anoop C S [Tue, 17 Sep 2024 18:20:25 +0000 (23:50 +0530)] 
vfs_ceph: Retrieve fs capabilties using vfs_get_fs_capabilities

vfs_ceph is supposed to be the last entry when listed with other vfs
modules. This is due to the fact that the connection path is not local
to the server but relative to the virtual remote file system beneath
it. Especially SMB_VFS_FS_CAPABILITIES implementation from vfs_default
is likely to return incorrect results based on the connection path
assumed to be local to the server which might not be the case with
ceph module stacked. Therefore it doesn't make sense to pass through
any vfs interface implementations further down the line to vfs_default.

Instead make use of get_fs_capabilties to start with already known fs
capabilties from connect phase.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agovfs_ceph: Populate fs capabilities within cephwrap_statvfs
Anoop C S [Mon, 23 Sep 2024 09:25:59 +0000 (14:55 +0530)] 
vfs_ceph: Populate fs capabilities within cephwrap_statvfs

SMB_VFS_STATVFS implementation for vfs_ceph failed to fill in the
FsCapabilities field for vfs_statvfs_struct. Insert the minimum
required values for defining the capabilties of a ceph file system.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agovfs_default: Retrieve fs capabilites using vfs_get_fs_capabilties
Anoop C S [Tue, 24 Sep 2024 05:55:54 +0000 (11:25 +0530)] 
vfs_default: Retrieve fs capabilites using vfs_get_fs_capabilties

Make use of get_fs_capabilties to start with already known fs
capabilties from connect phase.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agos3/smbd: Add a helper to fetch fs capabilities
Anoop C S [Tue, 24 Sep 2024 05:36:58 +0000 (11:06 +0530)] 
s3/smbd: Add a helper to fetch fs capabilities

We create a new helper function to retrieve the fs capabilties via
STATVFS call. Additionally set other capabilities based on specific
parametric options. This is 99.9% taken from SMB_VFS_FS_CAPABILITIES
implementation of vfs_default in preparation to be called from any
required vfs module.

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

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
13 months agoctdb-tests: Fix test failure when tests are installed
Martin Schwenke [Wed, 4 Sep 2024 10:20:20 +0000 (20:20 +1000)] 
ctdb-tests: Fix test failure when tests are installed

This currently works when tests are run in-tree.

However, when installed, use of an incorrect variable means it fails
to find statd_callout in the tests/ subdirectory.  Switch to using the
correct variable.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Oct  6 11:07:05 UTC 2024 on atb-devel-224

13 months agoctdb-tests: Add missing quotes in test output
Martin Schwenke [Wed, 4 Sep 2024 10:10:43 +0000 (20:10 +1000)] 
ctdb-tests: Add missing quotes in test output

These should have caused test failure since commit
ef921bdbdbacecf39ee2a1851f16dbba62175fcc.  However, the test failure
occurred in a sub-shell, which covered the failure.  So, add an error
exit if the sub-shell fails.

While here, add an error exit for another potential uncaught
sub-shell-related failure in a related test.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
13 months agoutils: Fix up 14a533680245
Volker Lendecke [Fri, 4 Oct 2024 13:12:22 +0000 (15:12 +0200)] 
utils: Fix up 14a533680245

Obvious omission

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Oct  6 02:25:09 UTC 2024 on atb-devel-224

13 months agolib: Use talloc_realloc instead of talloc_realloc_size
Volker Lendecke [Fri, 4 Oct 2024 13:09:35 +0000 (15:09 +0200)] 
lib: Use talloc_realloc instead of talloc_realloc_size

Maybe Coverity understands that talloc_realloc re-allocates the input
buf. It does not understand that talloc_realloc_size does it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
13 months agos3:g_lock: Do not let pointers to point outside the input buffer
Pavel Filipenský [Fri, 4 Oct 2024 08:31:03 +0000 (10:31 +0200)] 
s3:g_lock: Do not let pointers to point outside the input buffer

If num_shared == 0 the shared points at the address outside the buf.
Make it NULL instead.

(gdb) p *lck
$33 = {
  exclusive = {
    pid = 1187098,
    task_id = 0,
    vnn = 4294967295,
    unique_id = 7349874180613937639
  },
  num_shared = 0,
  shared = 0x555555646980 "@kdUUU",
  unique_lock_epoch = 1489043017590848833,
  unique_data_epoch = 11232048132975083808,
  datalen = 0,
  data = 0x555555646980 "@kdUUU"
}

Same for datalen & data.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Sat Oct  5 14:44:46 UTC 2024 on atb-devel-224

14 months agonetcmd:domain:policy: Fix missing conversion from tgt_lifetime minutes to 10^(-7...
Andréas Leroux [Wed, 25 Sep 2024 12:42:25 +0000 (14:42 +0200)] 
netcmd:domain:policy: Fix missing conversion from tgt_lifetime minutes to 10^(-7) seconds

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15692
Signed-off-by: Andréas Leroux <aleroux@tranquil.it>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Oct  4 04:01:22 UTC 2024 on atb-devel-224

14 months agoauth4: Fix CID 1034877 Resource leak
Volker Lendecke [Mon, 30 Sep 2024 09:05:20 +0000 (11:05 +0200)] 
auth4: Fix CID 1034877 Resource leak

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): Wed Oct  2 14:19:08 UTC 2024 on atb-devel-224

14 months agontvfs: Fix CID 1034883 Resource leak
Volker Lendecke [Mon, 30 Sep 2024 09:01:04 +0000 (11:01 +0200)] 
ntvfs: Fix CID 1034883 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolib: Change ADD_TO_ARRAY to use a tmp variable
Volker Lendecke [Mon, 30 Sep 2024 08:43:00 +0000 (10:43 +0200)] 
lib: Change ADD_TO_ARRAY to use a tmp variable

This should fix a few Coverity Resource Leak findings. Coverity does
not understand that SMB_ASSERT aborts the program, so it believes if
realloc fails we leak the previous allocation. Those are false
positives, but doing it this way does not cost much.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolib: Avoid duplicate definition of ADD_TO_ARRAY
Volker Lendecke [Mon, 30 Sep 2024 08:37:06 +0000 (10:37 +0200)] 
lib: Avoid duplicate definition of ADD_TO_ARRAY

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolib: Factor out ADD_TO_MALLOC_ARRAY()
Volker Lendecke [Mon, 30 Sep 2024 08:34:17 +0000 (10:34 +0200)] 
lib: Factor out ADD_TO_MALLOC_ARRAY()

ADD_TO_ARRAY with an explicit NULL mem_ctx is only used in 3
places. I've checked the other places, and I think I made sure that the
mem_ctx being passed in is non-NULL everywhere else.

This makes the "legacy" use with SMB_REALLOC more obvious.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolib: Fix CID 1596761 Resource leak
Volker Lendecke [Sun, 29 Sep 2024 07:58:13 +0000 (09:58 +0200)] 
lib: Fix CID 1596761 Resource leak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agoshadow_copy2: Ignore VFS_OPEN_HOW_WITH_BACKUP_INTENT
Christof Schmitt [Tue, 1 Oct 2024 20:29:56 +0000 (13:29 -0700)] 
shadow_copy2: Ignore VFS_OPEN_HOW_WITH_BACKUP_INTENT

d1846452e96 vfs: Add VFS_OPEN_HOW_WITH_BACKUP_INTENT introduced
VFS_OPEN_HOW_WITH_BACKUP_INTENT for files opened with
FILE_OPEN_FOR_BACKUP_INTENT. shadow_copy2 refuses the open on a file if
any flage in how.resolve is set. Change the check in shadow_copy2 to
allow opening of files with VFS_OPEN_HOW_WITH_BACKUP_INTENT.

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

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): Wed Oct  2 08:06:38 UTC 2024 on atb-devel-224

14 months agos3:notifyd: Use a watcher per db record
Andreas Schneider [Mon, 22 Jul 2024 10:26:55 +0000 (12:26 +0200)] 
s3:notifyd: Use a watcher per db record

This fixes a O(n²) performance regression in notifyd. The problem was
that we had a watcher per notify instance. This changes the code to have
a watcher per notify db entry.

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

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): Tue Oct  1 14:22:43 UTC 2024 on atb-devel-224

14 months agos3:winbindd: let store_current_dc_in_gencache() take the dcaddr directly
Stefan Metzmacher [Fri, 27 Sep 2024 11:31:13 +0000 (13:31 +0200)] 
s3:winbindd: let store_current_dc_in_gencache() take the dcaddr directly

We could avoid relying on smbXcli_conn_remote_sockaddr() as much as
possible, because we aim to remove domain->conn.cli same day...

Also note that find_dc() always filled domain->dcaddr already
when cm_open_connection() calls store_current_dc_in_gencache().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Oct  1 11:01:35 UTC 2024 on atb-devel-224

14 months agos3:winbindd: dcip_check_name() only takes pss as const input value
Stefan Metzmacher [Fri, 27 Sep 2024 11:29:31 +0000 (13:29 +0200)] 
s3:winbindd: dcip_check_name() only takes pss as const input value

The makes things easier to understand, because the callers
pass in &domain->dcaddr, which could also used as output value.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: set_dc_type_and_flags() doesn't need to do something for primary or...
Stefan Metzmacher [Wed, 25 Sep 2024 17:33:09 +0000 (19:33 +0200)] 
s3:winbindd: set_dc_type_and_flags() doesn't need to do something for primary or internal domains

In the end set_dc_type_and_flags should be removed completely, but
this is a good start in the right direction...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: let add_trusted_domain() mark domains as initialized when loaded from...
Stefan Metzmacher [Wed, 25 Sep 2024 17:31:01 +0000 (19:31 +0200)] 
s3:winbindd: let add_trusted_domain() mark domains as initialized when loaded from config

We at least pass SEC_CHAN_LOCAL for internal domains,
only learned domains use SEC_CHAN_NULL.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: remove unused line in add_trusted_domain()
Stefan Metzmacher [Wed, 25 Sep 2024 17:29:53 +0000 (19:29 +0200)] 
s3:winbindd: remove unused line in add_trusted_domain()

Review with: git show -U8

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: it's 2024 and all AD domains should be native now
Stefan Metzmacher [Wed, 25 Sep 2024 17:04:41 +0000 (19:04 +0200)] 
s3:winbindd: it's 2024 and all AD domains should be native now

No need to use dssetup_DsRoleGetPrimaryDomainInformation that
only adds latency...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: let cm_connect_lsa() require schannel also for direct trusts
Stefan Metzmacher [Fri, 27 Sep 2024 10:21:53 +0000 (12:21 +0200)] 
s3:winbindd: let cm_connect_lsa() require schannel also for direct trusts

This means as domain member we require it also for our primary domain.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:winbindd: let connect_preferred_dc() pass the dcname to smbsock_connect()
Stefan Metzmacher [Fri, 27 Sep 2024 08:50:55 +0000 (10:50 +0200)] 
s3:winbindd: let connect_preferred_dc() pass the dcname to smbsock_connect()

The is not critical, but avoids using the ip address with
fallback to '*SMBSERVER' for connections to port 139.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agos3:libsmb: ads_dc_name() doesn't need to retry if we found a DC in the closest site
Stefan Metzmacher [Thu, 26 Sep 2024 17:14:40 +0000 (19:14 +0200)] 
s3:libsmb: ads_dc_name() doesn't need to retry if we found a DC in the closest site

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolibsmb: use more precise error status
Jule Anger [Fri, 6 Sep 2024 08:49:08 +0000 (10:49 +0200)] 
libsmb: use more precise error status

NO_MEMORY is the only possible error.

Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Signed-off-by: Jule Anger <janger@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Oct  1 08:15:35 UTC 2024 on atb-devel-224

14 months agos3:passdb: ENCTYPE_DES_CBC_MD5 is not longer used in secrets_domain_info_kerberos_keys()
Stefan Metzmacher [Fri, 13 Sep 2024 20:00:06 +0000 (22:00 +0200)] 
s3:passdb: ENCTYPE_DES_CBC_MD5 is not longer used in secrets_domain_info_kerberos_keys()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Sep 30 17:03:55 UTC 2024 on atb-devel-224

14 months agosystem_mitkrb5: require 1.16 as we use ENCTYPE_AES256_CTS_HMAC_SHA384_192
Stefan Metzmacher [Fri, 13 Sep 2024 20:12:34 +0000 (22:12 +0200)] 
system_mitkrb5: require 1.16 as we use ENCTYPE_AES256_CTS_HMAC_SHA384_192

commit 8e931fce126e8c1128da893c806702731c08758a introduced that
implicit dependency, we better make it more clear, which might
allow relying on more modern stuff in future...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
14 months agolib: Fix CID 1620428: Memory - illegal accesses (OVERRUN)
Volker Lendecke [Sun, 29 Sep 2024 06:13:04 +0000 (08:13 +0200)] 
lib: Fix CID 1620428:  Memory - illegal accesses  (OVERRUN)

Beginner's mistake, sorry.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Sep 29 11:49:13 UTC 2024 on atb-devel-224

14 months agolib/addns: match additional names in a non case insensitive way
Stefan Metzmacher [Thu, 26 Sep 2024 12:47:26 +0000 (14:47 +0200)] 
lib/addns: match additional names in a non case insensitive way

Sometime proxy dns servers mess up the case of parts of the
name...

So we should match with strequal() instead of strcmp(),
which results in much less dns packets on the wire...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sun Sep 29 08:09:46 UTC 2024 on atb-devel-224