]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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

2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years 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>
2 years agolibcli/security/tests: add some test strings
Douglas Bagnall [Thu, 7 Sep 2023 03:38:07 +0000 (15:38 +1200)] 
libcli/security/tests: add some test strings

These will soon be used by python/samba/tests/sddl_conditional_ace.py,
and are a format understood by the Windows programs in
libcli/security/tests/windows.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: sddl strings dir can be defined in class
Douglas Bagnall [Thu, 7 Sep 2023 03:27:21 +0000 (15:27 +1200)] 
pytest: sddl strings dir can be defined in class

Before we had to do this in an environment variable. In that case we
are probably wanting to monitor changes, so we like it to print more
messages than we want to see in an autobuild run that will hopefully
never do anything interesting.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: sddl tests can be only externally defined
Douglas Bagnall [Wed, 6 Sep 2023 23:19:21 +0000 (11:19 +1200)] 
pytest: sddl tests can be only externally defined

Currently a test suite needs a strings list in order to import new
strings. This lets us avoid that and have the actual tests defined
only in external lists, making it easier to see we're testing the same
thing on Windows and reducing duplication.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: windows-sddl-test: fix read of text examples
Douglas Bagnall [Mon, 11 Sep 2023 23:55:55 +0000 (11:55 +1200)] 
libcli/security: windows-sddl-test: fix read of text examples

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: windows-sddl-test: fix typo in --help
Douglas Bagnall [Thu, 7 Sep 2023 02:38:49 +0000 (14:38 +1200)] 
libcli/security: windows-sddl-test: fix typo in --help

found by Rob van der Linde.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest:security_descriptors: test collected conditional ACEs
Douglas Bagnall [Tue, 5 Sep 2023 23:51:15 +0000 (11:51 +1200)] 
pytest:security_descriptors: test collected conditional ACEs

These tests were named in the superclass, but were not actually run,
nor was the file in git.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest:security descriptors: hack to capture results as json
Douglas Bagnall [Mon, 4 Sep 2023 23:27:33 +0000 (11:27 +1200)] 
pytest:security descriptors: hack to capture results as json

This makes it easy to separate a large number of examples into
successes and knownfails.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: security descriptors: test some conditional and RA ACEs
Douglas Bagnall [Mon, 4 Sep 2023 23:27:00 +0000 (11:27 +1200)] 
pytest: security descriptors: test some conditional and RA ACEs

We have two sets of tests: one that will succeed, and one that is going
to remain a knownfail. The latter involves Resource Attribute ACEs that
have the TX type, meaning "byte string".

In MS-DTYP, a bytestring is defined like "#6869210a", with a hash,
followed by an even number of hex digits. In other places on the web, it
is mentioned that zeroes in the string can be replaced by hashes, like so
"#686921#a". We discover via indirect fuzzing that a TX RA ACE can also
take bare integers, like "6869210a" or "2023". As it would be tricky to
support this, and there is no evidence of this occurring in the wild, we
will probably leave this as a knownfail.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: security_descriptors: tests without revision number hack
Douglas Bagnall [Wed, 9 Aug 2023 02:15:27 +0000 (14:15 +1200)] 
pytest: security_descriptors: tests without revision number hack

ACL revision 4 (SECURITY_ACL_REVISION_ADS) is effectively a superset
of revision 2 (SECURITY_ACL_REVISION_NT4), so any revision 2
ACL can be called revision 4 without any problem. But not vice versa:
a revision 4 ACL can contain ACE types that a revision 2 ACL can't. The
extra ACE types relate to objects.

Samba currently simplifies things by calling all its ACLs revision 4,
even if (as is commonly the case) the ACLs contain only revision 2 ACEs.
On the other hand, Windows will use revision 2 whenever it can. In other
tests we skip past this by forcing Windows ACLs to v4 before comparison.
This test is to remind us of the incompatibility.

It would not be hard to fix.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: use sec_object_ace() in size_security_ace
Douglas Bagnall [Tue, 22 Aug 2023 23:25:41 +0000 (11:25 +1200)] 
libcli/security: use sec_object_ace() in size_security_ace

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibrpc/ndr:ndr_sec_helper: fix a typo
Douglas Bagnall [Tue, 22 Aug 2023 23:24:46 +0000 (11:24 +1200)] 
librpc/ndr:ndr_sec_helper: fix a typo

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: security_descriptors test for repetitive ACLs
Douglas Bagnall [Mon, 4 Sep 2023 22:56:43 +0000 (10:56 +1200)] 
pytest: security_descriptors test for repetitive ACLs

If there are multiple identical ACEs in an SDDL ACL, Windows will decode
them all and put extra trailing zeroes at the end of the ACL.

In contrast, Samba will decode the ACEs and not put extra zeroes at the
end.

The problem comes when Samba tries to read a binary ACL from Windows that
has the extra zeroes, because Samba's ACL size calculation is based on
the size of its constituent ACEs, not the ACL size field.

There is no good reason for an ACL to have repeated ACEs, but they could
be added accidentally.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopytest: security_descriptors comparison is quieter
Douglas Bagnall [Wed, 9 Aug 2023 02:15:27 +0000 (14:15 +1200)] 
pytest: security_descriptors comparison is quieter

This matters when we have a millions failures.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4/librpc: build conditional ace Python bindings
Douglas Bagnall [Thu, 29 Jun 2023 03:13:58 +0000 (15:13 +1200)] 
s4/librpc: build conditional ace Python bindings

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib/fuzzing: fuzz SDDL conditional ACEs
Douglas Bagnall [Thu, 29 Jun 2023 03:15:23 +0000 (15:15 +1200)] 
lib/fuzzing: fuzz SDDL conditional ACEs

Here we're not compiling the whole SD, just the single conditional
ACE.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: test SDDL compilation in cmocka
Douglas Bagnall [Wed, 12 Jul 2023 05:24:33 +0000 (17:24 +1200)] 
libcli/security: test SDDL compilation in cmocka

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolbcli/security: callback object ACES fall back with no GUID
Douglas Bagnall [Tue, 19 Sep 2023 23:12:42 +0000 (11:12 +1200)] 
lbcli/security: callback object ACES fall back with no GUID

As with other object ACEs, if there is not a GUID to refer to the ACE
becomes the corresponding non-object ACE.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security/create_descriptor: calc_inherited handles new types
Douglas Bagnall [Fri, 21 Jul 2023 02:36:20 +0000 (14:36 +1200)] 
libcli/security/create_descriptor: calc_inherited handles new types

*_CALLBACK_OBJECT types inherit like other _OBJECT types.
*_CALLBACK types do nothing, like other non-OBJECT types.

We also explicitly throw unused alarm callback types and
SEC_ACE_TYPE_SYSTEM_MANDATORY_LABEL and
SEC_ACE_TYPE_SYSTEM_SCOPED_POLICY_ID into the fire.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: SDDL: add callback and resource ace type flags
Douglas Bagnall [Fri, 21 Jul 2023 05:00:50 +0000 (17:00 +1200)] 
libcli/security: SDDL: add callback and resource ace type flags

With this, Conditional ACEs and Resource Attribute ACEs in SDDL will
be parsed.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: sddl_encode_ace encodes resource attribute ACEs
Douglas Bagnall [Fri, 21 Jul 2023 04:53:45 +0000 (16:53 +1200)] 
libcli/security: sddl_encode_ace encodes resource attribute ACEs

Will work when the ace_flags table is updated.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: sddl_encode_ace encodes conditional ACEs
Douglas Bagnall [Fri, 21 Jul 2023 04:53:08 +0000 (16:53 +1200)] 
libcli/security: sddl_encode_ace encodes conditional ACEs

Will work when the ace_flags table is updated.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: sdd_decode_ace handles resource attribute types
Douglas Bagnall [Thu, 24 Aug 2023 04:10:35 +0000 (16:10 +1200)] 
libcli/security: sdd_decode_ace handles resource attribute types

The decoding will not happen until "RA" is added to the ace_types table.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: sdd_decode_ace handles callback types
Douglas Bagnall [Thu, 24 Aug 2023 03:12:01 +0000 (15:12 +1200)] 
libcli/security: sdd_decode_ace handles callback types

Conditional ACEs will not actually be decoded until the CALLBACK types
are added to the ace_types flag table.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: add conditional ace files to samba-security
Douglas Bagnall [Thu, 17 Aug 2023 04:39:46 +0000 (16:39 +1200)] 
libcli/security: add conditional ace files to samba-security

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