]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
2 years agopytest:auth_log_base: use string_is_guid()
Douglas Bagnall [Wed, 28 Feb 2024 03:19:38 +0000 (16:19 +1300)] 
pytest:auth_log_base: use string_is_guid()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopylibs: add string_is_guid() helper.
Douglas Bagnall [Thu, 15 Feb 2024 21:20:24 +0000 (21:20 +0000)] 
pylibs: add string_is_guid() helper.

In various places we use regular expressions to check for GUID-ness,
though typically we don't match GUIDs with uppercase hex digits when
we really should.

If we centralise the check, we have more chance of getting it right.

Pair-programmed-by: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Feb 29 02:38:07 UTC 2024 on atb-devel-224

2 years agosamba-tool: with --json, error messages are in JSON
Douglas Bagnall [Wed, 28 Feb 2024 03:14:24 +0000 (16:14 +1300)] 
samba-tool: with --json, error messages are in JSON

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool: instances remember whether --json was requested
Douglas Bagnall [Wed, 28 Feb 2024 03:13:15 +0000 (16:13 +1300)] 
samba-tool: instances remember whether --json was requested

All our subcommands are going to learn --json eventually, and they
shouldn't all have to do this individually.

The next commit uses this to automatically format CommandErrors as JSON.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool: add self.print_json_status() helper
Douglas Bagnall [Fri, 16 Feb 2024 00:59:25 +0000 (00:59 +0000)] 
samba-tool: add self.print_json_status() helper

This is a helper to return JSON for simple messages.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool: avoid mutable Command class values
Douglas Bagnall [Fri, 23 Feb 2024 03:19:02 +0000 (16:19 +1300)] 
samba-tool: avoid mutable Command class values

These values are shared across all instances of the class,
which makes no difference in samba-tool itself, because there
is one instance per process. But in tests we can have many
Command classes at once (due to runcmd()), and if any of them
happened to append to takes_args or takes_options rather than
replacing it, well, the effect would be subtle.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool domain level: avoid using assert
Douglas Bagnall [Wed, 14 Feb 2024 05:09:30 +0000 (05:09 +0000)] 
samba-tool domain level: avoid using assert

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool domain claim: use secrets module for token
Douglas Bagnall [Fri, 2 Feb 2024 01:23:38 +0000 (14:23 +1300)] 
samba-tool domain claim: use secrets module for token

`binascii.hexlify(os.urandom(8)).decode()` was fine, but `os.urandom`
is OS specific and can theoretically block (says the documentation).

We will let Python's secrets module worry about such details.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool user getpassword: Also return the time a GMSA password is valid until
Andrew Bartlett [Thu, 8 Feb 2024 22:44:33 +0000 (11:44 +1300)] 
samba-tool user getpassword: Also return the time a GMSA password is valid until

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agosamba-tool: Allow ;format=UnixTime etc to operate on virtual attributes
Andrew Bartlett [Wed, 28 Feb 2024 04:27:31 +0000 (17:27 +1300)] 
samba-tool: Allow ;format=UnixTime etc to operate on virtual attributes

To convert a virtual attribute we must understand that it has
been put into "obj" under the name including the ;format= part
and so we must look it back up with that name when looking to
covert it from (say) NTTIME to a unix time.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agopython/samba/tests: Include more detail on invoication in test of "samba-tool user...
Andrew Bartlett [Wed, 28 Feb 2024 21:38:38 +0000 (10:38 +1300)] 
python/samba/tests: Include more detail on invoication in test of "samba-tool user show"

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agosamba-tool user getpassword: Do not show preview of gMSA password
Andrew Bartlett [Fri, 2 Feb 2024 03:10:06 +0000 (16:10 +1300)] 
samba-tool user getpassword: Do not show preview of gMSA password

The AD server will send a preview of the next gMSA password, 5mins before
it is expected to be active.

This is useful in a keytab, which needs to be in place before a ticket
could possibly be issued, but is not helpful for authentication, as
the server also accepts passwords for 5mins after the change.

This avoids needing teach all users of this tool how to fall back to
the previous password for a 5min period every 30 days, by default.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agos3:libads: Trace ldap search base/filter/scope
Pavel Filipenský [Mon, 26 Feb 2024 07:31:24 +0000 (08:31 +0100)] 
s3:libads: Trace ldap search base/filter/scope

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4-kdc: Add "Fresh Public Key Identity" SID if PKINIT freshness used
Andrew Bartlett [Mon, 26 Feb 2024 22:23:03 +0000 (11:23 +1300)] 
s4-kdc: Add "Fresh Public Key Identity" SID if PKINIT freshness used

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Feb 28 04:45:48 UTC 2024 on atb-devel-224

2 years agopython/samba/tests/krb5: Expect SID_FRESH_PUBLIC_KEY_IDENTITY (only) when PKINIT...
Andrew Bartlett [Mon, 26 Feb 2024 22:55:33 +0000 (11:55 +1300)] 
python/samba/tests/krb5: Expect SID_FRESH_PUBLIC_KEY_IDENTITY (only) when PKINIT freshness used

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolibcli/security: Add SID_FRESH_PUBLIC_KEY_IDENTITY
Andrew Bartlett [Mon, 26 Feb 2024 22:09:38 +0000 (11:09 +1300)] 
libcli/security: Add SID_FRESH_PUBLIC_KEY_IDENTITY

This allows an ACL level check (rather than only an all-or-nothing KDC configuration)
that PKINIT freshness was used during the AS-REQ.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agothird_party/heimdal: import lorikeet-heimdal-202402270140 (commit e78a9d974c680d77565...
Andrew Bartlett [Tue, 27 Feb 2024 01:55:27 +0000 (14:55 +1300)] 
third_party/heimdal: import lorikeet-heimdal-202402270140 (commit e78a9d974c680d775650fb51f617ca7bf9d6727d)

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agothird_party/heimdal: Import lorikeet-heimdal-202402132018 (commit 66d4c120376f60ce0d0...
Jo Sutton [Tue, 13 Feb 2024 20:37:13 +0000 (09:37 +1300)] 
third_party/heimdal: Import lorikeet-heimdal-202402132018 (commit 66d4c120376f60ce0d02f4c23956df8e4d6007f2)

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Feb 27 02:19:31 UTC 2024 on atb-devel-224

2 years agos4:rpc_server: Make some arrays static
Jo Sutton [Tue, 20 Feb 2024 03:46:07 +0000 (16:46 +1300)] 
s4:rpc_server: Make some arrays static

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:util: Fix printing hex‐escaped characters
Jo Sutton [Tue, 20 Feb 2024 03:35:43 +0000 (16:35 +1300)] 
lib:util: Fix printing hex‐escaped characters

A signed char, passed to snprintf(), will be promoted to an ‘int’, and
then interpreted (according to the format string) as an ‘unsigned int’.
Any negative values passed in will thus be interpreted as large unsigned
values, too large to be represented in the two characters allocated for
them. In practice, they will always be represented as ‘\xFF’.

Cast these characters to ‘unsigned char’, and use the appropriate length
modifier for that type.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:util: Correctly determine whether a character needs to be escaped
Jo Sutton [Tue, 20 Feb 2024 03:30:15 +0000 (16:30 +1300)] 
lib:util: Correctly determine whether a character needs to be escaped

The condition ‘c > 0x1F’ is clearly meant to test whether a character is
a control code or not. While it works for ASCII characters, when ‘char’
is signed it fails for codepoints above 0x7f, which get represented as
negative values. Make this calculation work as it was (presumably)
intended by casting to ‘unsigned char’.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:rpc_server: Remove trailing whitespace
Jo Sutton [Tue, 20 Feb 2024 01:43:33 +0000 (14:43 +1300)] 
s4:rpc_server: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: Fail the test if we don’t receive an NTSTATUSError
Jo Sutton [Mon, 19 Feb 2024 23:27:36 +0000 (12:27 +1300)] 
python: Fail the test if we don’t receive an NTSTATUSError

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests/krb5: Move assertLocalSamDB() into RawKerberosTest
Jo Sutton [Thu, 15 Feb 2024 00:45:10 +0000 (13:45 +1300)] 
tests/krb5: Move assertLocalSamDB() into RawKerberosTest

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests/krb5: type hinting
Jo Sutton [Fri, 8 Dec 2023 01:05:45 +0000 (14:05 +1300)] 
tests/krb5: type hinting

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython/tests: Use TestCaseInTempDir rather than "private dir" for exported keytab
Andrew Bartlett [Wed, 21 Feb 2024 01:29:44 +0000 (14:29 +1300)] 
python/tests: Use TestCaseInTempDir rather than "private dir" for exported keytab

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopython/tests: Convert dckeytab test to use new NDR keytab parser
Andrew Bartlett [Wed, 21 Feb 2024 01:14:24 +0000 (14:14 +1300)] 
python/tests: Convert dckeytab test to use new NDR keytab parser

This is much nicer than reading strings out of the binary file.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopython/tests: Add test for new krb5 keytab parser
Andrew Bartlett [Tue, 20 Feb 2024 21:22:12 +0000 (10:22 +1300)] 
python/tests: Add test for new krb5 keytab parser

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolibrpc/idl: Check protocol version number in Kerberos ccache parser
Andrew Bartlett [Tue, 27 Feb 2024 00:56:50 +0000 (13:56 +1300)] 
librpc/idl: Check protocol version number in Kerberos ccache parser

The ccache file format version is checked by the switch in OPTIONAL_HEADER.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agolibrpc/idl: Add a parser for a FILE: format keytab
Andrew Bartlett [Tue, 20 Feb 2024 07:12:37 +0000 (20:12 +1300)] 
librpc/idl: Add a parser for a FILE: format keytab

This will let us examine keytab entries exported for gMSA accounts and
ensure they are the values we expect.  This will in particular help
test our KDC via the "samba-tool domain exportkeytab" as this is a thin
wrapper around the relevant code.

Additionally, we can use this to test the new client-side keytab generation
in "samba-tool domain exportkeytab" for gMSA accounts.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agopython/samba/samdb: Only do caching of well known DNs in dbcheck
Andrew Bartlett [Fri, 23 Feb 2024 02:32:06 +0000 (15:32 +1300)] 
python/samba/samdb: Only do caching of well known DNs in dbcheck

The fact that get_wellknown_dn() returned a cached DN that could
not be modified safely was unexpected, particularly given that
other similar routines did not do that.

The use case given at the time this was written by
Matthieu Patou in 6122acad0f1a7bc23b6f58862c16968e13da979d
was dbcheck, so move the cache there, and name it clearly.

dbcheck is the only case that uses this rotuine in an inner
loop.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2 years agosource4/torture: Add SEC_STD_DELETE to enable proper cleanup
Anoop C S [Thu, 22 Feb 2024 13:56:08 +0000 (19:26 +0530)] 
source4/torture: Add SEC_STD_DELETE to enable proper cleanup

basic.maximum_allowed and smb2.maximum_allowed attempt to unlink the
files created by those tests. But the restrictive SD with which they
were created prohibits the deletion inside shares where vfs_acl_xattr
is configured including "ignore system acls". The very same file will
otherwise cause problems while progressing with remaining sub tests.
SEC_STD_DELETE could be the minimum required additional access mask
to successfully delete the file under the said configuration using
vfs_acl_xattr and "ignore system acls" option without loosing the
integrity of the overall test.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb 26 18:35:43 UTC 2024 on atb-devel-224

2 years agopython:gp: Implement client site lookup in site_dn_for_machine()
Andreas Schneider [Wed, 21 Feb 2024 08:10:47 +0000 (09:10 +0100)] 
python:gp: Implement client site lookup in site_dn_for_machine()

This is [MS-GPOL] 3.2.5.1.4 Site Search.

The netr_DsRGetSiteName() needs to run over local rpc, however we do not
have the call implemented in our rpc_server. What netr_DsRGetSiteName()
actually does is an ldap query to get the sitename, we can just do the
same.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Feb 26 08:06:08 UTC 2024 on atb-devel-224

2 years agolibrpc:idl: Make netlogon_samlogon_response public
Andreas Schneider [Wed, 21 Feb 2024 07:56:06 +0000 (08:56 +0100)] 
librpc:idl: Make netlogon_samlogon_response public

This is required that we can use it with ndrdump or in python to decode
a NETLOGON_SAM_LOGON_RESPONSE_EX ldap response.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Pair-Programmed-With: Guenther Deschner <gd@samba.org>

Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3: winbindd: assign rangenum member after NULL check
Shaleen Bathla [Wed, 21 Feb 2024 13:25:28 +0000 (18:55 +0530)] 
s3: winbindd: assign rangenum member after NULL check

if we are doing NULL check for range, then we should assign its member
after the NULL check.

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu Feb 22 10:57:38 UTC 2024 on atb-devel-224

2 years agos3: winbindd: reduce scope of a variable
Shaleen Bathla [Wed, 21 Feb 2024 13:08:45 +0000 (18:38 +0530)] 
s3: winbindd: reduce scope of a variable

reduce scope of variable as a best practice

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2 years agos3: winbindd: remove double initialization
Shaleen Bathla [Wed, 21 Feb 2024 12:56:11 +0000 (18:26 +0530)] 
s3: winbindd: remove double initialization

remove re-initialization of entry variable in for loop

Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2 years agoctdb-protocol: Add missing push support for new controls
Martin Schwenke [Fri, 9 Feb 2024 06:29:46 +0000 (17:29 +1100)] 
ctdb-protocol: Add missing push support for new controls

CTDB_CONTROL_TCP_CLIENT_DISCONNECTED and
CTDB_CONTROL_TCP_CLIENT_PASSED were added in commits
c6602b686b4e50d93272667ef86d3904181fb1ab and
037e8e449deb136ad5ed5e4de05439411b545b6d.  They were missing test
support for the packet push/pull.  While adding the testing (for
completeness, before adding another new control) I noticed that the
push functionality was absent.  This adds that, along with the test
support.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb 19 10:21:48 UTC 2024 on atb-devel-224

2 years agos3/rpc_client: Fix array offset check
Noel Power [Thu, 8 Feb 2024 14:05:43 +0000 (14:05 +0000)] 
s3/rpc_client: Fix array offset check

Previous to this commit we were modifying the offset before
the array offset check. This was causing a spurious debug
message indicating the offset was out of bounds. An second
problem is that upon detecting the error we don't exit the loop.
A third problem was that when reading the offset the check
didn't cater for the size of the integer address about to be read.

This commit moves the offset check to before the first read,
additionally when an error is detected now we actually exit the loop
and the offset have been corrected to include the size of the
integer to be read

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15579
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Feb 17 17:58:43 UTC 2024 on atb-devel-224

2 years agos3/rpc_client: Ensure max possible row buffer size is not exceeded
Noel Power [Wed, 14 Feb 2024 11:19:39 +0000 (11:19 +0000)] 
s3/rpc_client: Ensure max possible row buffer size is not exceeded

The max buf size of rows buffer should not exceed 0x00004000.
Ensuring this value is within limits means we can safely use
uint32_t offsets.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15579
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agoidl: Add constant for max rows buffer size
Noel Power [Wed, 14 Feb 2024 12:01:28 +0000 (12:01 +0000)] 
idl: Add constant for max rows buffer size

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15579
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos4:dsdb: Fix grammar
Jo Sutton [Tue, 13 Feb 2024 03:53:57 +0000 (16:53 +1300)] 
s4:dsdb: Fix grammar

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Feb 16 03:47:12 UTC 2024 on atb-devel-224

2 years agolibcli/security: Make ‘session_info’ parameter const
Jo Sutton [Tue, 13 Feb 2024 19:17:03 +0000 (08:17 +1300)] 
libcli/security: Make ‘session_info’ parameter const

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:ldap_server: Remove trailing whitespace
Jo Sutton [Mon, 12 Feb 2024 03:48:36 +0000 (16:48 +1300)] 
s4:ldap_server: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: Include missing headers
Jo Sutton [Thu, 18 Jan 2024 01:28:04 +0000 (14:28 +1300)] 
libcli/security: Include missing headers

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Let requests with the AS_SYSTEM control reset an account’s password
Jo Sutton [Tue, 13 Feb 2024 01:13:46 +0000 (14:13 +1300)] 
s4:dsdb: Let requests with the AS_SYSTEM control reset an account’s password

dsdb_have_system_access() takes into account the AS_SYSTEM control as
well as the result of dsdb_module_am_system().

This change means that we can reset the password of an account without
being SYSTEM by means of the AS_SYSTEM control. This is essential for
ldapsrv_SearchRequest() to be able to process the automatic password
changes of Group Managed Service Accounts.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Make use of dsdb_have_system_access()
Jo Sutton [Tue, 13 Feb 2024 01:12:30 +0000 (14:12 +1300)] 
s4:dsdb: Make use of dsdb_have_system_access()

There should not be any change in behaviour.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add function to determine whether we have system access
Jo Sutton [Tue, 13 Feb 2024 01:09:23 +0000 (14:09 +1300)] 
s4:dsdb: Add function to determine whether we have system access

This takes into account the dsdb session info, as well as the presence
or absence of an AS_SYSTEM control.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add include guard to dsdb/samdb/ldb_modules/util.h
Jo Sutton [Thu, 15 Feb 2024 03:48:29 +0000 (16:48 +1300)] 
s4:dsdb: Add include guard to dsdb/samdb/ldb_modules/util.h

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove redundant include
Jo Sutton [Thu, 15 Feb 2024 03:48:06 +0000 (16:48 +1300)] 
s4:dsdb: Remove redundant include

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add function to create a GMSA password update request
Jo Sutton [Tue, 13 Feb 2024 01:06:38 +0000 (14:06 +1300)] 
s4:dsdb: Add function to create a GMSA password update request

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove unused includes
Jo Sutton [Tue, 13 Feb 2024 00:50:40 +0000 (13:50 +1300)] 
s4:dsdb: Remove unused includes

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add to ‘user_attrs’ attributes required for Group Managed Service Accounts
Jo Sutton [Tue, 13 Feb 2024 00:45:10 +0000 (13:45 +1300)] 
s4:dsdb: Add to ‘user_attrs’ attributes required for Group Managed Service Accounts

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:passdb: Reformat long line
Jo Sutton [Tue, 13 Feb 2024 00:43:59 +0000 (13:43 +1300)] 
s3:passdb: Reformat long line

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:passdb: Reformat array of strings
Jo Sutton [Tue, 13 Feb 2024 00:40:48 +0000 (13:40 +1300)] 
s3:passdb: Reformat array of strings

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:passdb: Make array of strings static
Jo Sutton [Tue, 13 Feb 2024 00:40:29 +0000 (13:40 +1300)] 
s3:passdb: Make array of strings static

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:passdb: Remove trailing whitespace
Jo Sutton [Tue, 13 Feb 2024 00:40:20 +0000 (13:40 +1300)] 
s3:passdb: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopidl: Do not call mapTypeName() on expression
Jo Sutton [Tue, 13 Feb 2024 00:17:28 +0000 (13:17 +1300)] 
pidl: Do not call mapTypeName() on expression

$var_name is not a type name, but an expression, such as ‘r->in.server’.
mapTypeName() will turn this into ‘struct r->in.server’, which makes no
sense.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Add test for GMSA password derivation
Jo Sutton [Tue, 13 Feb 2024 01:39:41 +0000 (14:39 +1300)] 
lib:crypto: Add test for GMSA password derivation

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Add functions for deriving gMSA passwords
Jo Sutton [Tue, 13 Feb 2024 00:04:06 +0000 (13:04 +1300)] 
lib:crypto: Add functions for deriving gMSA passwords

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Add more GKDI functions
Jo Sutton [Tue, 13 Feb 2024 00:04:48 +0000 (13:04 +1300)] 
lib:crypto: Add more GKDI functions

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Fix documentation typos
Jo Sutton [Mon, 12 Feb 2024 23:34:43 +0000 (12:34 +1300)] 
ldb: Fix documentation typos

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Split out ldb_controls_get_control() to search a list of controls
Jo Sutton [Mon, 12 Feb 2024 22:57:07 +0000 (11:57 +1300)] 
ldb: Split out ldb_controls_get_control() to search a list of controls

Update the ldb ABI accordingly.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Correct copy‐and‐pasted comments
Jo Sutton [Mon, 12 Feb 2024 22:54:57 +0000 (11:54 +1300)] 
ldb: Correct copy‐and‐pasted comments

These comments refer to controls being added, but in these functions the
controls are actually being *searched* for.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Remove trailing whitespace
Jo Sutton [Mon, 12 Feb 2024 22:53:07 +0000 (11:53 +1300)] 
ldb: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add dsdb_werror() macro
Jo Sutton [Mon, 12 Feb 2024 22:52:06 +0000 (11:52 +1300)] 
s4:dsdb: Add dsdb_werror() macro

This works like dsdb_module_werror(), but does not require an ldb module
to work.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add search flag indicating that gMSA passwords are to be updated
Jo Sutton [Mon, 12 Feb 2024 22:51:35 +0000 (11:51 +1300)] 
s4:dsdb: Add search flag indicating that gMSA passwords are to be updated

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Include missing headers
Jo Sutton [Mon, 12 Feb 2024 22:51:19 +0000 (11:51 +1300)] 
s4:dsdb: Include missing headers

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add dsdb control indicating that gMSA passwords are to be updated
Jo Sutton [Mon, 12 Feb 2024 22:25:33 +0000 (11:25 +1300)] 
s4:dsdb: Add dsdb control indicating that gMSA passwords are to be updated

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:setup: Remove empty line
Jo Sutton [Mon, 12 Feb 2024 22:26:08 +0000 (11:26 +1300)] 
s4:setup: Remove empty line

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Fix code formatting
Jo Sutton [Mon, 12 Feb 2024 03:58:41 +0000 (16:58 +1300)] 
s4:dsdb: Fix code formatting

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add ‘ares’ parameter to operational attribute constructor functions
Jo Sutton [Mon, 12 Feb 2024 03:56:59 +0000 (16:56 +1300)] 
s4:dsdb: Add ‘ares’ parameter to operational attribute constructor functions

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Make array static
Jo Sutton [Mon, 12 Feb 2024 03:50:39 +0000 (16:50 +1300)] 
s4:dsdb: Make array static

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove trailing whitespace
Jo Sutton [Mon, 12 Feb 2024 03:49:44 +0000 (16:49 +1300)] 
s4:dsdb: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove duplicate word
Jo Sutton [Tue, 16 Jan 2024 02:48:43 +0000 (15:48 +1300)] 
s4:dsdb: Remove duplicate word

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agomailmap: Associate my identity with my old email address
Jo Sutton [Mon, 12 Feb 2024 23:32:19 +0000 (12:32 +1300)] 
mailmap: Associate my identity with my old email address

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove unused ‘domain_dn’ parameter
Jo Sutton [Fri, 19 Jan 2024 23:01:30 +0000 (12:01 +1300)] 
s4:dsdb: Remove unused ‘domain_dn’ parameter

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Remove reference to now‐gone lmNewHash parameter
Jo Sutton [Thu, 15 Feb 2024 01:12:07 +0000 (14:12 +1300)] 
s4:dsdb: Remove reference to now‐gone lmNewHash parameter

This parameter was removed in commit
75c54d54ad9fdff7098c1b4f11252528f35ea658.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Split out function to create a ‘password set’ ldb request
Jo Sutton [Fri, 19 Jan 2024 23:00:27 +0000 (12:00 +1300)] 
s4:dsdb: Split out function to create a ‘password set’ ldb request

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Allocate NT hash on to more appropriate memory context
Jo Sutton [Mon, 12 Feb 2024 03:25:10 +0000 (16:25 +1300)] 
s4:dsdb: Allocate NT hash on to more appropriate memory context

The NT hash should live at least as long as the message to which it is
added.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Undefine helper macro
Jo Sutton [Fri, 19 Jan 2024 22:58:45 +0000 (11:58 +1300)] 
s4:dsdb: Undefine helper macro

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Check return value of talloc_new()
Jo Sutton [Fri, 19 Jan 2024 00:33:09 +0000 (13:33 +1300)] 
s4:dsdb: Check return value of talloc_new()

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Remove unused imports
Jo Sutton [Wed, 17 Jan 2024 21:01:49 +0000 (10:01 +1300)] 
python:tests: Remove unused imports

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Remove ‘attrs’ parameter from samba_kdc_lookup_server()
Jo Sutton [Wed, 17 Jan 2024 00:13:56 +0000 (13:13 +1300)] 
s4:kdc: Remove ‘attrs’ parameter from samba_kdc_lookup_server()

It is always equal to ‘server_attrs’.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:compression: Update my name
Jo Sutton [Wed, 7 Feb 2024 21:55:32 +0000 (10:55 +1300)] 
lib:compression: Update my name

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: Reformat nt_time.py
Jo Sutton [Fri, 2 Feb 2024 00:11:22 +0000 (13:11 +1300)] 
python: Reformat nt_time.py

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Fix code spelling
Jo Sutton [Wed, 24 Jan 2024 21:28:31 +0000 (10:28 +1300)] 
ldb: Fix code spelling

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Simplify ldb_errstring()
Jo Sutton [Wed, 24 Jan 2024 01:19:26 +0000 (14:19 +1300)] 
ldb: Simplify ldb_errstring()

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Remove trailing whitespace
Jo Sutton [Wed, 24 Jan 2024 01:19:11 +0000 (14:19 +1300)] 
ldb: Remove trailing whitespace

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:util: Remove inaccurate comment
Jo Sutton [Fri, 19 Jan 2024 20:53:20 +0000 (09:53 +1300)] 
lib:util: Remove inaccurate comment

A C compiler would not be allowed to apply the tail call optimization in
this situation, because it would change the observed behaviour of the
program.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:libads: Remove ‘unicodePwd’ attribute from ads_find_machine_acct() search
Jo Sutton [Thu, 18 Jan 2024 23:38:24 +0000 (12:38 +1300)] 
s3:libads: Remove ‘unicodePwd’ attribute from ads_find_machine_acct() search

This attribute was added to the search in commit
4f389c1f78cdc2424795e3b2a1ce43818c400c2d. But it’s not clear to me that
anything actually retrieves the unicodePwd from the result (excluding
inconsequential things like ads_dump()).

Furthermore, this being a search over LDAP, it will never return a
unicodePwd.

Removing this attribute from the search means that we no longer have to
worry about the account possibly being a Group Managed Service Account
and the unicodePwd being out‐of‐date.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotestprogs:blackbox: Fix code spelling
Jo Sutton [Fri, 19 Jan 2024 00:23:36 +0000 (13:23 +1300)] 
testprogs:blackbox: Fix code spelling

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosamba-tool: Display friendlier error message if no password is available
Jo Sutton [Wed, 17 Jan 2024 22:26:34 +0000 (11:26 +1300)] 
samba-tool: Display friendlier error message if no password is available

‘samba-tool user get-kerberos-ticket’ is supposed to display an error
message if no password is available. However, the conditions for which
the message is displayed are impossible to be met. If ‘utf16_pw’ is not
None, the message is not displayed; if ‘utf16_pw’ *is* None, ‘nt_pass’
is assigned with a samr.Password object, which is not None — and so the
message is still not displayed.

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Pass correct arguments to set_named_ccache()
Jo Sutton [Wed, 17 Jan 2024 21:55:55 +0000 (10:55 +1300)] 
python:tests: Pass correct arguments to set_named_ccache()

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Fix code spelling
Jo Sutton [Wed, 17 Jan 2024 21:48:44 +0000 (10:48 +1300)] 
python:tests: Fix code spelling

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Add helper functions to get GKDI root key DNs
Jo Sutton [Thu, 11 Jan 2024 00:52:27 +0000 (13:52 +1300)] 
s4:dsdb: Add helper functions to get GKDI root key DNs

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Explicitly check for zero
Jo Sutton [Sun, 7 Jan 2024 20:48:44 +0000 (09:48 +1300)] 
lib:crypto: Explicitly check for zero

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Comment on GKDI definitions
Jo Sutton [Tue, 9 Jan 2024 01:14:23 +0000 (14:14 +1300)] 
lib:crypto: Comment on GKDI definitions

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Export gkid_key_type() and gkid_is_valid()
Jo Sutton [Tue, 9 Jan 2024 01:13:31 +0000 (14:13 +1300)] 
lib:crypto: Export gkid_key_type() and gkid_is_valid()

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:crypto: Fix code formatting
Jo Sutton [Fri, 22 Dec 2023 03:01:36 +0000 (16:01 +1300)] 
lib:crypto: Fix code formatting

Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>