]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
6 months agoauth: Add missing talloc_free() in error code path.
Jeremy Allison [Wed, 15 Jan 2025 18:21:19 +0000 (10:21 -0800)] 
auth: Add missing talloc_free() in error code path.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Thu Jan 16 14:32:39 UTC 2025 on atb-devel-224

6 months agos3:winbindd: split our wb_gettoken_trybuiltins() helper
Stefan Metzmacher [Sat, 23 Jul 2022 22:46:06 +0000 (00:46 +0200)] 
s3:winbindd: split our wb_gettoken_trybuiltins() helper

This makes the logical steps a bit cleaner and future changes easier.

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): Wed Jan 15 14:00:28 UTC 2025 on atb-devel-224

6 months agos3:winbindd: split out wb_gettoken_trylocalgroups() function
Stefan Metzmacher [Sat, 23 Jul 2022 22:44:07 +0000 (00:44 +0200)] 
s3:winbindd: split out wb_gettoken_trylocalgroups() function

This makes the logical steps a bit cleaner and future changes easier.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agos3:winbindd: add winbindd_domain_verify_sid() helper
Stefan Metzmacher [Fri, 22 Jul 2022 13:15:56 +0000 (15:15 +0200)] 
s3:winbindd: add winbindd_domain_verify_sid() helper

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agos3:winbindd: consistently use add_sid_to_array_unique() in winbindd_ads.c
Stefan Metzmacher [Fri, 22 Jul 2022 13:15:02 +0000 (15:15 +0200)] 
s3:winbindd: consistently use add_sid_to_array_unique() in winbindd_ads.c

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agos3:winbindd: use struct initializers for all struct winbindd_methods cases
Stefan Metzmacher [Tue, 26 Jul 2022 08:52:19 +0000 (10:52 +0200)] 
s3:winbindd: use struct initializers for all struct winbindd_methods cases

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agos3:auth: let check_sam_security() add NETLOGON_NTLMV2_ENABLED
Stefan Metzmacher [Wed, 15 Jan 2025 11:41:21 +0000 (12:41 +0100)] 
s3:auth: let check_sam_security() add NETLOGON_NTLMV2_ENABLED

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agos4:auth/ntlm: let authsam_check_password_internals() add NETLOGON_NTLMV2_ENABLED
Stefan Metzmacher [Wed, 15 Jan 2025 10:57:12 +0000 (11:57 +0100)] 
s4:auth/ntlm: let authsam_check_password_internals() add NETLOGON_NTLMV2_ENABLED

Windows returns NETLOGON_NTLMV2_ENABLED in all
netr_LogonSamLogon* response messages.
Even if NTLMv1 was actually used and also
for password authentication.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agopython:tests/krb5: let netlogon.py check for NETLOGON_NTLMV2_ENABLED
Stefan Metzmacher [Wed, 15 Jan 2025 11:22:34 +0000 (12:22 +0100)] 
python:tests/krb5: let netlogon.py check for NETLOGON_NTLMV2_ENABLED

It's there for network_samlogon and interactive_samlogon,
but not in ticket_samlogon.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
6 months agoselftest: force 'client use krb5 netlogon = yes' for admem_idmap_autorid
Stefan Metzmacher [Wed, 8 Jan 2025 09:49:42 +0000 (10:49 +0100)] 
selftest: force 'client use krb5 netlogon = yes' for admem_idmap_autorid

With 'reject aes netlogon servers = yes' we prevent any fallback.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jan 14 00:37:34 UTC 2025 on atb-devel-224

6 months agos4:torture/rpc: add rpc.pac tests with DCERPC_SCHANNEL_KRB5/ServerAuthenticateKerberos()
Stefan Metzmacher [Mon, 11 Nov 2024 18:32:48 +0000 (19:32 +0100)] 
s4:torture/rpc: add rpc.pac tests with DCERPC_SCHANNEL_KRB5/ServerAuthenticateKerberos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agoselftest: add 'server support krb5 netlogon = yes' for fl2008r2dc
Stefan Metzmacher [Wed, 27 Nov 2024 11:32:27 +0000 (12:32 +0100)] 
selftest: add 'server support krb5 netlogon = yes' for fl2008r2dc

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: let rpc.samlogon also test DCERPC_SCHANNEL_KRB5/ServerAuthenticateKer...
Stefan Metzmacher [Wed, 27 Nov 2024 11:21:57 +0000 (12:21 +0100)] 
s4:torture/rpc: let rpc.samlogon also test DCERPC_SCHANNEL_KRB5/ServerAuthenticateKerberos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: let rpc.samlogon test credential_flags again...
Stefan Metzmacher [Wed, 27 Nov 2024 11:17:27 +0000 (12:17 +0100)] 
s4:torture/rpc: let rpc.samlogon test credential_flags again...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: let rpc.schannel also use of DCERPC_SCHANNEL_KRB5
Stefan Metzmacher [Fri, 8 Nov 2024 14:56:45 +0000 (15:56 +0100)] 
s4:torture/rpc: let rpc.schannel also use of DCERPC_SCHANNEL_KRB5

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: prepare test_lsa_ops for ServerAuthenticateKerberos
Stefan Metzmacher [Mon, 11 Nov 2024 19:30:25 +0000 (20:30 +0100)] 
s4:torture/rpc: prepare test_lsa_ops for ServerAuthenticateKerberos

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: use expected_{account,authority}_name variables in test_lsa_ops
Stefan Metzmacher [Mon, 11 Nov 2024 19:26:55 +0000 (20:26 +0100)] 
s4:torture/rpc: use expected_{account,authority}_name variables in test_lsa_ops

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: prepare netlogon tests for ServerAuthenticateKerberos
Stefan Metzmacher [Wed, 27 Nov 2024 11:21:12 +0000 (12:21 +0100)] 
s4:torture/rpc: prepare netlogon tests for ServerAuthenticateKerberos

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: prepare lsa lookup tests for ServerAuthenticateKerberos
Stefan Metzmacher [Wed, 27 Nov 2024 11:18:36 +0000 (12:18 +0100)] 
s4:torture/rpc: prepare lsa lookup tests for ServerAuthenticateKerberos

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:torture/rpc: make more use of netlogon_creds_client_verify()
Stefan Metzmacher [Wed, 27 Nov 2024 11:15:42 +0000 (12:15 +0100)] 
s4:torture/rpc: make more use of netlogon_creds_client_verify()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos4:librpc/rpc: implement DCERPC_SCHANNEL_KRB5
Stefan Metzmacher [Fri, 8 Nov 2024 16:48:31 +0000 (17:48 +0100)] 
s4:librpc/rpc: implement DCERPC_SCHANNEL_KRB5

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:tests: let test_update_keytab.sh use rpc changetrustpw --server
Stefan Metzmacher [Thu, 7 Nov 2024 19:00:08 +0000 (20:00 +0100)] 
s3:tests: let test_update_keytab.sh use rpc changetrustpw --server

If we pass the server name via -I/--ipaddress means we internally loose
the server name and fail to use kerberos with just the ip address.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agopython:tests: let s3_net_join.py avoid kerberos_state=DONT_USE_KERBEROS
Stefan Metzmacher [Thu, 7 Nov 2024 18:09:26 +0000 (19:09 +0100)] 
python:tests: let s3_net_join.py avoid kerberos_state=DONT_USE_KERBEROS

We may use ServerAuthenticateKerberos in future and that needed to
use kerberos.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agotestprogs/blackbox: let test_rpcclient_schannel.sh explicitly use --option=clientusek...
Stefan Metzmacher [Thu, 7 Nov 2024 17:31:25 +0000 (18:31 +0100)] 
testprogs/blackbox: let test_rpcclient_schannel.sh explicitly use --option=clientusekrb5netlogon

This also tests lsa over kerberos

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agopython:tests: let auth_log.py also test --option=clientusekrb5netlogon=yes
Stefan Metzmacher [Thu, 7 Nov 2024 16:37:05 +0000 (17:37 +0100)] 
python:tests: let auth_log.py also test --option=clientusekrb5netlogon=yes

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agopython:tests: let auth_log.py explicitly use --option=clientusekrb5netlogon=no
Stefan Metzmacher [Thu, 7 Nov 2024 15:41:00 +0000 (16:41 +0100)] 
python:tests: let auth_log.py explicitly use --option=clientusekrb5netlogon=no

It also add some additional checks to make sure netlogon with AES was
used.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agopython:tests: let auth_log.py use self.assertIn(received, [4, 5]
Stefan Metzmacher [Thu, 7 Nov 2024 15:37:56 +0000 (16:37 +0100)] 
python:tests: let auth_log.py use self.assertIn(received, [4, 5]

This will simplify further changes.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agoselftest: add 'server support krb5 netlogon = yes' for ad_dc_ntvfs
Stefan Metzmacher [Wed, 27 Nov 2024 11:32:27 +0000 (12:32 +0100)] 
selftest: add 'server support krb5 netlogon = yes' for ad_dc_ntvfs

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agolibcli/auth: add support for ServerAuthenticateKerberos()
Stefan Metzmacher [Fri, 6 Sep 2024 12:07:15 +0000 (14:07 +0200)] 
libcli/auth: add support for ServerAuthenticateKerberos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:winbindd: split out cm_connect_schannel_or_krb5() helper
Stefan Metzmacher [Wed, 6 Nov 2024 13:00:58 +0000 (14:00 +0100)] 
s3:winbindd: split out cm_connect_schannel_or_krb5() helper

This will allow us to use ServerAuthenticateKerberos() later.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:cli_netlogon: prepare for netr_ServerAuthenticateKerberos()
Stefan Metzmacher [Wed, 30 Oct 2024 11:13:36 +0000 (12:13 +0100)] 
s3:cli_netlogon: prepare for netr_ServerAuthenticateKerberos()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:winbindd: use GENSEC_FEATURE_NO_DELEGATION for trust credentials for netlogon
Stefan Metzmacher [Wed, 27 Nov 2024 09:59:58 +0000 (10:59 +0100)] 
s3:winbindd: use GENSEC_FEATURE_NO_DELEGATION for trust credentials for netlogon

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:rpcclient: use GENSEC_FEATURE_NO_DELEGATION for trust credentials
Stefan Metzmacher [Wed, 27 Nov 2024 09:59:58 +0000 (10:59 +0100)] 
s3:rpcclient: use GENSEC_FEATURE_NO_DELEGATION for trust credentials

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:libnet_join: use GENSEC_FEATURE_NO_DELEGATION for trust credentials
Stefan Metzmacher [Wed, 27 Nov 2024 09:59:58 +0000 (10:59 +0100)] 
s3:libnet_join: use GENSEC_FEATURE_NO_DELEGATION for trust credentials

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:cli_netlogon: use GENSEC_FEATURE_NO_DELEGATION for trust credentials
Stefan Metzmacher [Wed, 30 Oct 2024 11:13:36 +0000 (12:13 +0100)] 
s3:cli_netlogon: use GENSEC_FEATURE_NO_DELEGATION for trust credentials

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agolibcli/auth: add netlogon_creds_cli_use_kerberos() helper
Stefan Metzmacher [Fri, 6 Sep 2024 12:07:15 +0000 (14:07 +0200)] 
libcli/auth: add netlogon_creds_cli_use_kerberos() helper

This allows the calling code to decide if a krb5 or anonymous
netlogon connection should be tried.

Currently we don't try ServerAuthenticateKerberos, but that will change
in a few commits. But before we need to prepare the callers...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agodocs-xml/smbdotconf: add "client use krb5 netlogon" option
Stefan Metzmacher [Thu, 7 Nov 2024 12:25:37 +0000 (13:25 +0100)] 
docs-xml/smbdotconf: add "client use krb5 netlogon" option

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agodocs-xml/smbdotconf: add "reject aes netlogon servers" option
Stefan Metzmacher [Thu, 7 Nov 2024 11:41:05 +0000 (12:41 +0100)] 
docs-xml/smbdotconf: add "reject aes netlogon servers" option

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:libads: prepare trust_pw_change() for ServerAuthenticateKerberos()
Stefan Metzmacher [Thu, 31 Oct 2024 17:32:52 +0000 (18:32 +0100)] 
s3:libads: prepare trust_pw_change() for ServerAuthenticateKerberos()

We use kerberos_kinit_passwords_ext() to check the password before
and after ServerPasswordSet2() as ServerAuthenticateKerberos()
does not check it. We use the ip address of the dcerpc connection
in order to use a fixed KDC, so that we talk to the same server
that also received the ServerPasswordSet2().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agos3:libads: rename variables in trust_pw_change()
Stefan Metzmacher [Tue, 5 Nov 2024 11:42:37 +0000 (12:42 +0100)] 
s3:libads: rename variables in trust_pw_change()

We'll have more than nt_hashes soon.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
6 months agovfs_ceph_new: add profiling support
Shweta Sodani [Thu, 2 Jan 2025 13:42:08 +0000 (19:12 +0530)] 
vfs_ceph_new: add profiling support

Signed-off-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Mon Jan 13 21:26:34 UTC 2025 on atb-devel-224

7 months agosharesec: Check if share exists in configuration
Vinit Agnihotri [Tue, 3 Dec 2024 05:51:09 +0000 (11:21 +0530)] 
sharesec: Check if share exists in configuration

Load config from registry without share info and check if sharename
exists from configuration. This results into lesser delay for the same.

In case of view we load config with all shares to ensure we get all
shares for diplay purpose.

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

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Jan 10 10:45:30 UTC 2025 on atb-devel-224

7 months agosharesec: Add function to check existence of share from config
Vinit Agnihotri [Tue, 3 Dec 2024 05:49:09 +0000 (11:19 +0530)] 
sharesec: Add function to check existence of share from config

Add function to detect if a share name exists in the registry or config file.

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

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
7 months agoparam: Add API to load registry without share info
Vinit Agnihotri [Tue, 3 Dec 2024 05:42:34 +0000 (11:12 +0530)] 
param: Add API to load registry without share info

As number of shares increases loading entire registry configuration along with
share information becomes very costly operation.
Since we may not require share information all time, we can optimise
this by using API just loading configuration without any share info.

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

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
7 months agosharesec: Fix warning frame not freed in order
Vinit Agnihotri [Thu, 12 Dec 2024 13:35:24 +0000 (19:05 +0530)] 
sharesec: Fix warning frame not freed in order

This change should fix following warning:
Freed frame ../../source3/utils/sharesec.c:515, expected ../../source3/utils/sharesec.c:637

Frame was not getting freed in case of servicename is NULL.

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

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
7 months agos3-sharesec: Add Test to verify command option "--view-all"
Guenther Deschner [Wed, 11 Dec 2024 10:03:47 +0000 (15:33 +0530)] 
s3-sharesec: Add Test to verify command option "--view-all"

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

Signed-off-by: Guenther Deschner <gd@samba.org>
Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
7 months agos4:selftest: samba.tests.krb5.netlogon don't need explicit FAST_SUPPORT
Stefan Metzmacher [Thu, 19 Dec 2024 12:34:18 +0000 (13:34 +0100)] 
s4:selftest: samba.tests.krb5.netlogon don't need explicit FAST_SUPPORT

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jan  8 10:16:50 UTC 2025 on atb-devel-224

7 months agopython:tests/krb5: let netlogon.py test referral ticket for SEC_CHAN_DNS_DOMAIN
Stefan Metzmacher [Mon, 16 Dec 2024 17:11:31 +0000 (18:11 +0100)] 
python:tests/krb5: let netlogon.py test referral ticket for SEC_CHAN_DNS_DOMAIN

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: allow get_service_ticket to accept a trust referral ticket without...
Stefan Metzmacher [Mon, 16 Dec 2024 14:12:21 +0000 (15:12 +0100)] 
python:tests/krb5: allow get_service_ticket to accept a trust referral ticket without kvno

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: allow tickets without a kvno
Stefan Metzmacher [Mon, 16 Dec 2024 14:51:34 +0000 (15:51 +0100)] 
python:tests/krb5: allow tickets without a kvno

This is needed for trust referrals.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: let netlogon.py export changed passwords to keytab
Stefan Metzmacher [Wed, 18 Dec 2024 13:59:06 +0000 (14:59 +0100)] 
python:tests/krb5: let netlogon.py export changed passwords to keytab

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: add domain trust tests to netlogon.py
Stefan Metzmacher [Mon, 16 Dec 2024 14:18:54 +0000 (15:18 +0100)] 
python:tests/krb5: add domain trust tests to netlogon.py

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: add a create_trust() helper function to test trusted domains
Stefan Metzmacher [Mon, 2 Dec 2024 07:48:32 +0000 (08:48 +0100)] 
python:tests/krb5: add a create_trust() helper function to test trusted domains

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: allow exporting a keytab file of the accounts used by the tests
Stefan Metzmacher [Wed, 18 Dec 2024 10:44:27 +0000 (11:44 +0100)] 
python:tests/krb5: allow exporting a keytab file of the accounts used by the tests

EXPORT_KEYTAB_FILE=/dev/shm/export.keytab
EXPORT_KEYTAB_APPEND=0 or 1
EXPORT_EXISTING_CREDS_TO_KEYTAB=0 or 1
EXPORT_GIVEN_CREDS_TO_KEYTAB=0 or 1

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: add KerberosCredentials.[g|s]et_trust_{incoming,outgoing,account...
Stefan Metzmacher [Mon, 16 Dec 2024 12:47:34 +0000 (13:47 +0100)] 
python:tests/krb5: add KerberosCredentials.[g|s]et_trust_{incoming,outgoing,account}_creds

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopycredentials: add [g|s]et_old_nt_hash()
Stefan Metzmacher [Sat, 14 Dec 2024 16:51:44 +0000 (17:51 +0100)] 
pycredentials: add [g|s]et_old_nt_hash()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agos4:rpc_server/netlogon: fix error codes for netr_NetrLogonSendToSam() with SEC_CHAN_RODC
Stefan Metzmacher [Fri, 13 Dec 2024 15:11:34 +0000 (16:11 +0100)] 
s4:rpc_server/netlogon: fix error codes for netr_NetrLogonSendToSam() with SEC_CHAN_RODC

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agos4:rpc_server/netlogon: an RODC is not allowed to call netr_ServerPasswordGet()
Stefan Metzmacher [Fri, 13 Dec 2024 15:01:27 +0000 (16:01 +0100)] 
s4:rpc_server/netlogon: an RODC is not allowed to call netr_ServerPasswordGet()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: let netlogon.py run the tests also as rodc
Stefan Metzmacher [Fri, 13 Dec 2024 14:46:02 +0000 (15:46 +0100)] 
python:tests/krb5: let netlogon.py run the tests also as rodc

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: allow netlogon.py tests to work against a KDC with claims enabled
Stefan Metzmacher [Fri, 13 Dec 2024 14:44:43 +0000 (15:44 +0100)] 
python:tests/krb5: allow netlogon.py tests to work against a KDC with claims enabled

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: allow get_mock_rodc_krbtgt_creds(preserve=False) to create a tmp...
Stefan Metzmacher [Fri, 13 Dec 2024 14:42:37 +0000 (15:42 +0100)] 
python:tests/krb5: allow get_mock_rodc_krbtgt_creds(preserve=False) to create a tmp rodc

This also exposes credentials for the machine account for netlogon
testing.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agopython:tests/krb5: fix etypes_to_test values in RawKerberosTest
Stefan Metzmacher [Wed, 18 Dec 2024 13:57:06 +0000 (14:57 +0100)] 
python:tests/krb5: fix etypes_to_test values in RawKerberosTest

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agos4:rpc_server/netlogon: fill netlogon_creds_CredentialState->tdo_guid
Stefan Metzmacher [Thu, 12 Dec 2024 15:26:23 +0000 (16:26 +0100)] 
s4:rpc_server/netlogon: fill netlogon_creds_CredentialState->tdo_guid

This will help us to lookup the tdo object using a <GUID=TDO-GUID>
search base.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agoschannel.idl: add tdo_guid to netlogon_creds_CredentialState
Stefan Metzmacher [Thu, 12 Dec 2024 15:09:50 +0000 (16:09 +0100)] 
schannel.idl: add tdo_guid to netlogon_creds_CredentialState

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
7 months agos4:dsdb: fix logic of dsdb_trust_routing_by_name()
Stefan Metzmacher [Tue, 7 Jan 2025 13:06:43 +0000 (14:06 +0100)] 
s4:dsdb: fix logic of dsdb_trust_routing_by_name()

We need to use the longest dnsname match as possible.

If we are the domain samba.example.com and have a trust
to example.com, a routing request for dc.samba.example.com
should return the tdo for samba.example.com instead
of example.com.

I reproduced the problem with the following diff:

> diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm
> index 15d7692b5d64..6e9595b784c4 100644
> --- a/selftest/target/Samba.pm
> +++ b/selftest/target/Samba.pm
> @@ -564,7 +564,7 @@ sub realm_to_ip_mappings
>   'samba2000.example.com'           => 'dc5',
>   'samba2003.example.com'           => 'dc6',
>   'samba2008r2.example.com'         => 'dc7',
> - 'addom.samba.example.com'         => 'addc',
> + 'addom.samba2008r2.example.com'         => 'addc',
>   'addom2.samba.example.com'        => 'addcsmb1',
>   'sub.samba.example.com'           => 'localsubdc',
>   'chgdcpassword.samba.example.com' => 'chgdcpass',
> diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
> index 0e4cf50235c3..6bca0cfd0c89 100755
> --- a/selftest/target/Samba4.pm
> +++ b/selftest/target/Samba4.pm
> @@ -2631,7 +2631,7 @@ sub setup_fl2008r2dc
>       return undef;
>   }
>
> - $env = $self->setup_trust($env, $ad_dc_vars, "forest", "");
> + $env = $self->setup_trust($env, $ad_dc_vars, "forest", "--skip-validation");
>   if (!defined $env) {
>       return undef;
>   }
> @@ -2843,7 +2843,7 @@ sub _setup_ad_dc
>   $server = "addc";
>   }
>   if (!defined($dom)) {
> - $dom = "addom.samba.example.com";
> + $dom = "addom.samba2008r2.example.com";
>   }
>   my $env = $self->provision_ad_dc($path, $server, "ADDOMAIN",
>    $dom,

and running:
 make -j testenv SELFTEST_TESTENV="fl2008r2dc:local"

Inside the testenv:
bin/smbclient //addc.addom.samba2008r2.example.com/netlogon \
  -U$TRUST_USERNAME@$TRUST_REALM%$TRUST_PASSWORD \
  --use-kerberos=required \
  -c 'ls'

It lets the KDC of ADDOM.SAMBA2008R2.EXAMPLE.COM to
generate a (referral) ticket for
krbtgt/SAMBA2008R2.EXAMPLE.COM@ADDOM.SAMBA2008R2.EXAMPLE.COM
instead of
cifs/addc.addom.samba2008r2.example.com@ADDOM.SAMBA2008R2.EXAMPLE.COM

As ADDOM.SAMBA2008R2.EXAMPLE.COM has a forest trust (without msDS-TrustForestTrustInfo)
to SAMBA2008R2.EXAMPLE.COM dsdb_trust_update_best_tln() overwrote the
best match of addom.samba2008r2.example.com with samba2008r2.example.com.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jan  8 04:14:47 UTC 2025 on atb-devel-224

7 months agosmbd: fill fsp_flas.posix_append in open_file_ntcreate()
Ralph Boehme [Thu, 5 Dec 2024 09:26:59 +0000 (10:26 +0100)] 
smbd: fill fsp_flas.posix_append in open_file_ntcreate()

This small changes enables the new append-IO machinery.

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): Tue Jan  7 23:05:57 UTC 2025 on atb-devel-224

7 months agotests: test SMB3 POSIX append-IO behaviour
Ralph Boehme [Thu, 28 Nov 2024 11:12:26 +0000 (12:12 +0100)] 
tests: test SMB3 POSIX append-IO behaviour

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: allow VFS_PWRITE_APPEND_OFFSET in vfs_valid_pwrite_range()
Ralph Boehme [Fri, 29 Nov 2024 13:09:12 +0000 (14:09 +0100)] 
smbd: allow VFS_PWRITE_APPEND_OFFSET in vfs_valid_pwrite_range()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: assert fsp->fsp_flags.posix_append and offset in smbd_smb2_write_send()
Ralph Boehme [Fri, 22 Nov 2024 18:41:51 +0000 (19:41 +0100)] 
smbd: assert fsp->fsp_flags.posix_append and offset in smbd_smb2_write_send()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: prepare smb2_write.c for handling a negative offset
Ralph Boehme [Fri, 22 Nov 2024 18:40:38 +0000 (19:40 +0100)] 
smbd: prepare smb2_write.c for handling a negative offset

Use off_t instead of uint64_t for the offset in order to support negative
offsets coming in over the wire for SMB3 POSIX append-IO which enforces
offset=VFS_PWRITE_APPEND_OFFSET (-1) for all writes.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs_default: implement POSIX append-IO
Ralph Boehme [Fri, 22 Nov 2024 18:38:33 +0000 (19:38 +0100)] 
vfs_default: implement POSIX append-IO

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agos3/lib: use VFS_PWRITE_APPEND_OFFSET in default_sys_recvfile()
Ralph Boehme [Fri, 29 Nov 2024 13:06:39 +0000 (14:06 +0100)] 
s3/lib: use VFS_PWRITE_APPEND_OFFSET in default_sys_recvfile()

Note that splice() itself doesn't work with an O_APPEND outfd:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=efc968d450e013049a662d22727cf132618dcb2f

Hence for the real splice() codepath itself no changes are needed, as splice
will just fail with EINVAL triggering the fallback code.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: implement POSIX append-IO in vfs_pwrite_data()
Ralph Boehme [Sun, 24 Nov 2024 07:23:36 +0000 (08:23 +0100)] 
vfs: implement POSIX append-IO in vfs_pwrite_data()

This basically just avoids clobbering a possible offset=VFS_PWRITE_APPEND_OFFSET
when calling SMB_VFS_PWRITE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs_io_uring: implement POSIX append-IO
Ralph Boehme [Sun, 24 Nov 2024 08:27:36 +0000 (09:27 +0100)] 
vfs_io_uring: implement POSIX append-IO

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs_aio_fork: implement POSIX append-IO
Ralph Boehme [Sun, 24 Nov 2024 07:10:25 +0000 (08:10 +0100)] 
vfs_aio_fork: implement POSIX append-IO

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolib: add sys_write_full()
Ralph Boehme [Sun, 24 Nov 2024 07:08:26 +0000 (08:08 +0100)] 
lib: add sys_write_full()

Basically a copy of sys_pwrite_full(), calling write() instead of pwrite().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: check for VFS_PWRITE_APPEND_OFFSET in vfs_fill_sparse()
Ralph Boehme [Fri, 29 Nov 2024 12:04:36 +0000 (13:04 +0100)] 
smbd: check for VFS_PWRITE_APPEND_OFFSET in vfs_fill_sparse()

This is the only place a function dealing with allocation and file length being
called from the write IO path. In the case of POSIX append-IO with
offset=VFS_PWRITE_APPEND_OFFSET vfs_fill_sparse() must be a noop.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: add vfs_valid_allocation_range() as a copy of vfs_valid_pwrite_range()
Ralph Boehme [Fri, 29 Nov 2024 12:00:30 +0000 (13:00 +0100)] 
smbd: add vfs_valid_allocation_range() as a copy of vfs_valid_pwrite_range()

Not a copy of the whole code obviously, a copy of behaviour. A subsequent commit
will further change vfs_valid_pwrite_range().

Existing callers of vfs_valid_pwrite_range() that are not calling it in the
write-IO codepath, but when dealing with allocation and size, are converted to
use vfs_valid_allocation_range().

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agos3/pylibsmb: add VFS_PWRITE_APPEND_OFFSET
Ralph Boehme [Thu, 28 Nov 2024 07:08:46 +0000 (08:08 +0100)] 
s3/pylibsmb: add VFS_PWRITE_APPEND_OFFSET

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: add VFS_PWRITE_APPEND_OFFSET
Ralph Boehme [Fri, 22 Nov 2024 18:36:18 +0000 (19:36 +0100)] 
vfs: add VFS_PWRITE_APPEND_OFFSET

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: add fsp_flags.posix_append
Ralph Boehme [Fri, 22 Nov 2024 18:36:39 +0000 (19:36 +0100)] 
vfs: add fsp_flags.posix_append

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: fix access_mask to FILE_APPEND_DATA mapping for POSIX opens
Ralph Boehme [Sat, 9 Nov 2024 15:15:08 +0000 (16:15 +0100)] 
smbd: fix access_mask to FILE_APPEND_DATA mapping for POSIX opens

Only use POSIX O_APPEND flag if the client requested FILE_APPEND_DATA without
FILE_WRITE_DATA.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agotests: add a test for copy-chunk on a POSIX handle
Ralph Boehme [Mon, 11 Nov 2024 09:39:15 +0000 (10:39 +0100)] 
tests: add a test for copy-chunk on a POSIX handle

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agotests: use libsmb.unix_mode_to_wire() in smb3unix.py
Ralph Boehme [Thu, 5 Dec 2024 09:20:00 +0000 (10:20 +0100)] 
tests: use libsmb.unix_mode_to_wire() in smb3unix.py

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agotests: use clean_file() from our superclass in smb3unix.py
Ralph Boehme [Mon, 11 Nov 2024 09:38:05 +0000 (10:38 +0100)] 
tests: use clean_file() from our superclass in smb3unix.py

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agopylibsmb: add "copy_chunk"
Ralph Boehme [Mon, 11 Nov 2024 07:06:13 +0000 (08:06 +0100)] 
pylibsmb: add "copy_chunk"

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbtorture: verify Windows SEC_FILE_APPEND_DATA behaviour
Ralph Boehme [Sat, 9 Nov 2024 15:00:39 +0000 (16:00 +0100)] 
smbtorture: verify Windows SEC_FILE_APPEND_DATA behaviour

This test proves that Windows will not enforce append behaviour when using
SEC_FILE_APPEND_DATA: writing with an offset and length into existing data is
not mapped to an append operation. According to

https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntcreatefile

Windows internal APIs seemt to support append-IO:

  If only the FILE_APPEND_DATA and SYNCHRONIZE flags are set, the caller can
  write only to the end of the file, and any offset information on writes to the
  file is ignored. However, the file is automatically extended as necessary for
  this type of write operation.

...but at least over SMB2 it doesn't work.

This also demonstrates that Windows behaves as documented in the footnote in

MS-SMB2 3.3.5.13 "Receiving an SMB2 WRITE Request":

  If the range being written to is within the existing file size and
  Open.GrantedAccess does not include FILE_WRITE_DATA, or if the range being
  written to extends the file size and Open.GrantedAccess does not include
  FILE_APPEND_DATA, the server SHOULD<358> fail the request with
  STATUS_ACCESS_DENIED.

MS-SMB2 <358> Section 3.3.5.13:

  Windows SMB2 servers allow the operation when either FILE_APPEND_DATA or
  FILE_WRITE_DATA is set in Open.GrantedAccess.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
7 months agosmbd: fix an invalid memory access
Ralph Boehme [Fri, 22 Nov 2024 09:21:14 +0000 (10:21 +0100)] 
smbd: fix an invalid memory access

This was introduced by f86208d272cfa0ce6753b02d3f5b1cce4fd91e2e:

==47833== Invalid read of size 1
==47833==    at 0x4846782: strlen (vg_replace_strmem.c:494)
==47833==    by 0x4F9D257: __vfprintf_internal (vfprintf-process-arg.c:397)
==47833==    by 0x4FBD3A5: __vasprintf_internal (vasprintf.c:57)
==47833==    by 0x4EBDFFD: __dbgtext_va (debug.c:1939)
==47833==    by 0x4EBE125: dbgtext (debug.c:1960)
==47833==    by 0x49A9E77: exit_server_common (server_exit.c:230)
==47833==    by 0x49A9EE6: smbd_exit_server_cleanly (server_exit.c:247)
==47833==    by 0x4ECA2EF: exit_server_cleanly (smbd_shim.c:113)
==47833==    by 0x495E72B: smbd_server_connection_terminate_done (smb2_server.c:1758)
==47833==    by 0x4D4ED6A: _tevent_req_notify_callback (tevent_req.c:177)
==47833==    by 0x4D4EEFB: tevent_req_finish (tevent_req.c:234)
==47833==    by 0x4D4F02A: tevent_req_trigger (tevent_req.c:291)
==47833==  Address 0xb8cf820 is 96 bytes inside a block of size 123 free'd
==47833==    at 0x484317B: free (vg_replace_malloc.c:872)
==47833==    by 0x4CF8950: _tc_free_internal (talloc.c:1222)
==47833==    by 0x4CF993E: _tc_free_children_internal (talloc.c:1669)
==47833==    by 0x4CF8830: _tc_free_internal (talloc.c:1184)
==47833==    by 0x4CF993E: _tc_free_children_internal (talloc.c:1669)
==47833==    by 0x4CF8830: _tc_free_internal (talloc.c:1184)
==47833==    by 0x4CF89F7: _talloc_free_internal (talloc.c:1248)
==47833==    by 0x4CF9D93: _talloc_free (talloc.c:1792)
==47833==    by 0x495E700: smbd_server_connection_terminate_done (smb2_server.c:1748)
==47833==    by 0x4D4ED6A: _tevent_req_notify_callback (tevent_req.c:177)
==47833==    by 0x4D4EEFB: tevent_req_finish (tevent_req.c:234)
==47833==    by 0x4D4F02A: tevent_req_trigger (tevent_req.c:291)
==47833==  Block was alloc'd at
==47833==    at 0x48407B4: malloc (vg_replace_malloc.c:381)
==47833==    by 0x4CF7CAC: __talloc_with_prefix (talloc.c:783)
==47833==    by 0x4CF7E46: __talloc (talloc.c:825)
==47833==    by 0x4CFB007: __talloc_strlendup (talloc.c:2454)
==47833==    by 0x4CFB0BD: talloc_strdup (talloc.c:2470)
==47833==    by 0x495E7B6: smbd_server_connection_terminate_ex (smb2_server.c:1775)
==47833==    by 0x4969222: smbd_smb2_connection_handler (smb2_server.c:5291)
==47833==    by 0x4D4CAE2: tevent_common_invoke_fd_handler (tevent_fd.c:174)
==47833==    by 0x4D596D5: epoll_event_loop (tevent_epoll.c:696)
==47833==    by 0x4D59E5E: epoll_event_loop_once (tevent_epoll.c:926)
==47833==    by 0x4D5529C: std_event_loop_once (tevent_standard.c:110)
==47833==    by 0x4D4B3B9: _tevent_loop_once (tevent.c:820)
==47833==

state was a child of "xconn", so when xconn was freed state went away.

As reason is used at the very end of exit_server_common() after *all* global
objects that could be used as talloc parent are freed, there's just no other way
to make "reason" a talloc string then allocating it from the NULL context right
away.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agofruit: fixup size_t overflow check
Michael Tokarev [Thu, 17 Nov 2022 20:51:03 +0000 (23:51 +0300)] 
fruit: fixup size_t overflow check

https://bugzilla.samba.org/show_bug.cgi?id=13622 .
The check ('bandsize > SIZE_MAX/nbands' is wrong, since
it caps the total size to the wrong data type size_t
instead of off_t -- samba is always built with LFS support
so off_t is always 64bits, while size_t is 32bit son a
32bit platform.  This has caused issues already, capping
size of the bands: https://bugs.debian.org/974868 .

Since there's another overflow check already, let's just
fold this one to the following one and log a more complete
error message.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Sat Jan  4 20:47:35 UTC 2025 on atb-devel-224

7 months agos3:vfs_fruit: Fix crash for nbands == 0
Pavel Filipenský [Thu, 2 Jan 2025 17:25:22 +0000 (18:25 +0100)] 
s3:vfs_fruit: Fix crash for nbands == 0

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agotorture:fruit: Test timemachine for 0 bands
Pavel Filipenský [Thu, 2 Jan 2025 17:32:40 +0000 (18:32 +0100)] 
torture:fruit: Test timemachine for 0 bands

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agoinclude <grp.h> for setgroups in a few places
Michael Tokarev [Fri, 29 Nov 2024 06:34:42 +0000 (09:34 +0300)] 
include <grp.h> for setgroups in a few places

setgroups(), unlike getgroups(), is not in <unistd.h> but in <grp.h>.
Recent compilers require function declaration before using a function
(or more and more distributions treat lack of declaration as error),
so all configure-time tests fails with source3/lib/util_sec.c:

source3/../lib/util/setid.c: In function 'samba_setgroups':
source3/../lib/util/setid.c:244:16: error: implicit declaration of function \
  'setgroups'; did you mean 'getgroups'? [-Wimplicit-function-declaration]
  244 |         return setgroups(setlen, gidset);

Add the missing include so configuration finds the existing system
functions instead of failing.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Thu Jan  2 17:58:50 UTC 2025 on atb-devel-224

7 months agoremove usage of bzero
Michael Tokarev [Mon, 18 Nov 2024 12:00:05 +0000 (15:00 +0300)] 
remove usage of bzero

bzero() function has been deprecated for a long time.
In samba it is replaced with memset().  But samba also
provides common memory-zeroing macros, like ZERO_STRUCT().
In all places where bzero() is used, it actually meant to
zero a structure or an array.

So replace these bzero() calls with ZERO_STRUCT() or
ZERO_ARRAY() as appropriate, and remove bzero() replacement
and testing entirely.

While at it, also stop checking for presence of memset() -
this function is standard for a very long time, and the
only conditional where HAVE_MEMSET were used, was to
provide replacement for bzero() - in all other places
memset() is used unconditionally.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agoreplace direct calls to memset_s() with commonly used macros
Michael Tokarev [Mon, 18 Nov 2024 11:19:54 +0000 (14:19 +0300)] 
replace direct calls to memset_s() with commonly used macros

samba provides macros for zeroing various structures in memory,
and all code uses them instead of relying on memset_s().
However, a few places use memset_s() directly.  Replace these
usages with macros for consistency and to be able to replace
memset_s() easier.

A few notes.

Commit 03a50d8f7d872b6ef701d12 "lib:util: Check memset_s() error
code in talloc_keep_secret_destructor()" (Aug-2022) added a check
for error return from memset_s().  This is the only place in whole
codebase which bothers about doing this.  But I've difficult time
figuring out the intention.  Was there a real case when this code
path is actually executed?

Commit 7658c9bf0a9c99e3f200571 "lib:crypto: Remove redundant array
zeroing" (Nov-2023) removed the OTHER line from the two lines used
to zero memory in here.  Initially the code used both memset_s()
*and* ZERO_ARRAY_LEN(), the former has been removed.  This change
removes the other - memset_s(), reintroducing ZERO_ARRAY_LEN().
Here however, it's probably better to use BURN_PTR instead of
ZERO_ARRAY - in this place and a few lines above.

Commit 8dddea2ceda40f2365bd6b1 "lib:talloc: Use memset_s() to avoid
the call gets optimized out" (Feb-2024) is a recent commit which
introduces memset_s().  However, it does not seem like it makes
any difference whatsoever for a testsuite, or that it actually
needs to clean up the memory to begin with.

We've quite an assortment of all this memory zeroing stuff.  Also
it is repeated in replace.h and memory.h (two sets in these files
are different but has big intersection).  I'd say, to fix this mess,
things from replace.h should be removed in favour of memory.h, and
necessary includes added, but this is for the next time.  We also
have lots of direct usages of memset_s() in heimdal code.

Cc: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agotestparm: do not fail if /run/samba does not exist
Michael Tokarev [Tue, 26 Apr 2022 13:14:38 +0000 (16:14 +0300)] 
testparm: do not fail if /run/samba does not exist

testparm explicitly fails if $piddir or $lockdir does not exist.
However, the daemons which actually use these directories, will
create it on demand, there is no need to fail even simple testparm
operations if the dirs are not there.

This change lets to (pre)configure samba without bothering to
pre-create the directories which are overwise needed only to fulfil
testparm criteria.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agoMinimal EDNS0 support for built-in DNS client
Michael Tokarev [Mon, 26 Feb 2024 11:15:00 +0000 (14:15 +0300)] 
Minimal EDNS0 support for built-in DNS client

Currently, samba built-in DNS client is UDP-only (it does
support TCP mode, but not all components use it).  In
particular, when winbind queries list of AD DCs (SRV
record) which can be quite large, it uses UDP-only query.
And at the same time, samba DNS client does not support
EDNS0 at all, so the reply is limited to standard DNS
packet size which is 512 bytes.

Add minimal EDNS0 OPT record to ADDITIONAL section when
sending a DNS request out, indicating we can accept
DNS packets up to 4Kb in size.

Since DNSSEC is in wide use today and DNSSEC requires
EDNS0, it is okay to assume ENDS0 is widely supported
these days, so there should be no regressions when
enabling EDNS0.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agopasschange: error message fix
Michael Tokarev [Mon, 26 Feb 2024 12:35:35 +0000 (15:35 +0300)] 
passchange: error message fix

Missing space and newline.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosilence "Can not convert group sid" warnings in the log
Michael Tokarev [Wed, 14 Feb 2024 12:26:29 +0000 (15:26 +0300)] 
silence "Can not convert group sid" warnings in the log

/var/log/samba/log.winbind is full of messages like:

[2024/02/09 06:25:04.788182,  1, pid=74620] source3/winbindd/winbindd_getgroups.c:259(winbindd_getgroups_recv)
  Could not convert sid S-0-0: NT_STATUS_NONE_MAPPED

On a busy server these are logged several 1000s times per minute,
making any other messages basically invisible.

This is a work-around, a proper solution is to handle some
special SIDs (like this one) separately.  Once this is done,
this change can be reverted.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosilence DNS lookup mismatch messages
Michael Tokarev [Mon, 23 Dec 2024 20:26:52 +0000 (23:26 +0300)] 
silence DNS lookup mismatch messages

There's just too much useless noise in the logs,
especially when the PTR record just doesn't exist.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibsamba-errors: eliminate dependency on samba-debug
Michael Tokarev [Mon, 18 Nov 2024 09:45:08 +0000 (12:45 +0300)] 
libsamba-errors: eliminate dependency on samba-debug

libsamba-errors is a collection of error codes/descriptions
like strerror(), - it is a set of simple functions converting
error code to string or the like.  However, in one single
place there's a DBG_DEBUG() "call" in errmap_unix.c, in
map_errno_from_nt_status(), which is here for a very long time
(since before samba3, initially with debug level 10).

Drop this debugging info, and eliminate extra dependency.
This makes libsamba-errors independent and self-contained,
with a well-known and stable ABI.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>