]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
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>
2 years agolibcli:security: add code to interpret conditional ACES
Douglas Bagnall [Wed, 6 Sep 2023 03:10:37 +0000 (15:10 +1200)] 
libcli:security: add code to interpret conditional ACES

This doesn't actually *do* anything yet, for two reasons:

 1. conditional ACEs are not checked in the
    libcli/security/access_check.c functions (or anywhere else), and
    will be treated just as they are now, as unknown types.

 2. this file isn't mentioned in the wscript, so aren't compiled.

 We'll get to point 2 first.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli:security: add functions to decode and decode RA ACEs
Douglas Bagnall [Wed, 6 Sep 2023 03:51:23 +0000 (15:51 +1200)] 
libcli:security: add functions to decode and decode RA ACEs

Resource Attribute ACEs have similar syntactical components to
conditional ACEs -- enough so that it is worth reusing the same
functions, but not quite enough so that it is exactly simple.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: add conditional ACE SDDL functions
Douglas Bagnall [Wed, 6 Sep 2023 03:50:43 +0000 (15:50 +1200)] 
libcli/security: add conditional ACE SDDL functions

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli:security: helpers for converting claim types
Douglas Bagnall [Thu, 29 Jun 2023 03:16:20 +0000 (15:16 +1200)] 
libcli:security: helpers for converting claim types

There are three different forms for claims, and we need to convert
between them.

For now, we are only going to be converting between conditional ACE
type and the CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1 type used by
resource ACEs and in the security token, and later we will add the PAC
claim types.

It doesn't help that these all have incompatible definitions, but we
do our best.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli:security: outline for sddl_conditional_ace.c
Douglas Bagnall [Wed, 12 Jul 2023 05:21:06 +0000 (17:21 +1200)] 
libcli:security: outline for sddl_conditional_ace.c

This is to show where we're going to end up.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: add stub of conditional ACE code.
Douglas Bagnall [Wed, 12 Jul 2023 05:20:44 +0000 (17:20 +1200)] 
libcli/security: add stub of conditional ACE code.

This is just the outline of what will come, but first we'll add
conditional ACE SDDL decoding in sddl_conditional_ace.c

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: find SDDL coda for RA and conditional ACEs
Douglas Bagnall [Thu, 24 Aug 2023 03:08:13 +0000 (15:08 +1200)] 
libcli/security: find SDDL coda for RA and conditional ACEs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: whitespace repair in sddl.c
Douglas Bagnall [Fri, 21 Jul 2023 04:51:53 +0000 (16:51 +1200)] 
libcli/security: whitespace repair in sddl.c

tabs not spaces.

It appears that my emacs got its configuration mixed up and was using
spaces.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agondr_sec_helper: ace length should be multiple of 4
Douglas Bagnall [Wed, 30 Aug 2023 00:14:14 +0000 (12:14 +1200)] 
ndr_sec_helper: ace length should be multiple of 4

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agondr_sec_helper: ndr_size_security_ace: do less work
Douglas Bagnall [Wed, 16 Aug 2023 22:46:23 +0000 (10:46 +1200)] 
ndr_sec_helper: ndr_size_security_ace: do less work

Almost always the ACE has an `ignored` DATA_BLOB as the coda, and the
length of the coda is the length field of the blob, which is usually
zero.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibrpc:security.idl: add conditional ace coda
Douglas Bagnall [Wed, 23 Aug 2023 00:09:11 +0000 (12:09 +1200)] 
librpc:security.idl: add conditional ace coda

Conditional ACEs go into a DATA_BLOB just like the default ignored
coda, but we add a union field with a different name to preserve
sanity.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/sec: reformat long line in wscript_build
Douglas Bagnall [Wed, 4 Jan 2023 02:56:05 +0000 (15:56 +1300)] 
libcli/sec: reformat long line in wscript_build

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibrpc:security.idl: ace->coda can be resource attribute
Douglas Bagnall [Wed, 23 Aug 2023 00:08:41 +0000 (12:08 +1200)] 
librpc:security.idl: ace->coda can be resource attribute

And now we see why security_ace_coda was a union.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: callback object aces are object aces
Douglas Bagnall [Sat, 3 Jun 2023 23:43:57 +0000 (11:43 +1200)] 
libcli/security: callback object aces are object aces

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: use tabs in sec_ace_object()
Douglas Bagnall [Sat, 3 Jun 2023 23:43:13 +0000 (11:43 +1200)] 
libcli/security: use tabs in sec_ace_object()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: helper to find ACEs with meaningful codas
Douglas Bagnall [Wed, 23 Aug 2023 00:47:53 +0000 (12:47 +1200)] 
libcli/security: helper to find ACEs with meaningful codas

Only Resource Attribute ACEs and Conditional ACEs are expected to have
trailing data. Others sometimes might, but we don't care what it is.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: helper to find resource attribute ACEs
Douglas Bagnall [Wed, 23 Aug 2023 00:44:26 +0000 (12:44 +1200)] 
libcli/security: helper to find resource attribute ACEs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli/security: helper to find callback/conditional aces
Douglas Bagnall [Thu, 8 Dec 2022 22:42:38 +0000 (11:42 +1300)] 
libcli/security: helper to find callback/conditional aces

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosecurity.idl: use sec_ace_object() in object switch
Douglas Bagnall [Wed, 23 Aug 2023 00:05:45 +0000 (12:05 +1200)] 
security.idl: use sec_ace_object() in object switch

At some point sec_ace_object() is going to gain awareness of
SEC_ACE_TYPE_ACCESS_ALLOWED_CALLBACK_OBJECT and the like.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosecurity.idl: extend security token with device SIDs
Douglas Bagnall [Wed, 23 Aug 2023 23:58:05 +0000 (11:58 +1200)] 
security.idl: extend security token with device SIDs

A device has SIDs too, and a modern security token needs to know
them in order to interpret conditional expressions like
"Device_member_of".

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotestparm: Allow idmap ranges overlap for idmap_nss
Samuel Cabrero [Tue, 26 Sep 2023 11:01:03 +0000 (13:01 +0200)] 
testparm: Allow idmap ranges overlap for idmap_nss

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Sep 26 19:28:08 UTC 2023 on atb-devel-224

2 years agolibsmb: Pass neg contexts through sync smbXcli_negprot_recv()
Volker Lendecke [Tue, 19 Sep 2023 18:10:12 +0000 (11:10 -0700)] 
libsmb: Pass neg contexts through sync smbXcli_negprot_recv()

Looks much larger than it is, there's a lot of callers too feed NULL to.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Sep 25 19:59:17 UTC 2023 on atb-devel-224

2 years agolibsmb: Make libsmb/clispnego.c static to libads/
Volker Lendecke [Thu, 14 Sep 2023 17:00:06 +0000 (19:00 +0200)] 
libsmb: Make libsmb/clispnego.c static to libads/

It's only called there. The "+" part of this patch might not conform
to README.Coding because it's a literal cut&paste.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolibcli: Correct guard #define
Volker Lendecke [Sun, 10 Sep 2023 05:05:04 +0000 (07:05 +0200)] 
libcli: Correct guard #define

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>