]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
6 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>
6 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>
6 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>
6 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>
7 months agospecify some deps on private libs actually used directly
Michael Tokarev [Thu, 19 May 2022 17:37:21 +0000 (20:37 +0300)] 
specify some deps on private libs actually used directly

Lots of samba libraries has incomplete dependencies listed
in wscript files.  This usually is not a problem since the
link line includes dependencies of their dependencies of
their dependencies, and somewhere down that line all immediate
dependencies which are missing are actually present.  But
sometimes this becomes a problem when a library does not
declare direct dependency on at least one private library
which it actually uses: in case no private library is
listed as direct dependency, private library directory is
not put into RUNPATH of the resulting binary, so the binary
can not find its own dependencies.

Fix a few such places, including some libraries which are
a part of public abi (libsmbldap, libndr).

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 agoHappy New Year 2025!
Stefan Metzmacher [Wed, 1 Jan 2025 07:36:35 +0000 (07:36 +0000)] 
Happy New Year 2025!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jan  1 19:16:03 UTC 2025 on atb-devel-224

7 months agoldb: fix Coverity 1636883
Douglas Bagnall [Mon, 23 Dec 2024 00:07:40 +0000 (13:07 +1300)] 
ldb: fix Coverity 1636883

oops.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Dec 30 04:17:46 UTC 2024 on atb-devel-224

7 months agoutil:datablob: data_blob_pad checks its alignment assumption
Douglas Bagnall [Wed, 11 Dec 2024 01:31:18 +0000 (14:31 +1300)] 
util:datablob: data_blob_pad checks its alignment assumption

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Dec 20 07:59:51 UTC 2024 on atb-devel-224

7 months agobootstrap: we don't need python-crypt-r anymore
Douglas Bagnall [Wed, 11 Dec 2024 21:35:02 +0000 (10:35 +1300)] 
bootstrap: we don't need python-crypt-r anymore

Recent commits made pyglue wrap the same crypt[_r] that dsdb modules
use, which removes an extenal dependency.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopytest: password_hash uses internal _glue.crypt
Douglas Bagnall [Wed, 11 Dec 2024 21:46:16 +0000 (10:46 +1300)] 
pytest: password_hash uses internal _glue.crypt

This will remove an external dependency.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool user: hashlib.sha1 is always present
Douglas Bagnall [Wed, 11 Dec 2024 02:56:20 +0000 (15:56 +1300)] 
samba-tool user: hashlib.sha1 is always present

We maybe thought we were checking that sha1 was in hashlib, but we were
only checking that hashlib is in the Python library (`hashlib.sha1()`
would not raise ImportError).

The documentation says hashlib always contains sha1 -- if that
changes, it is better we know by failing noisily with the import error
at the top of the file.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool user: use _glue.crypt, not crypt.crypt
Douglas Bagnall [Wed, 11 Dec 2024 02:54:48 +0000 (15:54 +1300)] 
samba-tool user: use _glue.crypt, not crypt.crypt

Because we know we have _glue.crypt, and we know it raises exceptions
rather than returning None, we can simplify the checks.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopytest: test that _glue.crypt works
Douglas Bagnall [Wed, 11 Dec 2024 21:44:07 +0000 (10:44 +1300)] 
pytest: test that _glue.crypt works

The test vectors were generated via Python 3.10 crypt module, which
directly wraps crypt(3), which in this case is from glibc 2.39-0ubuntu8.3.

We mainly test the sha256 and sha512 vectors, which seems to be all we
use, and which are said to be widely supported.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopyglue: add crypt() function
Douglas Bagnall [Wed, 11 Dec 2024 01:30:15 +0000 (14:30 +1300)] 
pyglue: add crypt() function

This wraps talloc_crypt_blob() from lib/util/util_crypt.c which in
turn wraps the system crypt[_r[n]].

We want this because the Python standard library crypt module is going
away. That one also wrapped the system crypt or crypt_r, so there
should be no change.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoutil: add a crypt strerror helper
Douglas Bagnall [Wed, 11 Dec 2024 01:30:04 +0000 (14:30 +1300)] 
util: add a crypt strerror helper

This will be used by Python also.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodsdb:password_hash: use talloc_crypt_blob()
Douglas Bagnall [Wed, 11 Dec 2024 22:16:22 +0000 (11:16 +1300)] 
dsdb:password_hash: use talloc_crypt_blob()

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodsdb:password_hash: move hash_blob allocation up
Douglas Bagnall [Wed, 11 Dec 2024 01:29:21 +0000 (14:29 +1300)] 
dsdb:password_hash: move hash_blob allocation up

This will make the next patch simpler.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoutil: add a crypt wrapper, derived from dsdb:password_hash
Douglas Bagnall [Thu, 5 Dec 2024 03:35:51 +0000 (16:35 +1300)] 
util: add a crypt wrapper, derived from dsdb:password_hash

This is going to be used by the dsdb password_hash module, and exposed
to Python via pyglue.

We're doing this because Python 3.13 has dropped crypt from the Python
standard library.

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

Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool: no traceback for unauthenticated rootdse access
Douglas Bagnall [Mon, 29 Jul 2024 21:53:14 +0000 (09:53 +1200)] 
samba-tool: no traceback for unauthenticated rootdse access

Under some circumstances rootdse returns an operations error with
"Operation unavailable without authentication" instead of insufficient
access rights.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Dec 20 00:00:02 UTC 2024 on atb-devel-224

7 months agoldb:dn_compare_base: avoid unlikely int overflow
Douglas Bagnall [Thu, 22 Aug 2024 22:14:04 +0000 (10:14 +1200)] 
ldb:dn_compare_base: avoid unlikely int overflow

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:dn_compare: be a bit more transitive
Douglas Bagnall [Thu, 22 Aug 2024 22:17:17 +0000 (10:17 +1200)] 
ldb:dn_compare: be a bit more transitive

If neither dn can casefold, they should be considered equal. Otherwise
cmp(dn1, dn2) will be inconsistent with cmp(dn2, dn1).

These will still sort to the end of the list, relative to any valid
DNs.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:23:09 +0000 (16:23 +1200)] 
ldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:kv: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:22:28 +0000 (16:22 +1200)] 
ldb:kv: s/ltdb/ldb_kv/ in comments and messages

with some subsequent tidy-ups for style.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:ldb_pack: filter avoids looping over msg when attrs contain "*"
Douglas Bagnall [Fri, 26 Jul 2024 03:47:03 +0000 (15:47 +1200)] 
ldb:ldb_pack: filter avoids looping over msg when attrs contain "*"

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:dn_casefold_internal: TALLOC_FREE only what we talloced
Douglas Bagnall [Wed, 21 Aug 2024 23:03:13 +0000 (11:03 +1200)] 
ldb:dn_casefold_internal: TALLOC_FREE only what we talloced

If the failure is not on the last component, we would have
TALLOC_FREE()ed some components that we hadn't set.

I think in all pathways we initialise the unset components to zero,
but we should be careful just in case.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:tests: add tests ensuring indexes don't change search results
Douglas Bagnall [Sat, 17 Aug 2024 01:34:01 +0000 (13:34 +1200)] 
ldb:tests: add tests ensuring indexes don't change search results

The index code (lib/ldb_key_value/ldb_kv_index.c) recapitulates LDB
expression logic, and it seemed less than completely obvious that it
would never make a mistake and return a different result than an
unindexed search.

Here we run the same search on an unindexed database and on some that
have been indexed with a variety of options. We assert that the
results are identical over a number of searches.

By default, when run from the command line, that number is 495161,
which takes a couple of minutes. But if the SKIP_SLOW_TESTS
environment variable is set, the number is 33569, which takes 20
seconds or so. In selftest we set the variable and run the smaller
number.

The tests will print the cumulative search time for each database for
each testsuite, like this:

$ python3 lib/ldb/tests/python/index_transparency.py
..........................................................[...]
<class '__main__.SearchTest'>
25.78186821937561 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-dn.ldb>
17.73349642753601 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-half-indexed.ldb>
15.14864206314087 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-guid.ldb>
13.107165575027466 <ldb connection mdb:///tmp/tmpf1x72x7l/mdb-indexed.ldb>

Like all benchmarks it is interesting but misleading. One caveat here
is that you have (probably) compiled tdb in developer mode without
optimisation, while lmdb is probably a system package compiled with -O2,
though perhaps not tuned to your exact architecture.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agolib:ldb-samba: use 'ldb' debug class more widely
Douglas Bagnall [Wed, 16 Oct 2024 23:12:46 +0000 (12:12 +1300)] 
lib:ldb-samba: use 'ldb' debug class more widely

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoselftest:S4: use PY_DEV_PROVISION for python dev-mode
Douglas Bagnall [Wed, 18 Sep 2024 01:52:17 +0000 (13:52 +1200)] 
selftest:S4: use PY_DEV_PROVISION for python dev-mode

Maybe we could look also at other -X options and -v.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
\18

7 months agoselftest:S4: use RR_PROVISION for rr recording
Douglas Bagnall [Wed, 18 Sep 2024 01:40:23 +0000 (13:40 +1200)] 
selftest:S4: use RR_PROVISION for rr recording

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoselftest:S4: do not add 'env python' multiple times'
Douglas Bagnall [Wed, 18 Sep 2024 01:38:52 +0000 (13:38 +1200)] 
selftest:S4: do not add 'env python' multiple times'

While we have no sane reason to use

VALGRIND_PROVISION=1 GDB_PROVISION=1 make test...

we will soon gain PY_DEV_PROVISION, which could be useful in tandem
with valgrind, rr, or gdb, and this will allow that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agolibcli/util: let nt_errstr() fallback to hresult_errstr()
Stefan Metzmacher [Mon, 16 Dec 2024 13:46:19 +0000 (14:46 +0100)] 
libcli/util: let nt_errstr() fallback to hresult_errstr()

Sometimes NTSTATUS fields return things like
HRES_SEC_E_WRONG_PRINCIPAL.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Dec 18 18:30:08 UTC 2024 on atb-devel-224

7 months agos4:scripting: fix gen_hresult.py
Stefan Metzmacher [Mon, 16 Dec 2024 13:43:41 +0000 (14:43 +0100)] 
s4:scripting: fix gen_hresult.py

Commit 6877e4849e81ed8f7f355fa4069f13a134e999ce reversed the
return values of hresult_errstr() and hresult_errstr_const().

hresult_errstr() should return "HRES_SEC_E_WRONG_PRINCIPAL",
while hresult_errstr_const() should return
"The target principal name is incorrect.".

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
7 months agolib: Fix error path memleaks in read_ea_list_entry()
Volker Lendecke [Thu, 12 Dec 2024 14:17:05 +0000 (15:17 +0100)] 
lib: Fix error path memleaks in read_ea_list_entry()

Don't leak the result on error

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Dec 18 09:30:33 UTC 2024 on atb-devel-224

7 months agolib: Fix a comment
Volker Lendecke [Thu, 12 Dec 2024 12:59:45 +0000 (13:59 +0100)] 
lib: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Simplify smbd_do_qfsinfo()
Volker Lendecke [Tue, 10 Dec 2024 10:42:59 +0000 (11:42 +0100)] 
smbd: Simplify smbd_do_qfsinfo()

Do early returns, avoid else statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agoFix whitespace
Volker Lendecke [Tue, 10 Dec 2024 15:57:47 +0000 (16:57 +0100)] 
Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: Slightly speed up stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 09:01:19 +0000 (10:01 +0100)] 
vfs: Slightly speed up stream_dir()

lp_parm_bool() is a relatively expensive string-based operation. Do it
only when needed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: Simplify stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 07:09:53 +0000 (08:09 +0100)] 
vfs: Simplify stream_dir()

We know in advance how large "id_hex" is.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agoModernize DEBUGs
Volker Lendecke [Mon, 9 Dec 2024 06:55:45 +0000 (07:55 +0100)] 
Modernize DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agopam_winbind: Fix Bug 15771
Volker Lendecke [Mon, 16 Dec 2024 16:49:43 +0000 (17:49 +0100)] 
pam_winbind: Fix Bug 15771

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15771

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agos3:winbindd: Remove unused set_routing_domain()
Pavel Filipenský [Mon, 16 Dec 2024 13:39:54 +0000 (14:39 +0100)] 
s3:winbindd: Remove unused set_routing_domain()

Commit 9a613f4 winbindd: add routing_domain as parameter to add_trusted_domain
deleted all calls of set_routing_domain().

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec 17 13:30:25 UTC 2024 on atb-devel-224

7 months agonsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:10:48 +0000 (14:10 +0100)] 
nsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:16:07 +0000 (14:16 +0100)] 
s3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:12:22 +0000 (14:12 +0100)] 
s4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE

torture_winbind_struct_show_sequence() is failing if run as:

make -j8 test TESTS="samba4.rpc.lsa.trusted.*ad_dc samba4.winbind.struct.ad_dc"

The reason is that the test constructs two lists of domains and assumes
that the list contain same domains in the same order.

However:

- the list based on DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep) contains 51 domains
- the list based on DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep) contains 39 domains

and we got:

failure: show_sequence [ ../../source4/torture/winbind/struct_based.c:824: domlist[i].netbios_name was TORTURE201, expected TORTURE200: inconsistent order of domain lists
]

Both list are based on full domain list, however the smaller one filters
out domain without trust_type in winbindd_list_trusted_domains():

trust_type = get_trust_type_string(talloc_tos(), d, domain);
if (trust_type == NULL) {
continue;
}

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agonsswitch:wbinfo: Remove implementation of deprecated '--sequence'
Pavel Filipenský [Mon, 16 Dec 2024 12:57:17 +0000 (13:57 +0100)] 
nsswitch:wbinfo: Remove implementation of deprecated '--sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodocs-xml:manpages: Remove deprecated 'wbinfo --sequence'
Pavel Filipenský [Mon, 16 Dec 2024 13:01:42 +0000 (14:01 +0100)] 
docs-xml:manpages: Remove deprecated 'wbinfo --sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>