samba.git
8 months agos4:auth: Fix ‘user_info_dc_out’ leak
Joseph Sutton [Thu, 21 Sep 2023 02:21:55 +0000 (14:21 +1200)]
s4:auth: Fix ‘user_info_dc_out’ leak

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:auth: Return a talloc‐allocated resource groups structure
Joseph Sutton [Thu, 21 Sep 2023 02:20:29 +0000 (14:20 +1200)]
s4:auth: Return a talloc‐allocated resource groups structure

Future callers will rely on resource_groups_out being talloc‐allocated.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:auth: Introduce helper variable ‘resource_groups_in’
Joseph Sutton [Thu, 21 Sep 2023 02:15:06 +0000 (14:15 +1200)]
s4:auth: Introduce helper variable ‘resource_groups_in’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:auth: Make returning resource groups the last thing we do
Joseph Sutton [Thu, 21 Sep 2023 02:13:36 +0000 (14:13 +1200)]
s4:auth: Make returning resource groups the last thing we do

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:torture: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:34:42 +0000 (17:34 +1200)]
s4:torture: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:kdc: Fix ldb_msg_find_krb5time_ldap_time()
Joseph Sutton [Wed, 20 Sep 2023 19:32:30 +0000 (07:32 +1200)]
s4:kdc: Fix ldb_msg_find_krb5time_ldap_time()

strptime() will fail to parse the LDAP ‘whenCreated’ time string,
because the format string is wrong: it will expect to get a time like
“20230920043849Z”, but the time string seems to be actually formatted
20230920043849.0Z” — like a GeneralizedTime.

Fix this by delegating to ldb_val_to_time().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:kdc: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 19:40:41 +0000 (07:40 +1200)]
s4:kdc: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos3:smbd: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:05:43 +0000 (17:05 +1200)]
s3:smbd: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos3:rpc_server: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:05:34 +0000 (17:05 +1200)]
s3:rpc_server: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos3:passdb: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:05:21 +0000 (17:05 +1200)]
s3:passdb: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos3:modules: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:05:09 +0000 (17:05 +1200)]
s3:modules: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos3:lib: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:04:58 +0000 (17:04 +1200)]
s3:lib: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib:audit_logging: Initialize ‘tm’ structure
Joseph Sutton [Wed, 20 Sep 2023 05:04:00 +0000 (17:04 +1200)]
lib:audit_logging: Initialize ‘tm’ structure

‘tm’ must be initialized prior to calling strptime().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/krb5_wrap: Simplify assignments
Joseph Sutton [Wed, 20 Sep 2023 04:20:47 +0000 (16:20 +1200)]
lib/krb5_wrap: Simplify assignments

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/krb5_wrap: Make use of smb_krb5_make_data()
Joseph Sutton [Wed, 20 Sep 2023 04:02:04 +0000 (16:02 +1200)]
lib/krb5_wrap: Make use of smb_krb5_make_data()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Test hex‐escapes that should be literals
Joseph Sutton [Wed, 20 Sep 2023 03:01:26 +0000 (15:01 +1200)]
libcli/security: Test hex‐escapes that should be literals

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Fix code formatting
Joseph Sutton [Wed, 20 Sep 2023 03:00:38 +0000 (15:00 +1200)]
libcli/security: Fix code formatting

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Use ACL revision constants
Joseph Sutton [Wed, 20 Sep 2023 03:00:10 +0000 (15:00 +1200)]
libcli/security: Use ACL revision constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Refer to UTF‐16 code units rather than to codepoints
Joseph Sutton [Wed, 20 Sep 2023 02:55:34 +0000 (14:55 +1200)]
libcli/security: Refer to UTF‐16 code units rather than to codepoints

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove unused flag SDDL_FLAG_IS_FAKE_OP
Joseph Sutton [Wed, 20 Sep 2023 02:42:26 +0000 (14:42 +1200)]
libcli/security: Remove unused flag SDDL_FLAG_IS_FAKE_OP

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove unused flag SDDL_FLAG_IS_LITERAL
Joseph Sutton [Wed, 20 Sep 2023 02:41:46 +0000 (14:41 +1200)]
libcli/security: Remove unused flag SDDL_FLAG_IS_LITERAL

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove unused flag SDDL_FLAG_IS_ATTR
Joseph Sutton [Wed, 20 Sep 2023 02:41:17 +0000 (14:41 +1200)]
libcli/security: Remove unused flag SDDL_FLAG_IS_ATTR

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove unused flag SDDL_FLAG_EXPECTING_END
Joseph Sutton [Wed, 20 Sep 2023 02:40:30 +0000 (14:40 +1200)]
libcli/security: Remove unused flag SDDL_FLAG_EXPECTING_END

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove unused macro
Joseph Sutton [Tue, 19 Sep 2023 02:28:13 +0000 (14:28 +1200)]
libcli/security: Remove unused macro

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopython:tests: Remove unused import
Joseph Sutton [Mon, 18 Sep 2023 22:14:29 +0000 (10:14 +1200)]
python:tests: Remove unused import

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:auth: Correct error message
Joseph Sutton [Mon, 11 Sep 2023 03:52:16 +0000 (15:52 +1200)]
s4:auth: Correct error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:torture: Use SID constants
Joseph Sutton [Mon, 11 Sep 2023 03:28:44 +0000 (15:28 +1200)]
s4:torture: Use SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:rpc_server: Use Builtin SID constant
Joseph Sutton [Mon, 11 Sep 2023 03:28:22 +0000 (15:28 +1200)]
s4:rpc_server: Use Builtin SID constant

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:ntvfs: Use World and System SID constants
Joseph Sutton [Mon, 11 Sep 2023 03:28:00 +0000 (15:28 +1200)]
s4:ntvfs: Use World and System SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:dsdb: Use Builtin SID constant
Joseph Sutton [Mon, 11 Sep 2023 03:27:09 +0000 (15:27 +1200)]
s4:dsdb: Use Builtin SID constant

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:auth: Use Anonymous and System SID constants
Joseph Sutton [Mon, 11 Sep 2023 03:26:41 +0000 (15:26 +1200)]
s4:auth: Use Anonymous and System SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:kdc: Use Compounded Authentication and Claims Valid SID constants
Joseph Sutton [Mon, 11 Sep 2023 02:27:38 +0000 (14:27 +1200)]
s4:kdc: Use Compounded Authentication and Claims Valid SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli:security: Add Compounded Authentication and Claims Valid SID constants
Joseph Sutton [Mon, 11 Sep 2023 02:27:14 +0000 (14:27 +1200)]
libcli:security: Add Compounded Authentication and Claims Valid SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:kdc: Use Asserted Identity SID constants
Joseph Sutton [Mon, 11 Sep 2023 02:15:05 +0000 (14:15 +1200)]
s4:kdc: Use Asserted Identity SID constants

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agos4:dsdb: Use NULL SID constant
Joseph Sutton [Mon, 11 Sep 2023 02:14:38 +0000 (14:14 +1200)]
s4:dsdb: Use NULL SID constant

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli:security: Correct Asserted Identity SID definitions
Joseph Sutton [Mon, 18 Sep 2023 02:56:12 +0000 (14:56 +1200)]
libcli:security: Correct Asserted Identity SID definitions

These definitions were the wrong way round.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli:security: Use SELF SID constant
Joseph Sutton [Mon, 11 Sep 2023 02:13:47 +0000 (14:13 +1200)]
libcli:security: Use SELF SID constant

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli:security: Add SELF SID constant
Joseph Sutton [Mon, 11 Sep 2023 02:13:09 +0000 (14:13 +1200)]
libcli:security: Add SELF SID constant

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopython:tests: Fix invalid escape sequences
Joseph Sutton [Sun, 10 Sep 2023 23:59:34 +0000 (11:59 +1200)]
python:tests: Fix invalid escape sequences

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agotests/krb5: Match filter after transforming test name
Joseph Sutton [Thu, 17 Aug 2023 23:48:03 +0000 (11:48 +1200)]
tests/krb5: Match filter after transforming test name

If you just want to rerun a single test that failed, this removes the
need to successfully guess its untransformed name.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Emit error message if program is too large
Joseph Sutton [Wed, 2 Aug 2023 02:15:09 +0000 (14:15 +1200)]
libcli/security: Emit error message if program is too large

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Add function to convert token claims to security attribute claims
Joseph Sutton [Thu, 21 Sep 2023 03:16:20 +0000 (15:16 +1200)]
libcli/security: Add function to convert token claims to security attribute claims

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Add some missing declarations
Joseph Sutton [Thu, 20 Jul 2023 03:46:33 +0000 (15:46 +1200)]
libcli/security: Add some missing declarations

so that users of this header file don’t have to declare them.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Const‐qualify function parameters
Joseph Sutton [Thu, 20 Jul 2023 03:44:49 +0000 (15:44 +1200)]
libcli/security: Const‐qualify function parameters

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Remove bool_value member
Joseph Sutton [Thu, 21 Sep 2023 03:44:04 +0000 (15:44 +1200)]
libcli/security: Remove bool_value member

‘bool_value’ has the same type as ‘uint_value’. Removing the former
avoids our having more duplicate code than is strictly necessary.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Use correct union member
Joseph Sutton [Thu, 21 Sep 2023 03:46:55 +0000 (15:46 +1200)]
libcli/security: Use correct union member

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Add header guard
Joseph Sutton [Thu, 20 Jul 2023 03:45:35 +0000 (15:45 +1200)]
libcli/security: Add header guard

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: condtional ACE recursive composites are not supported
Douglas Bagnall [Fri, 22 Sep 2023 04:29:51 +0000 (16:29 +1200)]
libcli/security: condtional ACE recursive composites are not supported

We can't add them via SDDL on Windows, and they aren't useful for
claims.

Signed-off-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): Wed Sep 27 00:41:26 UTC 2023 on atb-devel-224

8 months agolibcli/security: conditional ace sddl: do not read nested composites
Douglas Bagnall [Fri, 22 Sep 2023 04:31:36 +0000 (16:31 +1200)]
libcli/security: conditional ace sddl: do not read nested composites

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: conditional ace sddl: do not write nested composites
Douglas Bagnall [Fri, 22 Sep 2023 04:30:41 +0000 (16:30 +1200)]
libcli/security: conditional ace sddl: do not write nested composites

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agofuzzing: fuzz_sddl_parse forgives bad utf-8
Douglas Bagnall [Fri, 22 Sep 2023 03:19:32 +0000 (15:19 +1200)]
fuzzing: fuzz_sddl_parse forgives bad utf-8

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agoutil/str: helper to check for utf-8 validity
Douglas Bagnall [Thu, 6 Jul 2023 03:31:52 +0000 (15:31 +1200)]
util/str: helper to check for utf-8 validity

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: conditional ACE sddl doesn't have string escapes
Douglas Bagnall [Fri, 22 Sep 2023 02:16:35 +0000 (14:16 +1200)]
libcli/security: conditional ACE sddl doesn't have string escapes

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcl/security: conditional ACE sddl >= ops take literal parens only
Douglas Bagnall [Fri, 22 Sep 2023 00:02:56 +0000 (12:02 +1200)]
libcl/security: conditional ACE sddl >= ops take literal parens only

You can't do things like '(a == b) == (c < d)'.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security/sddl_conditional_ace: ban empty expressions in SDDL
Douglas Bagnall [Fri, 22 Sep 2023 00:53:42 +0000 (12:53 +1200)]
libcli/security/sddl_conditional_ace: ban empty expressions in SDDL

The trouble is with expressions like "(!(()))", which boil down to a
single NOT operation with no argument, which is invalid and can't be
run or expressed as SDDL.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/fuzzing: fuzz_sddl_parse: allow non-round-trip with long strings
Douglas Bagnall [Thu, 21 Sep 2023 03:03:23 +0000 (15:03 +1200)]
lib/fuzzing: fuzz_sddl_parse: allow non-round-trip with long strings

There is a borderline case where a conditional ACE unicode string
becomes longer than the SDDL parser wants to handle when control
characters are given canonical escaping. This can make the round trip
fail, but it isn't really a problem.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agoadd comment that ace_condition_composite is not representative of the wire format
Andrew Bartlett [Thu, 21 Sep 2023 04:08:52 +0000 (16:08 +1200)]
add comment that ace_condition_composite is not representative of the wire format

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agoconditional_aces: Avoid manual parsing for ace_condition_unicode
Andrew Bartlett [Thu, 21 Sep 2023 00:26:15 +0000 (12:26 +1200)]
conditional_aces: Avoid manual parsing for ace_condition_unicode

A consequence of this is that we remove the confusing "length"
from the IDL, as it was the internal UTF8 length, not a wire
value.  We use null terminated strings internally now.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibndr: Add support for pulling strings with LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NO...
Andrew Bartlett [Thu, 21 Sep 2023 02:55:10 +0000 (14:55 +1200)]
libndr: Add support for pulling strings with LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agoconditional_aces: Avoid manual parsing for ace_condition_int
Andrew Bartlett [Thu, 21 Sep 2023 00:03:27 +0000 (12:03 +1200)]
conditional_aces: Avoid manual parsing for ace_condition_int

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: Check for sddl_from_conditional_ace() failure in test_sddl_condition...
Andrew Bartlett [Wed, 20 Sep 2023 23:56:58 +0000 (11:56 +1200)]
libcli/security: Check for sddl_from_conditional_ace() failure in test_sddl_conditional_ace

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: Make failure parsing where consumed == -1 clear
Andrew Bartlett [Wed, 20 Sep 2023 23:56:25 +0000 (11:56 +1200)]
libcli/security: Make failure parsing where consumed == -1 clear

This was caught by the next condition, but this is clearer.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agoMake blob->data pointer in ace_sid_to_claim_v1_sid() a child of the DATA_BLOB
Andrew Bartlett [Tue, 19 Sep 2023 21:36:43 +0000 (09:36 +1200)]
Make blob->data pointer in ace_sid_to_claim_v1_sid() a child of the DATA_BLOB

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agoconditional_aces: Avoid manual parsing for ace_condition_bytes, use DATA_BLOB
Andrew Bartlett [Thu, 21 Sep 2023 00:55:53 +0000 (12:55 +1200)]
conditional_aces: Avoid manual parsing for ace_condition_bytes, use DATA_BLOB

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agoconditional_aces: Avoid manual parsing for ace_condition_sid
Andrew Bartlett [Tue, 19 Sep 2023 21:31:31 +0000 (09:31 +1200)]
conditional_aces: Avoid manual parsing for ace_condition_sid

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: access_check handles CALLBACK_OBJECT types
Douglas Bagnall [Mon, 25 Sep 2023 01:36:59 +0000 (14:36 +1300)]
libcli/security: access_check handles CALLBACK_OBJECT types

These are like an object type if the callback (i.e. condtional ACE
conditions) succeeds, otherwise they are ignored.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: se_access_check uses new callback checks
Douglas Bagnall [Wed, 20 Sep 2023 05:35:18 +0000 (17:35 +1200)]
libcli/security: se_access_check uses new callback checks

With the last caller of check_callback_ace_access() gone, so is that
function.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: sec_access_check_ds uses new callback ACE checks
Douglas Bagnall [Wed, 13 Sep 2023 05:24:57 +0000 (17:24 +1200)]
libcli/security: sec_access_check_ds uses new callback ACE checks

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: access_check with MAXIMUM_ALLOWED checks callbacks
Douglas Bagnall [Wed, 13 Sep 2023 05:25:52 +0000 (17:25 +1200)]
libcli/security: access_check with MAXIMUM_ALLOWED checks callbacks

To help clarify the logic, we make new functions that separate the
deny and allow cases, which helps keep track of what 'yes' and 'no'
mean and which incorporate the logic of token->evaluate_claims
handling, which determines when we want to run a conditional ACE, when
we want to ignore it, and when we want to take offence. In the case
when we decide to run it, we then need to decide whether to apply it
or ignore it based on the result. This last bit differs between allow
and deny aces, hence the two functions.

These functions will replace check_callback_ace_access() over the next
few commits.

In the case where token->evaluate_claims is
CLAIMS_EVALUATION_INVALID_STATE and the DACL contains a conditional
ACE, the maximum allowed is 0, as if it was a "deny everything" ACE.

This is an unexpected case. Most likely the evaluate_claims state
will be NEVER or ALWAYS. In the NEVER case the conditional ACE is
skipped, as would have happened in all cases before 4.20, while in the
ALWAYS case the conditional ACE is run and applied if successful.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: adjust tests for evaluate_claims flag
Douglas Bagnall [Tue, 19 Sep 2023 22:30:23 +0000 (10:30 +1200)]
libcli/security: adjust tests for evaluate_claims flag

Most tests were prepared in advance, but we left these ones to test
the change.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: Hook in ability to disable conditional ACE evaluation
Andrew Bartlett [Fri, 15 Sep 2023 00:36:56 +0000 (12:36 +1200)]
libcli/security: Hook in ability to disable conditional ACE evaluation

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos3-lib: Modify merge_nt_token() into a GPO-specifc merge with SYSTEM
Andrew Bartlett [Fri, 15 Sep 2023 00:08:20 +0000 (12:08 +1200)]
s3-lib: Modify merge_nt_token() into a GPO-specifc merge with SYSTEM

By making this specific to the only use case, merging with the SYSTEM
token for GPOs, we avoid having to merge the claims, as there are none
for SYSTEM.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agopython: Change the generic merge_nt_token() to being specific to the system_token
Andrew Bartlett [Fri, 15 Sep 2023 00:07:25 +0000 (12:07 +1200)]
python: Change the generic merge_nt_token() to being specific to the system_token

This allows us to punt on the question of merging the claims, as there are
none on the system token.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibgpo: Reimplmeent registry_create_system_token() using get_system_token()
Andrew Bartlett [Thu, 14 Sep 2023 22:52:51 +0000 (10:52 +1200)]
libgpo: Reimplmeent registry_create_system_token() using get_system_token()

This helps ensure we have a smaller number of places that
a struct security_token starts from.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: Rename dup_nt_token() -> security_token_duplicate()
Andrew Bartlett [Thu, 14 Sep 2023 22:08:01 +0000 (10:08 +1200)]
libcli/security: Rename dup_nt_token() -> security_token_duplicate()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: Move dup_nt_token() to libcli/security
Andrew Bartlett [Fri, 15 Sep 2023 05:31:44 +0000 (17:31 +1200)]
libcli/security: Move dup_nt_token() to libcli/security

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos3-winbind: Use token as parent for token->sids in check_info3_in_group()
Andrew Bartlett [Tue, 26 Sep 2023 20:42:55 +0000 (09:42 +1300)]
s3-winbind: Use token as parent for token->sids in check_info3_in_group()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos3-net_rpc: Make the struct user_token array the parent talloc context
Andrew Bartlett [Tue, 26 Sep 2023 20:35:19 +0000 (09:35 +1300)]
s3-net_rpc: Make the struct user_token array the parent talloc context

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos3-net_rpc: Use security_token_initialise() to create struct security_token
Andrew Bartlett [Tue, 26 Sep 2023 19:39:04 +0000 (08:39 +1300)]
s3-net_rpc: Use security_token_initialise() to create struct security_token

This ensures that the full structure is initialised now and in the
future.

Because this is now a talloc based structure, we can now use
add_sid_to_array_unique() rather than a reimplementation in this file.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibcli/security: Pass in claims evaluation state when building any security token
Andrew Bartlett [Thu, 14 Sep 2023 10:09:50 +0000 (22:09 +1200)]
libcli/security: Pass in claims evaluation state when building any security token

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos4-auth: pass lp_ctx to auth_generate_session_info() where possible
Andrew Bartlett [Thu, 14 Sep 2023 22:28:34 +0000 (10:28 +1200)]
s4-auth: pass lp_ctx to auth_generate_session_info() where possible

For non-testing callers of auth_generate_session_info(), passing
lp_ctx will allow us to correctly set a flag indicating if claims
should be evaluated.

For testing applications, the default will allow safe operation
inspecting the SID list.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agodocs-xml: Add new parameter "acl claims evaluation"
Andrew Bartlett [Thu, 14 Sep 2023 09:20:39 +0000 (21:20 +1200)]
docs-xml: Add new parameter "acl claims evaluation"

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibrpc: Add context as to if this token should be used for claims evaluation
Andrew Bartlett [Thu, 14 Sep 2023 09:04:34 +0000 (21:04 +1200)]
librpc: Add context as to if this token should be used for claims evaluation

Claims evaluation is added to the core se_access_check() library, but
not all callers provide claims in the security_token and we want to
be able to disable this new and complex code if needed.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agos3-lib/util_nttoken: Reimplement dup_nt_token() with NDR pull/push
Andrew Bartlett [Thu, 14 Sep 2023 06:24:36 +0000 (18:24 +1200)]
s3-lib/util_nttoken: Reimplement dup_nt_token() with NDR pull/push

The struct security_token can now contain complex claims as well as SIDs
so we can no longer just duplicate it by hand.  Instead let PIDL and libndr
do the hard work for us.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
8 months agolibrpc/ndr_claims: avoid 'bin/default' in #include
Douglas Bagnall [Tue, 12 Sep 2023 23:31:55 +0000 (11:31 +1200)]
librpc/ndr_claims: avoid 'bin/default' in #include

Obviously it works fine, but we don't do it anywhere else.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest: conditional_ace assembler assembles full descriptor
Douglas Bagnall [Fri, 15 Sep 2023 03:24:20 +0000 (15:24 +1200)]
pytest: conditional_ace assembler assembles full descriptor

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: beginning of tests for conditional ACE bytes
Douglas Bagnall [Wed, 13 Sep 2023 03:12:52 +0000 (15:12 +1200)]
libcli/security: beginning of tests for conditional ACE bytes

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest: assembler for conditional ACEs
Douglas Bagnall [Sun, 3 Sep 2023 22:11:51 +0000 (10:11 +1200)]
pytest: assembler for conditional ACEs

This is a helper module to construct conditional ACEs that can't be
created from SDDL.

There is a semi-infinite number of valid conditional ACEs that don't
have SDDL representations, and an even larger number of invalid (or
borderline invalid) ACEs.

This allows us to create those ACEs without having to deal with too
many array of numbers.

The next commit provides an example of its use.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/fuzzing: adjust access-check seed patch
Douglas Bagnall [Thu, 20 Jul 2023 22:51:29 +0000 (10:51 +1200)]
lib/fuzzing: adjust access-check seed patch

Now that access_check.c includes headers for conditional ACEs, the patch
should take that into account.

Also, we check for a talloc failure.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/fuzzing: fuzz_conditional_ace_blob
Douglas Bagnall [Thu, 29 Jun 2023 03:15:08 +0000 (15:15 +1200)]
lib/fuzzing: fuzz_conditional_ace_blob

This parses the blob as a conditional ACE, and if possible tries
decompiling it into SDDL.

There are not many round-trip assertions we can honestly make, but we
keep the trip going as long as possible, in case it reveals anything.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolib/fuzzing: adapt fuzz_sddl_access_check for claims
Douglas Bagnall [Wed, 12 Jul 2023 01:03:53 +0000 (13:03 +1200)]
lib/fuzzing: adapt fuzz_sddl_access_check for claims

The token has more stuff in it.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: conditional ace access checks for file server
Douglas Bagnall [Wed, 13 Sep 2023 05:25:34 +0000 (17:25 +1200)]
libcli/security: conditional ace access checks for file server

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: conditional ace access checks for AD
Douglas Bagnall [Thu, 29 Jun 2023 03:15:43 +0000 (15:15 +1200)]
libcli/security: conditional ace access checks for AD

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest:conditional_ace_claims: ease export of failing tests to C
Douglas Bagnall [Wed, 23 Aug 2023 03:23:29 +0000 (15:23 +1200)]
pytest:conditional_ace_claims: ease export of failing tests to C

When a test fails, this prints a little stanza like

static void test_something(void **state)
{
       INIT();
       USER_SIDS("WD", "AA");
       DEVICE_SIDS("BA", "BG");
       SD("D:(XA;;0x1f;;;AA;(! Member_of{SID(AA)}))");
       DENY_CHECK(0x10);
}

which is exactly right for copying into
libcli/security/tests/test_run_conditional_ace.c
which is much easier to iterate over with compiling and debugging.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest: tests for conditional ACEs with security tokens
Douglas Bagnall [Thu, 24 Aug 2023 01:44:17 +0000 (13:44 +1200)]
pytest: tests for conditional ACEs with security tokens

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest: tools for creating security tokens
Douglas Bagnall [Wed, 12 Jul 2023 05:22:24 +0000 (17:22 +1200)]
pytest: tools for creating security tokens

Sometimes we need security tokens for tests, and the raw constructor
is not very ergonomic. This wraps it so you can do this:

from samba.tests.token_factory import token as Token
t = Token(['WD', 'AA'],
          privileges=['SEC_PRIV_DEBUG'],
          rights=0x840,
          device_claims={'wheels': 2, 'smelly': 'no'},
          device_sids=['BG'])

and get a security.token object with the expected qualities.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security: cmocka test for running conditional ACEs
Douglas Bagnall [Wed, 12 Jul 2023 05:21:22 +0000 (17:21 +1200)]
libcli/security: cmocka test for running conditional ACEs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agolibcli/security/conditional ACEs: compare composites as sets
Douglas Bagnall [Tue, 12 Sep 2023 22:21:49 +0000 (10:21 +1200)]
libcli/security/conditional ACEs: compare composites as sets

... or at least settishly.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agosecurity.idl: drop claim v1 reserved field
Douglas Bagnall [Tue, 12 Sep 2023 01:51:37 +0000 (13:51 +1200)]
security.idl: drop claim v1 reserved field

It isn't used and ended up filled with junk. The alignment works out.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
8 months agopytest: sddl tests with conditional ACEs
Douglas Bagnall [Thu, 24 Aug 2023 01:44:41 +0000 (13:44 +1200)]
pytest: sddl tests with conditional ACEs

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