]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
3 years agolib:util: Check memset_s() error code in talloc_keep_secret_destructor()
Joseph Sutton [Tue, 2 Aug 2022 02:35:33 +0000 (14:35 +1200)] 
lib:util: Check memset_s() error code in talloc_keep_secret_destructor()

Panic if memset_s() fails.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR password change
Joseph Sutton [Tue, 5 Jul 2022 08:17:33 +0000 (20:17 +1200)] 
CVE-2021-20251 s3: Ensure bad password count atomic updates for SAMR password change

The bad password count is supposed to limit the number of failed login
attempt a user can make before being temporarily locked out, but race
conditions between processes have allowed determined attackers to make
many more than the specified number of attempts.  This is especially
bad on constrained or overcommitted hardware.

To fix this, once a bad password is detected, we reload the sam account
information under a user-specific mutex, ensuring we have an up to
date bad password count.

Derived from a similar patch to source3/auth/check_samsec.c by
Jeremy Allison <jra@samba.org>

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s3: ensure bad password count atomic updates
Jeremy Allison [Mon, 11 Jan 2021 20:11:35 +0000 (12:11 -0800)] 
CVE-2021-20251 s3: ensure bad password count atomic updates

The bad password count is supposed to limit the number of failed login
attempt a user can make before being temporarily locked out, but race
conditions between processes have allowed determined attackers to make
many more than the specified number of attempts.  This is especially
bad on constrained or overcommitted hardware.

To fix this, once a bad password is detected, we reload the sam account
information under a user-specific mutex, ensuring we have an up to
date bad password count.

Discovered by Nathaniel W. Turner.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:auth_winbind: Check return status of authsam_logon_success_accounting()
Joseph Sutton [Mon, 4 Jul 2022 08:51:38 +0000 (20:51 +1200)] 
CVE-2021-20251 s4:auth_winbind: Check return status of authsam_logon_success_accounting()

This may return an error if we find the account is locked out.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4-rpc_server: Check badPwdCount update return status
Joseph Sutton [Sat, 9 Jul 2022 03:55:02 +0000 (15:55 +1200)] 
CVE-2021-20251 s4-rpc_server: Check badPwdCount update return status

If the account has been locked out in the meantime (indicated by
NT_STATUS_ACCOUNT_LOCKED_OUT), we should return the appropriate error
code.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:kdc: Check badPwdCount update return status
Joseph Sutton [Sat, 9 Jul 2022 03:54:52 +0000 (15:54 +1200)] 
CVE-2021-20251 s4:kdc: Check badPwdCount update return status

If the account has been locked out in the meantime (indicated by
NT_STATUS_ACCOUNT_LOCKED_OUT), we should return the appropriate error
code.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:kdc: Check return status of authsam_logon_success_accounting()
Joseph Sutton [Fri, 1 Jul 2022 03:04:41 +0000 (15:04 +1200)] 
CVE-2021-20251 s4:kdc: Check return status of authsam_logon_success_accounting()

If we find that the user has been locked out sometime during the request
(due to a race), we will now return an error code.

Note that we cannot avoid the MIT KDC aspect of the issue by checking
the return status of mit_samba_zero_bad_password_count(), because
kdb_vftabl::audit_as_req() returning void means we cannot pass on the
result.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:kdc: Move logon success accounting code into existing branch
Joseph Sutton [Tue, 5 Jul 2022 23:11:43 +0000 (11:11 +1200)] 
CVE-2021-20251 s4:kdc: Move logon success accounting code into existing branch

This simplifies the code for the following commit.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:dsdb: Make badPwdCount update atomic
Joseph Sutton [Sat, 9 Jul 2022 03:54:12 +0000 (15:54 +1200)] 
CVE-2021-20251 s4:dsdb: Make badPwdCount update atomic

We reread the account details inside the transaction in case the account
has been locked out in the meantime. If it has, we return the
appropriate error code.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4:dsdb: Update bad password count inside transaction
Joseph Sutton [Sat, 9 Jul 2022 03:44:21 +0000 (15:44 +1200)] 
CVE-2021-20251 s4:dsdb: Update bad password count inside transaction

Previously, there was a gap between calling dsdb_update_bad_pwd_count()
and dsdb_module_modify() where no transaction was in effect. Another
process could slip in and modify badPwdCount, only for our update to
immediately overwrite it. Doing the update inside the transaction will
help for the following commit when we make it atomic.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4-auth: Pass through error code from badPwdCount update
Joseph Sutton [Sat, 9 Jul 2022 03:53:51 +0000 (15:53 +1200)] 
CVE-2021-20251 s4-auth: Pass through error code from badPwdCount update

The error code may be NT_STATUS_ACCOUNT_LOCKED_OUT, which we use in
preference to NT_STATUS_WRONG_PASSWORD.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 auth4: Avoid reading the database twice by precaculating some variables
Andrew Bartlett [Tue, 30 Mar 2021 03:48:31 +0000 (16:48 +1300)] 
CVE-2021-20251 auth4: Avoid reading the database twice by precaculating some variables

These variables are not important to protect against a race with
and a double-read can easily be avoided by moving them up the file
a little.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: Inline samdb_result_effective_badPwdCount() in authsam_logon_su...
Andrew Bartlett [Thu, 25 Mar 2021 02:33:08 +0000 (15:33 +1300)] 
CVE-2021-20251 auth4: Inline samdb_result_effective_badPwdCount() in authsam_logon_success_accounting()

By bringing this function inline it can then be split out in a
subsequent commit.

Based on work by Gary Lockyer <gary@catalyst.net.nz>

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: Split authsam_calculate_lastlogon_sync_interval() out
Andrew Bartlett [Thu, 25 Mar 2021 01:42:39 +0000 (14:42 +1300)] 
CVE-2021-20251 auth4: Split authsam_calculate_lastlogon_sync_interval() out

authsam_calculate_lastlogon_sync_interval() is split out of authsam_update_lastlogon_timestamp()

Based on work by Gary Lockyer <gary@catalyst.net.nz>

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: Return only the result message and free the surrounding result
Gary Lockyer [Wed, 24 Mar 2021 22:30:59 +0000 (11:30 +1300)] 
CVE-2021-20251 auth4: Return only the result message and free the surrounding result

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: Add missing newline to debug message on PSO read failure
Andrew Bartlett [Tue, 30 Mar 2021 03:35:44 +0000 (16:35 +1300)] 
CVE-2021-20251 auth4: Add missing newline to debug message on PSO read failure

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 s4 auth: make bad password count increment atomic
Andrew Bartlett [Tue, 30 Mar 2021 05:01:39 +0000 (18:01 +1300)] 
CVE-2021-20251 s4 auth: make bad password count increment atomic

Ensure that the bad password count is incremented atomically,
and that the successful logon accounting data is updated atomically.

Use bad password indicator (in a distinct TDB) to determine if to open a transaction

We open a transaction when we have seen the hint that this user
has recorded a bad password.  This allows us to avoid always
needing one, while not missing a possible lockout.

We also go back and get a transation if we did not take out
one out but we chose to do a write (eg for lastLogonTimestamp)

Based on patches by Gary Lockyer <gary@catalyst.net.nz>

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: Detect ACCOUNT_LOCKED_OUT error for password change
Joseph Sutton [Tue, 5 Jul 2022 08:17:49 +0000 (20:17 +1200)] 
CVE-2021-20251 auth4: Detect ACCOUNT_LOCKED_OUT error for password change

This is more specific than NT_STATUS_UNSUCCESSFUL, and for the SAMR
password change, matches the result the call to samdb_result_passwords()
would give.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4 auth test: Unit tests for source4/auth/sam.c
Gary Lockyer [Mon, 8 Feb 2021 22:59:05 +0000 (11:59 +1300)] 
CVE-2021-20251 s4 auth test: Unit tests for source4/auth/sam.c

cmocka unit tests for the authsam_reread_user_logon_data in
source4/auth/sam.c

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 auth4: Reread the user record if a bad password is noticed.
Andrew Bartlett [Tue, 30 Mar 2021 04:57:10 +0000 (17:57 +1300)] 
CVE-2021-20251 auth4: Reread the user record if a bad password is noticed.

As is, this is pointless, as we need a transaction to make this
any less of a race, but this provides the steps towards that goal.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 s4 auth: Prepare to make bad password count increment atomic
Gary Lockyer [Wed, 27 Jan 2021 01:24:58 +0000 (14:24 +1300)] 
CVE-2021-20251 s4 auth: Prepare to make bad password count increment atomic

To ensure that the bad password count is incremented atomically,
and that the successful logon accounting data is updated atomically,
without always opening a transaction, we will need to make a note
of all bad and successful passwords in a side-DB outside the
transaction lock.

This provides the functions needed for that and hooks them in
(future commits will handle errors and use the results).

Based on patches by Gary Lockyer <gary@catalyst.net.nz>

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 auth4: split samdb_result_msds_LockoutObservationWindow() out
Gary Lockyer [Mon, 15 Mar 2021 21:52:58 +0000 (10:52 +1300)] 
CVE-2021-20251 auth4: split samdb_result_msds_LockoutObservationWindow() out

samdb_result_msds_LockoutObservationWindow() is split out of
samdb_result_effective_badPwdCount()

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

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user
Andrew Bartlett [Mon, 29 Mar 2021 21:51:26 +0000 (10:51 +1300)] 
CVE-2021-20251 s4-rpc_server: Use authsam_search_account() to find the user

This helps the bad password and audit log handling code as it
allows assumptions to be made about the attributes found in
the variable "msg", such as that DSDB_SEARCH_SHOW_EXTENDED_DN
was used.

This ensures we can re-search on the DN via the embedded GUID,
which in in turn rename-proof.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agoCVE-2021-20251 tests/krb5: Add tests for password lockout race
Joseph Sutton [Mon, 4 Jul 2022 08:48:48 +0000 (20:48 +1200)] 
CVE-2021-20251 tests/krb5: Add tests for password lockout race

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 lib:crypto: Add Python functions for AES SAMR password change
Joseph Sutton [Tue, 2 Aug 2022 02:35:19 +0000 (14:35 +1200)] 
CVE-2021-20251 lib:crypto: Add Python functions for AES SAMR password change

These functions allow us to perform key derivation and AES256 encryption
in Python. They will be used in a following commit.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 lib:crypto: Add md4_hash_blob() for hashing data with MD4
Joseph Sutton [Wed, 13 Jul 2022 02:20:59 +0000 (14:20 +1200)] 
CVE-2021-20251 lib:crypto: Add md4_hash_blob() for hashing data with MD4

This lets us access MD4, which might not be available in hashlib, from
Python. This function is used in a following commit for hashing a
password to obtain the verifier for a SAMR password change.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2021-20251 lib:crypto: Add des_crypt_blob_16() for encrypting data with DES
Joseph Sutton [Wed, 6 Jul 2022 03:36:26 +0000 (15:36 +1200)] 
CVE-2021-20251 lib:crypto: Add des_crypt_blob_16() for encrypting data with DES

This lets us access single-DES from Python. This function is used in a
following commit for encrypting an NT hash to obtain the verifier for a
SAMR password change.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agolib:crypto: Use constant time memory comparison to check HMAC
Joseph Sutton [Tue, 2 Aug 2022 02:34:55 +0000 (14:34 +1200)] 
lib:crypto: Use constant time memory comparison to check HMAC

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agolib:crypto: Check for overflow before filling pauth_tag array
Joseph Sutton [Tue, 2 Aug 2022 02:34:26 +0000 (14:34 +1200)] 
lib:crypto: Check for overflow before filling pauth_tag array

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:torture: Zero samr_UserInfo union in password set test
Joseph Sutton [Tue, 2 Aug 2022 03:21:43 +0000 (15:21 +1200)] 
s4:torture: Zero samr_UserInfo union in password set test

If init_samr_CryptPasswordAES() does not fill the
u.info31.password.auth_data array completely, we may be comparing
uninitialised bytes.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agolib:crypto: Zero auth_tag array in encryption test
Joseph Sutton [Tue, 2 Aug 2022 03:19:02 +0000 (15:19 +1200)] 
lib:crypto: Zero auth_tag array in encryption test

If samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt() does not fill the
array completely, we may be comparing uninitialised bytes.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos3:rpc_server: Fix typo in error message
Joseph Sutton [Tue, 2 Aug 2022 02:01:59 +0000 (14:01 +1200)] 
s3:rpc_server: Fix typo in error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos3: smbtorture: In run_smb1_dfs_paths() ensure we're actually reading and testing...
Jeremy Allison [Wed, 7 Sep 2022 22:15:38 +0000 (15:15 -0700)] 
s3: smbtorture: In run_smb1_dfs_paths() ensure we're actually reading and testing crtimes from the filesystem.

Ensures crtime of the root of the share and a newly created
file crtime are different. Should help avoid mistakes like the
error fixed by the previous commit.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Sep 12 16:21:23 UTC 2022 on sn-devel-184

3 years agos3: smbtorture3: Fix invalid tests for file identity.
Jeremy Allison [Wed, 7 Sep 2022 22:13:45 +0000 (15:13 -0700)] 
s3: smbtorture3: Fix invalid tests for file identity.

The test SMB1-DFS-PATHS was using the file ino number
to check for file identity, fetching it using cli_qfileinfo_basic().

This works for SMB2, but the info level used by this for SMB1
(SMB_QUERY_FILE_ALL_INFO) doesn't return the ino number, so
all comparisons were succeeding as zero.

Change to using crtime (create time) for identity comparison
instead. This fix is mostly a rename of ino -> crtime, with
some changes around the tests and printf on error, but it
is easier to do in one go.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agos4:kdc: Set Kerberos debug class for all KDC files
Andreas Schneider [Fri, 9 Sep 2022 10:32:57 +0000 (12:32 +0200)] 
s4:kdc: Set Kerberos debug class for all KDC files

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Sep 12 03:27:55 UTC 2022 on sn-devel-184

3 years agodocs-xml: some fixes and updates for ea and acl docs in smb.conf
Björn Jacke [Sun, 11 Sep 2022 19:35:07 +0000 (21:35 +0200)] 
docs-xml: some fixes and updates for ea and acl docs in smb.conf

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoFix spelling mistakes.
Michael Tokarev [Fri, 9 Sep 2022 20:45:38 +0000 (13:45 -0700)] 
Fix spelling mistakes.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Sep 12 02:29:32 UTC 2022 on sn-devel-184

3 years agotests/krb5: Add claims tests
Joseph Sutton [Fri, 4 Mar 2022 03:23:32 +0000 (16:23 +1300)] 
tests/krb5: Add claims tests

Based on tests originally written by Stefan Metzmacher <metze@samba.org>

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Sep  9 01:11:05 UTC 2022 on sn-devel-184

3 years agotests/krb5: Allow specifying sname for getting service ticket
Joseph Sutton [Mon, 7 Mar 2022 04:07:03 +0000 (17:07 +1300)] 
tests/krb5: Allow specifying sname for getting service ticket

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Check claims buffers
Joseph Sutton [Fri, 4 Mar 2022 03:22:07 +0000 (16:22 +1300)] 
tests/krb5: Check claims buffers

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add xpress (de)compression functions
Joseph Sutton [Fri, 4 Mar 2022 03:21:19 +0000 (16:21 +1300)] 
tests/krb5: Add xpress (de)compression functions

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agotests/krb5: Add function for creating claims
Joseph Sutton [Fri, 4 Mar 2022 03:20:18 +0000 (16:20 +1300)] 
tests/krb5: Add function for creating claims

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agokrb5pac.idl: Add definitions for claims PAC buffers
Joseph Sutton [Fri, 4 Mar 2022 03:17:40 +0000 (16:17 +1300)] 
krb5pac.idl: Add definitions for claims PAC buffers

The PAC device info definition comes from [MS-PAC] 2.12.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoclaims.idl: Add claim type definitions
Joseph Sutton [Thu, 8 Sep 2022 23:02:01 +0000 (11:02 +1200)] 
claims.idl: Add claim type definitions

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agos4:kdc: Set kerberos debug class for kdc service
Andreas Schneider [Tue, 6 Sep 2022 08:19:54 +0000 (10:19 +0200)] 
s4:kdc: Set kerberos debug class for kdc service

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Sep  8 23:34:15 UTC 2022 on sn-devel-184

3 years agoselftest: Add Address Sanitizer suppressions
Andreas Schneider [Tue, 6 Sep 2022 08:06:37 +0000 (10:06 +0200)] 
selftest: Add Address Sanitizer suppressions

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoselftest: Create asan_options variable
Andreas Schneider [Tue, 6 Sep 2022 08:06:05 +0000 (10:06 +0200)] 
selftest: Create asan_options variable

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoselftest: Fix address sanitizer with python3
Andreas Schneider [Tue, 6 Sep 2022 06:59:56 +0000 (08:59 +0200)] 
selftest: Fix address sanitizer with python3

==9542==AddressSanitizer: failed to intercept 'crypt'
==9542==AddressSanitizer: failed to intercept 'crypt_r'

[..]

AddressSanitizer:DEADLYSIGNAL
=================================================================
==29768==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000000000 bp 0x7ffcec4bf3c0 sp 0x7ffcec4beb58 T0)
==29768==Hint: pc points to the zero page.
==29768==The signal is caused by a READ memory access.
==29768==Hint: address points to the zero page.
    #0 0x0  (<unknown module>)
    #1 0x7f052cca4129 in crypt_crypt_impl /usr/src/debug/python310-core-3.10.6-3.1.x86_64/Modules/_cryptmodule.c:44

We would need to build python without --as-needed as we can't so that
we need to preload the library to avoid a segfault.

See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98669

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoselftest: Remove tailing whitspaces in selftest.pl
Andreas Schneider [Tue, 6 Sep 2022 06:48:49 +0000 (08:48 +0200)] 
selftest: Remove tailing whitspaces in selftest.pl

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agowaf: Do not use as-needed if we build with Address Sanitizer
Andreas Schneider [Tue, 6 Sep 2022 06:47:47 +0000 (08:47 +0200)] 
waf: Do not use as-needed if we build with Address Sanitizer

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98669

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4:gensec: Do not link subsystems against dlopen() modules!
Andreas Schneider [Thu, 8 Sep 2022 08:32:38 +0000 (10:32 +0200)] 
s4:gensec: Do not link subsystems against dlopen() modules!

This is not a shared library. This only worked because we use
'--as-needed' as linker option.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest samba-tool forest: use runcmd
Douglas Bagnall [Wed, 7 Sep 2022 10:17:41 +0000 (22:17 +1200)] 
pytest samba-tool forest: use runcmd

This is an example/test to show how runsublevelcmd() converts into
runcmd() whilst ensuring it works.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agomake runcmd, runsubcmd, exact aliases
Douglas Bagnall [Wed, 7 Sep 2022 10:17:05 +0000 (22:17 +1200)] 
make runcmd, runsubcmd, exact aliases

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest: samba-tool: coalesce run*cmd functions
Douglas Bagnall [Wed, 7 Sep 2022 04:57:46 +0000 (16:57 +1200)] 
pytest: samba-tool: coalesce run*cmd functions

We have had three different functions for resolving samba-tool commands,
depending on whether they are nested 1, 2, or n deep (where n could also
be 1 or 2). This API evolved around a separation of sub-command names and
options, so that the Command that was eventually found could be given the
right outf and errf.

Now we can just use the same outf and errf for all levels, and we can not
care about this distinction.

All these functions are now synonyms, and we keep them all for now for
backward-compatibility.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: binary uses samba_tool function
Douglas Bagnall [Wed, 7 Sep 2022 22:17:54 +0000 (10:17 +1200)] 
samba-tool: binary uses samba_tool function

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest/samba-tool: entry function follows too logic
Douglas Bagnall [Thu, 8 Sep 2022 08:27:33 +0000 (20:27 +1200)] 
pytest/samba-tool: entry function follows too logic

To further align the logic of the tool and the tests, we use
the same logic in the test function as in samba-tool.  In
effect, this means the function is even less likely to raise
an exception, rahter printing it out and returning an error code.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest/password-lockout: fix using samba_tool function
Douglas Bagnall [Wed, 7 Sep 2022 10:04:08 +0000 (22:04 +1200)] 
pytest/password-lockout: fix using samba_tool function

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest/samba_dnsupdate: fix using samba-tool function
Douglas Bagnall [Wed, 7 Sep 2022 10:03:16 +0000 (22:03 +1200)] 
pytest/samba_dnsupdate: fix using samba-tool function

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest/netcmd: fix for new samba-tool api
Douglas Bagnall [Wed, 7 Sep 2022 10:03:47 +0000 (22:03 +1200)] 
pytest/netcmd: fix for new samba-tool api

In this case we are skipping _resolve().

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: add a convenience function that does it all
Douglas Bagnall [Wed, 7 Sep 2022 22:00:36 +0000 (10:00 +1200)] 
samba-tool: add a convenience function that does it all

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: command that has exception, shows exception
Douglas Bagnall [Wed, 7 Sep 2022 20:56:45 +0000 (08:56 +1200)] 
samba-tool: command that has exception, shows exception

This will make a difference to the string printed in the cases that
call self.usage(), resulting in more specified usage for the
sub-command. It would also matter if the samba-tool sub-command had a
different .show_command_error() or .errf, but I don't think that
happens.

Note: usually command._run() will have caught and shown the exception,
returning -1.

We also rename away 'cmd' so we don't again imagine it is the command
we are running.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: _resolve() can set outf, errf
Douglas Bagnall [Wed, 7 Sep 2022 04:33:33 +0000 (16:33 +1200)] 
samba-tool: _resolve() can set outf, errf

We catch output in outf and errf for testing, which we currently do
with

    cmd.outf = self.stringIO()
    cmd.errf = self.stringIO()

on the final resolved commands. But this does not catch the output of
the super-commands, of which we normally expect none. Using

    supercmd._resolve(*args, outf=self.stringIO(), errf=self.stringIO())

will redirect output all the way up the chain.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: more conventional usage of parser.parse_args
Douglas Bagnall [Wed, 7 Sep 2022 03:07:43 +0000 (15:07 +1200)] 
samba-tool: more conventional usage of parser.parse_args

By default parse_args will use sys.argv[1:], which is to say the
command-line without the command name. We have always fed it the
equivalent of sys.argv, then trimmed the command off the result. That
was a bit silly.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: separate ._run() from command resolution
Douglas Bagnall [Wed, 7 Sep 2022 03:34:23 +0000 (15:34 +1200)] 
samba-tool: separate ._run() from command resolution

Prior to this commit, in super-commands, the first half of the _run()
is resolving what sub-command to run, and the second half is working
out what to print if that failed. Some issues with that are:

 * it looks a little bit complicated.

 * the tests can't use the tool's resolution code, because it runs
   immediately, while the tests first want to fiddle with self.outf
   and so on.

 * it makes it harder to subclass and override the resolution code, so
   instead we do strange things like where we subclass dict as in
   main.py.

So we split it into ._resolve() and ._run().

There are a few tests that break. We mark these as flapping, rather
than knownfail, so as to avoid going into extremely fine-grain filters
for tests that will be fixed within a few commits.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: do not crash on unimplemented .run()
Douglas Bagnall [Tue, 16 Aug 2022 01:43:54 +0000 (13:43 +1200)] 
samba-tool: do not crash on unimplemented .run()

The run() method is always called with arguments, so it crashes before
the NotImplementedError() is ever reached. That's OK, but this is better.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos3:libads: let cldap_ping_list() use cldap_multi_netlogon()
Stefan Metzmacher [Wed, 24 Aug 2022 14:11:06 +0000 (16:11 +0200)] 
s3:libads: let cldap_ping_list() use cldap_multi_netlogon()

We have a list of ip addresses, so we can request them
all together under a single timeout, instead of asking
each ip with it's own timeout.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Sep  8 08:12:46 UTC 2022 on sn-devel-184

3 years agos3:libads: split out ads_fill_cldap_reply() out of ads_try_connect()
Stefan Metzmacher [Wed, 24 Aug 2022 14:36:17 +0000 (16:36 +0200)] 
s3:libads: split out ads_fill_cldap_reply() out of ads_try_connect()

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
3 years agos3:modules - fix read of uninitialized memory
Andrew Walker [Tue, 6 Sep 2022 20:45:58 +0000 (16:45 -0400)] 
s3:modules - fix read of uninitialized memory

For loop accesses entry->next after entry
has been removed from list in glfs_clear_preopened().

Signed-off-by: Andrew Walker <awalker@ixsystems.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Sep  7 19:40:17 UTC 2022 on sn-devel-184

3 years agontlm_auth: Remove an unused #include
Volker Lendecke [Tue, 6 Sep 2022 18:52:27 +0000 (20:52 +0200)] 
ntlm_auth: Remove an unused #include

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agotorture3: Pass NULL to ReadDirName
Volker Lendecke [Tue, 6 Sep 2022 08:43:29 +0000 (10:43 +0200)] 
torture3: Pass NULL to ReadDirName

Do the necessary fstat manually

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Remove an unused variable
Volker Lendecke [Tue, 6 Sep 2022 07:29:18 +0000 (09:29 +0200)] 
smbd: Remove an unused variable

ReadDirName happily takes NULL for "sbuf"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agotorture3: Remove an unused variable
Volker Lendecke [Tue, 6 Sep 2022 07:16:14 +0000 (09:16 +0200)] 
torture3: Remove an unused variable

ReadDirName happily takes NULL for "sbuf"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Remove unused variables
Volker Lendecke [Tue, 6 Sep 2022 07:07:31 +0000 (09:07 +0200)] 
smbd: Remove unused variables

ReadDirName happily takes NULL for "sbuf"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Shorten long lines
Volker Lendecke [Mon, 5 Sep 2022 13:31:19 +0000 (15:31 +0200)] 
smbd: Shorten long lines

This code is young enough to justify a README.Coding patch, at least
IMO.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbtorture3: Avoid an "else"
Volker Lendecke [Mon, 5 Sep 2022 11:08:54 +0000 (13:08 +0200)] 
smbtorture3: Avoid an "else"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agoldb: Fix a typo
Volker Lendecke [Tue, 6 Sep 2022 10:35:20 +0000 (12:35 +0200)] 
ldb: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agoldb: Fix a typo
Volker Lendecke [Tue, 6 Sep 2022 10:15:14 +0000 (12:15 +0200)] 
ldb: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolibrpc: Simplify ndr_size_dom_sid28()
Volker Lendecke [Wed, 31 Aug 2022 15:35:42 +0000 (17:35 +0200)] 
librpc: Simplify ndr_size_dom_sid28()

Don't duplicate the calculation

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agolibrpc: Simplify ndr_size_dom_sid28()
Volker Lendecke [Wed, 31 Aug 2022 15:35:03 +0000 (17:35 +0200)] 
librpc: Simplify ndr_size_dom_sid28()

all_zero() treats a NULL pointer as true.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: Save a few lines by using tevent_req_nterror()'s retval
Volker Lendecke [Thu, 1 Sep 2022 10:30:57 +0000 (12:30 +0200)] 
smbd: Save a few lines by using tevent_req_nterror()'s retval

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosamba-tool ntacl: better messages for missing files
Douglas Bagnall [Wed, 10 Aug 2022 23:26:44 +0000 (11:26 +1200)] 
samba-tool ntacl: better messages for missing files

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Sep  7 06:02:20 UTC 2022 on sn-devel-184

3 years agopysmbd: set_nt_acl() can raise FileNotFoundError
Douglas Bagnall [Thu, 1 Sep 2022 01:18:12 +0000 (01:18 +0000)] 
pysmbd: set_nt_acl() can raise FileNotFoundError

rather than an NTStatusError, which is harder to decipher, and which
carries less information (namely, not the name of the problematic file).

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopysmbd: get_nt_acl() raises FileNotFoundError if appropriate
Douglas Bagnall [Wed, 31 Aug 2022 23:25:26 +0000 (11:25 +1200)] 
pysmbd: get_nt_acl() raises FileNotFoundError if appropriate

rather than an NTStatusError, which is harder to decipher, and which
carries less information (namely, not the name of the problematic
file).

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopysmbd: avoid leaks in get_nt_acl()
Douglas Bagnall [Wed, 31 Aug 2022 23:06:03 +0000 (11:06 +1200)] 
pysmbd: avoid leaks in get_nt_acl()

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopybindings: xattr_native raises OSError not TypeError
Douglas Bagnall [Wed, 7 Sep 2022 00:56:37 +0000 (12:56 +1200)] 
pybindings: xattr_native raises OSError not TypeError

Most likely it is a bad filename or attribute, not the wrong type of
argument.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest: posixacl getntacl should raise OSError
Douglas Bagnall [Wed, 7 Sep 2022 00:46:42 +0000 (12:46 +1200)] 
pytest: posixacl getntacl should raise OSError

Not TypeError, which is supposed to be about Python data types. This
way we get to check/see an errno and strerror, and will allow us to
set the filename which will be useful for some errors.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest: samba-tool ntacl should report errors better
Douglas Bagnall [Wed, 31 Aug 2022 22:29:59 +0000 (10:29 +1200)] 
pytest: samba-tool ntacl should report errors better

We want `samba-tool ntacl sysvolreset` and `samba-tool ntacl
sysvolcheck` to fail when the Policies folder is not in place, but not
to produce an inscrutable stacktrace.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: use string_to_level helper()
Douglas Bagnall [Wed, 31 Aug 2022 02:40:46 +0000 (14:40 +1200)] 
samba-tool domain: use string_to_level helper()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Tue Sep  6 22:07:23 UTC 2022 on sn-devel-184

3 years agosamba-tool domain: add string_to_level() helper
Douglas Bagnall [Wed, 31 Aug 2022 01:47:45 +0000 (13:47 +1200)] 
samba-tool domain: add string_to_level() helper

Reverse transform of level_to_string(), obviously.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: expand string_version_to_constant range
Douglas Bagnall [Wed, 31 Aug 2022 01:35:57 +0000 (13:35 +1200)] 
samba-tool domain: expand string_version_to_constant range

This won't actually have any effect yet -- the new values are
inaccessible in the place it is used because the range is limited by
the --function-level option config.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain show: report level 2016
Douglas Bagnall [Wed, 31 Aug 2022 01:13:20 +0000 (13:13 +1200)] 
samba-tool domain show: report level 2016

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain show: use level_to_string()
Douglas Bagnall [Wed, 31 Aug 2022 01:28:50 +0000 (13:28 +1200)] 
samba-tool domain show: use level_to_string()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: helper function for domain level names
Douglas Bagnall [Wed, 31 Aug 2022 01:12:06 +0000 (13:12 +1200)] 
samba-tool domain: helper function for domain level names

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use CommandError on auth failure
Douglas Bagnall [Wed, 17 Aug 2022 23:53:29 +0000 (11:53 +1200)] 
samba-tool ldapcmp: use CommandError on auth failure

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use CommandError, not assertion
Douglas Bagnall [Wed, 17 Aug 2022 23:52:54 +0000 (11:52 +1200)] 
samba-tool ldapcmp: use CommandError, not assertion

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: do not assume common attributes
Douglas Bagnall [Wed, 17 Aug 2022 23:38:35 +0000 (11:38 +1200)] 
samba-tool ldapcmp: do not assume common attributes

This has caused numerous reports of

ERROR(<class 'KeyError'>): uncaught exception - 'serverReferenceBL'
  File /usr/lib/python3/dist-packages/samba/netcmd/__init__.py, line 185, in _run
    return self.run(*args, **kwargs)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 957, in run
    if b1.diff(b2):
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 781, in diff
    if object1 == object2:
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 549, in __eq__
    return self.cmp_attrs(other)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 590, in cmp_attrs
    if isinstance(self.attributes[x], list) and isinstance(other.attributes[x], list):

because other does not have attribute 'x'.

It is better to assume other.attributes[x] is None, which will compare
as unequal to whatever self.attributes[x] is, showing up as a diff
rather than a crash.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use shorter names in cmp_attrs
Douglas Bagnall [Wed, 17 Aug 2022 23:34:53 +0000 (11:34 +1200)] 
samba-tool ldapcmp: use shorter names in cmp_attrs

This simplifies a fix in the next commit.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use ValueError, not Exception
Douglas Bagnall [Wed, 17 Aug 2022 23:32:25 +0000 (11:32 +1200)] 
samba-tool ldapcmp: use ValueError, not Exception

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: catch werror.WERR_ACCESS_DENIED
Douglas Bagnall [Wed, 17 Aug 2022 22:58:54 +0000 (10:58 +1200)] 
samba-tool dns: catch werror.WERR_ACCESS_DENIED

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: use DnsconnWrapper in zonecreate
Douglas Bagnall [Sat, 13 Aug 2022 00:55:01 +0000 (12:55 +1200)] 
samba-tool dns: use DnsconnWrapper in zonecreate

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>