metze/samba/wip.git
11 months agosmbd: Pass "char*" to dos_mode_from_name()
Volker Lendecke [Tue, 20 Jun 2023 14:22:30 +0000 (16:22 +0200)]
smbd: Pass "char*" to dos_mode_from_name()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Pass stat_ex and files_struct to dos_mode_from_sbuf()
Volker Lendecke [Tue, 20 Jun 2023 14:19:50 +0000 (16:19 +0200)]
smbd: Pass stat_ex and files_struct to dos_mode_from_sbuf()

Will enable simplification of dos_mode_msdfs()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Extend openat_pathref_dirfsp_nosymlink()
Volker Lendecke [Mon, 12 Dec 2022 13:04:00 +0000 (14:04 +0100)]
smbd: Extend openat_pathref_dirfsp_nosymlink()

Turn it into openat_pathref_fsp_nosymlink() which opens not only
directories but normal files and symlinks too. If it finds a symlink,
return NT_STATUS_STOPPED_ON_SYMLINK and all the metadata we can find:
struct stat_ex plus the symlink target.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agotest: skip the open-eintr test
Volker Lendecke [Thu, 8 Dec 2022 10:07:53 +0000 (11:07 +0100)]
test: skip the open-eintr test

With 7bb8af3f74c we already had to tune the error_inject VFS object to filter
out the openat-calls coming from filename_convert_dirfsp&friends. With
the next patch openat() will be called from even more places, and I
don't really see a good way to properly deal with EINTR in all the
places where it can happen. The real case where EINTR is something we
need to handle properly I guess is with kernel oplocks active: open()
waits for another process to give up its kernel oplock, which opens
the window for EINTR to become a valid case to properly take care
of. For all other opens I would be willing to live with the fact that
we just return an error message that might be different from Windows.

To detect that kernel oplock case properly, with O_PATH we have to
look at the /proc/self/fd/<n> reopen or the O_EMPTY_PATH FreeBSD
flavor from inside the error_inject module I guess. But then, the
second time we come around the corner we have to let it pass.

Difficult to properly test, disable the test for now.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Fully fill in fsp in openat_pathref_fsp_nosymlink_internal()
Volker Lendecke [Tue, 16 May 2023 09:24:35 +0000 (11:24 +0200)]
smbd: Fully fill in fsp in openat_pathref_fsp_nosymlink_internal()

Prepare for allowing openat_pathref_fsp_nosymlink() to open real files
in the next patches.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Lift up conn->cwd from openat_pathref_dirfsp_nosymlink()
Volker Lendecke [Tue, 16 May 2023 09:13:35 +0000 (11:13 +0200)]
smbd: Lift up conn->cwd from openat_pathref_dirfsp_nosymlink()

The goal of this patch is to make the next patches smaller. Next
patches will also make openat_pathref_dirfsp_nosymlink() open real
files, not only directories.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Factor out full_path_extend()
Volker Lendecke [Tue, 16 May 2023 08:49:08 +0000 (10:49 +0200)]
smbd: Factor out full_path_extend()

This logic will be used in another place in the next commit

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Add read_symlink_reparse()
Volker Lendecke [Mon, 5 Dec 2022 11:15:21 +0000 (12:15 +0100)]
smbd: Add read_symlink_reparse()

Fake up a symlink reparse point structure from an on-disk reparse
point.

Turn in-share absolute symlinks into relative ones for the client to
properly follow symlinks. Pass on everything else as-is. In particular
clients follow symlinks pointing at \\server\share\...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Apply some README.Coding to dos_mode_from_sbuf()
Volker Lendecke [Tue, 20 Jun 2023 14:16:23 +0000 (16:16 +0200)]
smbd: Apply some README.Coding to dos_mode_from_sbuf()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Simplify dos_mode_msdfs()
Volker Lendecke [Tue, 20 Jun 2023 13:34:28 +0000 (15:34 +0200)]
smbd: Simplify dos_mode_msdfs()

This is exactly what dos_mode_from_name() does.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Move dos_mode_from_name() up in dosmode.c
Volker Lendecke [Tue, 20 Jun 2023 13:31:34 +0000 (15:31 +0200)]
smbd: Move dos_mode_from_name() up in dosmode.c

Is useful in dos_mode_msdfs() as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agosmbd: Slightly simplify smbd_dirptr_get_entry()
Volker Lendecke [Wed, 21 Jun 2023 15:48:24 +0000 (17:48 +0200)]
smbd: Slightly simplify smbd_dirptr_get_entry()

Implementing virtually empty directories for "dont descend" looks
easier to me this way. It should also be an optimization, because now
we don't walk the whole directory anymore after . and .., which always
come first anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months ago.gitlab-ci:bootstrap: remove ubuntu1804*, add debian12, upgrade opensuse 15.5
Stefan Metzmacher [Thu, 17 Nov 2022 15:14:27 +0000 (16:14 +0100)]
.gitlab-ci:bootstrap: remove ubuntu1804*, add debian12, upgrade opensuse 15.5

Signed-off-by: Stefan Metzmacher <metze@samba.org>
[abartlet@samba.org Use Debian 11 for the 32 bit host as the compile
 currently fails - just exits without information - mid-way on Debian 12]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Jun 30 08:51:17 UTC 2023 on atb-devel-224

11 months agothird_party: Update socket_wrapper to version 1.4.2
Andreas Schneider [Wed, 21 Jun 2023 10:40:16 +0000 (12:40 +0200)]
third_party: Update socket_wrapper to version 1.4.2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Jun 29 16:06:11 UTC 2023 on atb-devel-224

11 months agos3:utils: smbget fix a memory leak
Jones Syue [Tue, 27 Jun 2023 09:19:59 +0000 (17:19 +0800)]
s3:utils: smbget fix a memory leak

Using smbget to download files recursively (-R).

If smbget found that a file is already existed in the destination,
smbget would said 'File exists', return early, and 'newname' allocated
memory is never freed, this is found by valgrind.

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

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Jun 28 07:02:34 UTC 2023 on atb-devel-224

11 months agos4:kdc: don't log an error if msDS-AllowedToActOnBehalfOfOtherIdentity is missing
Stefan Metzmacher [Fri, 23 Jun 2023 09:51:47 +0000 (11:51 +0200)]
s4:kdc: don't log an error if msDS-AllowedToActOnBehalfOfOtherIdentity is missing

We log a warnings if access is not granted from a security descriptor in
msDS-AllowedToActOnBehalfOfOtherIdentity, so we should use the same log
level if msDS-AllowedToActOnBehalfOfOtherIdentity is not available at
all.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jun 27 06:39:08 UTC 2023 on atb-devel-224

11 months agos4:kdc: Include default groups in security token
Joseph Sutton [Tue, 20 Jun 2023 04:50:18 +0000 (16:50 +1200)]
s4:kdc: Include default groups in security token

This is consistent with the behaviour of the existing function
_authn_policy_access_check() and of Windows.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Implement Heimdal hook for resource-based constrained delegation
Joseph Sutton [Tue, 20 Jun 2023 02:22:15 +0000 (14:22 +1200)]
s4:kdc: Implement Heimdal hook for resource-based constrained delegation

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Adjust authentication policy RBCD tests to expect appropriate failure...
Joseph Sutton [Tue, 20 Jun 2023 04:48:58 +0000 (16:48 +1200)]
tests/krb5: Adjust authentication policy RBCD tests to expect appropriate failure statuses

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Be less strict regarding acceptable delegation error codes
Joseph Sutton [Tue, 20 Jun 2023 04:46:03 +0000 (16:46 +1200)]
tests/krb5: Be less strict regarding acceptable delegation error codes

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Remove useless sdb → hdb error code translation
Joseph Sutton [Tue, 20 Jun 2023 04:41:05 +0000 (16:41 +1200)]
s4:kdc: Remove useless sdb → hdb error code translation

samba_kdc_check_s4u2proxy() is never going to return an SDB_* error
code, so these conditions can never be hit.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Initialize pointers with NULL
Joseph Sutton [Tue, 20 Jun 2023 04:40:03 +0000 (16:40 +1200)]
s4:kdc: Initialize pointers with NULL

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agothird_party/heimdal: Import lorikeet-heimdal-202306200407 (commit fc2894beeaa71897753...
Joseph Sutton [Tue, 20 Jun 2023 04:33:17 +0000 (16:33 +1200)]
third_party/heimdal: Import lorikeet-heimdal-202306200407 (commit fc2894beeaa71897753975154a5f7fd80b923325)

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agosmbd: Don't mask open error if fstatat() fails
Volker Lendecke [Mon, 26 Jun 2023 11:17:44 +0000 (13:17 +0200)]
smbd: Don't mask open error if fstatat() fails

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jun 26 16:53:21 UTC 2023 on atb-devel-224

11 months agotests: Show smbd returns wrong error code when creating on r/o fs
Volker Lendecke [Mon, 26 Jun 2023 12:54:00 +0000 (14:54 +0200)]
tests: Show smbd returns wrong error code when creating on r/o fs

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agoerror_inject: Enable returning EROFS for O_CREAT
Volker Lendecke [Mon, 26 Jun 2023 11:17:19 +0000 (13:17 +0200)]
error_inject: Enable returning EROFS for O_CREAT

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agoerror_inject: map EROFS
Volker Lendecke [Mon, 26 Jun 2023 10:47:17 +0000 (12:47 +0200)]
error_inject: map EROFS

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
11 months agos4:kdc: Don’t overwrite error code
Joseph Sutton [Mon, 26 Jun 2023 05:09:22 +0000 (17:09 +1200)]
s4:kdc: Don’t overwrite error code

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Mon Jun 26 12:11:30 UTC 2023 on atb-devel-224

11 months agos4:kdc: Add comment to clarify that we fetch the client claims
Joseph Sutton [Thu, 22 Jun 2023 23:55:24 +0000 (11:55 +1200)]
s4:kdc: Add comment to clarify that we fetch the client claims

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: clear client and device claims from trusts
Stefan Metzmacher [Thu, 22 Jun 2023 07:08:53 +0000 (09:08 +0200)]
s4:kdc: clear client and device claims from trusts

As we don't support the Claims Transformation Algorithm [MS-CTA]
we better clear claims as they have no valid meaning in our domain.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Make [client,device]_claims_blob const pointers
Joseph Sutton [Sun, 25 Jun 2023 23:10:51 +0000 (11:10 +1200)]
s4:kdc: Make [client,device]_claims_blob const pointers

This is so that we can have them point to ‘null_data’ if we so choose.

We can’t assign the result of data_blob_talloc() to a const pointer, so
we go through an intermediary non-const pointer for the
device_claims_blob case.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Remove unnecessary NULL check
Joseph Sutton [Sun, 25 Jun 2023 23:11:19 +0000 (11:11 +1200)]
s4:kdc: Remove unnecessary NULL check

pac_blobs_add_blob() already checks whether the blob argument is NULL,
and skips adding the blob if so.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: pass krbtgt skdc_entries to samba_kdc_update_pac()
Stefan Metzmacher [Thu, 22 Jun 2023 07:18:51 +0000 (09:18 +0200)]
s4:kdc: pass krbtgt skdc_entries to samba_kdc_update_pac()

For now we only pass in the krbtgt that verified the client pac
and optionally the krbtgt that verified the device pac.

These can be different depending on the domain of the related
principals.

If we want to apply SID filtering in future we may also need
to pass in the krbtgt that verified the delegated_proxy_pac,
but that needs more research and if not required for the
following changes.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: adjust formatting of samba_kdc_update_pac() documentation
Stefan Metzmacher [Thu, 22 Jun 2023 23:20:59 +0000 (11:20 +1200)]
s4:kdc: adjust formatting of samba_kdc_update_pac() documentation

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Enforce authentication policy service restrictions when getting a PAC
Joseph Sutton [Fri, 16 Jun 2023 03:08:00 +0000 (15:08 +1200)]
s4:kdc: Enforce authentication policy service restrictions when getting a PAC

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Check authentication policy server restrictions
Joseph Sutton [Fri, 16 Jun 2023 02:24:50 +0000 (14:24 +1200)]
s4:kdc: Check authentication policy server restrictions

For a constrained delegation request, we need to pass ‘delegated_proxy’
(and the delegated proxy PAC, if one was provided) into
samba_kdc_update_pac() so that we can verify that the delegating server
is allowed to authenticate to the target server.

The ‘const’ is entirely unnecessary in a function declaration, but we
add it just to be consistent.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Check authentication policy device restrictions
Joseph Sutton [Fri, 16 Jun 2023 03:05:48 +0000 (15:05 +1200)]
s4:kdc: Check authentication policy device restrictions

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Add comment stating that policies aren’t looked up for S4U clients
Joseph Sutton [Tue, 20 Jun 2023 00:57:27 +0000 (12:57 +1200)]
s4:kdc: Add comment stating that policies aren’t looked up for S4U clients

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Test that client policies are not enforced with S4U
Joseph Sutton [Tue, 20 Jun 2023 00:59:11 +0000 (12:59 +1200)]
tests/krb5: Test that client policies are not enforced with S4U

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Fix RBCD comments
Joseph Sutton [Tue, 20 Jun 2023 00:56:45 +0000 (12:56 +1200)]
tests/krb5: Fix RBCD comments

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Don’t unnecessarily specify ‘id’
Joseph Sutton [Tue, 20 Jun 2023 00:39:26 +0000 (12:39 +1200)]
tests/krb5: Don’t unnecessarily specify ‘id’

In tests where we have multiple accounts of the same type, we use the
‘id’ parameter to ensure that these accounts are all different, as some
restrictions are bypassed if an account authenticates to the selfsame
account. However, this is unnecessary if we already specify (with
‘use_cache=False’) that the cache is not to be used.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Remove unused ‘server’ parameter in pac_verify()
Joseph Sutton [Mon, 19 Jun 2023 23:21:27 +0000 (11:21 +1200)]
s4:kdc: Remove unused ‘server’ parameter in pac_verify()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Handle new KDC_AUTH_EVENT_CLIENT_FOUND audit event
Joseph Sutton [Mon, 19 Jun 2023 23:20:44 +0000 (11:20 +1200)]
s4:kdc: Handle new KDC_AUTH_EVENT_CLIENT_FOUND audit event

NOTE: This commit finally works again!

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Ensure that we don’t log PREAUTH_REQUIRED errors
Joseph Sutton [Mon, 19 Jun 2023 23:15:50 +0000 (11:15 +1200)]
s4:kdc: Ensure that we don’t log PREAUTH_REQUIRED errors

Such errors were not logged in the past, either, but that was accidental
— a result of failing too early for an authentication event to be set —
rather than the auditing being deliberately designed that way.

Now that we have added the KDC_AUTH_EVENT_CLIENT_FOUND event, we want to
ensure that PREAUTH_REQUIRED errors continue to go unlogged.

NOTE: THIS COMMIT WON’T COMPILE/WORK ON ITS OWN!

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agos4:kdc: Update Samba KDC plugin to match new Heimdal version
Joseph Sutton [Mon, 19 Jun 2023 23:14:50 +0000 (11:14 +1200)]
s4:kdc: Update Samba KDC plugin to match new Heimdal version

NOTE: THIS COMMIT WON’T COMPILE/WORK ON ITS OWN!

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agothird_party/heimdal: Import lorikeet-heimdal-202306192129 (commit 0096f9c1dc105d8ac9f...
Joseph Sutton [Mon, 19 Jun 2023 22:52:01 +0000 (10:52 +1200)]
third_party/heimdal: Import lorikeet-heimdal-202306192129 (commit 0096f9c1dc105d8ac9f7dd96d653b05228f7d280)

NOTE: THIS COMMIT WON’T COMPILE/WORK ON ITS OWN!

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/krb5: Add test for authenticating with disabled account and wrong password
Joseph Sutton [Wed, 21 Jun 2023 04:54:36 +0000 (16:54 +1200)]
tests/krb5: Add test for authenticating with disabled account and wrong password

This shows us that the client’s access is checked prior to passwords
being checked.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agotests/auth_log_pass_change: Fix flapping test
Joseph Sutton [Mon, 19 Jun 2023 22:11:50 +0000 (10:11 +1200)]
tests/auth_log_pass_change: Fix flapping test

It appears that discardMessages() is still not entirely reliable. Ensure
that we filter out any messages from the Administrator’s authentication.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agonetcmd: domain: Fix typo
Joseph Sutton [Mon, 19 Jun 2023 00:55:40 +0000 (12:55 +1200)]
netcmd: domain: Fix typo

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
11 months agoAlign samba_kdc_update_pac() prototype in pac-glue.h with the implementation in pac...
Andrew Bartlett [Sun, 25 Jun 2023 23:03:14 +0000 (11:03 +1200)]
Align samba_kdc_update_pac() prototype in pac-glue.h with the implementation in pac-glue.c

Commit 6bd3b4528d4b33c8f7ae6341d166bea3a06cd971 diverged the const
declarations in the header, this brings them back in alignnment as
is Samba's normal practice.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Jun 26 00:26:37 UTC 2023 on atb-devel-224

11 months agos4:kdc: Use talloc_get_type_abort()
Joseph Sutton [Fri, 16 Jun 2023 03:02:35 +0000 (15:02 +1200)]
s4:kdc: Use talloc_get_type_abort()

We subsequently dereference the result without performing a NULL check.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Create a temporary talloc context on which to allocate
Joseph Sutton [Fri, 16 Jun 2023 03:00:29 +0000 (15:00 +1200)]
s4:kdc: Create a temporary talloc context on which to allocate

‘client->context’ is too long-lived to use for allocating short-term
data.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Return NTSTATUS and auditing information from samba_kdc_update_pac() to be...
Joseph Sutton [Fri, 16 Jun 2023 02:49:11 +0000 (14:49 +1200)]
s4:kdc: Return NTSTATUS and auditing information from samba_kdc_update_pac() to be logged

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Flip sense of condition
Joseph Sutton [Fri, 16 Jun 2023 02:32:09 +0000 (14:32 +1200)]
s4:kdc: Flip sense of condition

A negative condition incurs more cognitive load.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Unify common code paths
Joseph Sutton [Fri, 16 Jun 2023 02:30:00 +0000 (14:30 +1200)]
s4:kdc: Unify common code paths

Perhaps view with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Use samba_kdc_obtain_user_info_dc() for !client_pac_is_trusted case
Joseph Sutton [Fri, 16 Jun 2023 02:04:43 +0000 (14:04 +1200)]
s4:kdc: Use samba_kdc_obtain_user_info_dc() for !client_pac_is_trusted case

This will help to reduce code duplication and the number of branching
code paths.

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Move adding compounded authentication SID out of samba_kdc_obtain_user_info_dc()
Joseph Sutton [Fri, 16 Jun 2023 01:40:20 +0000 (13:40 +1200)]
s4:kdc: Move adding compounded authentication SID out of samba_kdc_obtain_user_info_dc()

We may not always want this SID to be present. For example, to enforce
authentication policies as Windows does, we’ll want the client’s
security token without this SID.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Have samba_kdc_update_pac_blob() do less
Joseph Sutton [Fri, 16 Jun 2023 01:13:58 +0000 (13:13 +1200)]
s4:kdc: Have samba_kdc_update_pac_blob() do less

Previously this function obtained the auth_user_info_dc structure, then
used it to update the PAC blob. Now it does only one thing: fetch the
auth_user_info_dc info and return it to the caller, who can then call
samba_get_logon_info_pac_blob().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Remove unused PAC_SIGNATURE_DATA parameters
Joseph Sutton [Fri, 16 Jun 2023 01:06:24 +0000 (13:06 +1200)]
s4:kdc: Remove unused PAC_SIGNATURE_DATA parameters

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Log errors in samba_kdc_update_pac_blob()
Joseph Sutton [Fri, 16 Jun 2023 01:04:17 +0000 (13:04 +1200)]
s4:kdc: Log errors in samba_kdc_update_pac_blob()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Have samba_kdc_update_pac_blob() return krb5_error_code
Joseph Sutton [Fri, 16 Jun 2023 00:57:38 +0000 (12:57 +1200)]
s4:kdc: Have samba_kdc_update_pac_blob() return krb5_error_code

This gives it more control over the final Kerberos error code, so that
we won’t always get ERR_GENERIC.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Add singular out path to samba_kdc_update_pac_blob()
Joseph Sutton [Fri, 16 Jun 2023 00:53:07 +0000 (12:53 +1200)]
s4:kdc: Add singular out path to samba_kdc_update_pac_blob()

This ensures that we always clean up resources.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Make krb5_principal parameters const
Joseph Sutton [Fri, 16 Jun 2023 00:17:50 +0000 (12:17 +1200)]
s4:kdc: Make krb5_principal parameters const

The ‘const’ is entirely unnecessary in a function declaration, but we
add it just to be consistent.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Add helper function to determine whether a device is allowed to authenticate
Joseph Sutton [Thu, 15 Jun 2023 23:22:28 +0000 (11:22 +1200)]
s4:kdc: Add helper function to determine whether a device is allowed to authenticate

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Add helper function to determine whether authentication to a server is allowed
Joseph Sutton [Thu, 15 Jun 2023 23:20:04 +0000 (11:20 +1200)]
s4:kdc: Add helper function to determine whether authentication to a server is allowed

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:kdc: Add functionality to log client and server authentication policies
Joseph Sutton [Thu, 15 Jun 2023 23:01:04 +0000 (11:01 +1200)]
s4:kdc: Add functionality to log client and server authentication policies

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:auth: Log authentication policies for NTLM authentication
Joseph Sutton [Thu, 15 Jun 2023 22:40:16 +0000 (10:40 +1200)]
s4:auth: Log authentication policies for NTLM authentication

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:auth: Add audit info parameters to check_password_recv()
Joseph Sutton [Thu, 15 Jun 2023 22:21:59 +0000 (10:21 +1200)]
s4:auth: Add audit info parameters to check_password_recv()

These pointers can be set by implementing functions in order for them to
be logged in auth_check_password_recv().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agos4:auth: Set ‘authoritative’ even if there is an error
Joseph Sutton [Thu, 15 Jun 2023 22:26:25 +0000 (10:26 +1200)]
s4:auth: Set ‘authoritative’ even if there is an error

This is consistent with all the other functions that set
‘authoritative’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agoauth: Add functionality to log client and server policy information
Joseph Sutton [Thu, 15 Jun 2023 05:07:05 +0000 (17:07 +1200)]
auth: Add functionality to log client and server policy information

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agolib:audit_logging: Add function to return the JSON null object
Joseph Sutton [Thu, 15 Jun 2023 01:30:45 +0000 (13:30 +1200)]
lib:audit_logging: Add function to return the JSON null object

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agopython:tests: Fix typos
Joseph Sutton [Mon, 12 Jun 2023 22:34:39 +0000 (10:34 +1200)]
python:tests: Fix typos

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agonetcmd: domain: Fix typo
Joseph Sutton [Thu, 25 May 2023 02:50:16 +0000 (14:50 +1200)]
netcmd: domain: Fix typo

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agotests/krb5: Test authentication policy audit logging
Joseph Sutton [Wed, 14 Jun 2023 04:25:16 +0000 (16:25 +1200)]
tests/krb5: Test authentication policy audit logging

For each test, we check the authentication logs and ensure the messages
are as we expect.

We only test AS-REQs and TGS-REQs with the Heimdal KDC at the moment,
assuming that MIT doesn’t support logging for those cases.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agotests/krb5: Test more authentication logging of TGT lifetimes
Joseph Sutton [Thu, 15 Jun 2023 23:40:57 +0000 (11:40 +1200)]
tests/krb5: Test more authentication logging of TGT lifetimes

It is useful to test a combination of device restrictions and TGT
lifetime restrictions so that we can check what TGT lifetime values end
up in the logs.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agotests/krb5: Improve authentication policy creation
Joseph Sutton [Wed, 14 Jun 2023 04:14:42 +0000 (16:14 +1200)]
tests/krb5: Improve authentication policy creation

Don’t require passing in an ID to create an authentication policy.
Instead, have create_authn_policy() generate one for us.

We now return an actual AuthenticationPolicy object rather than just a
DN. This will give the tests more details to work with about the
policies.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
11 months agonetcmd: domain: add error handling to domain claims commands
Rob van der Linde [Fri, 23 Jun 2023 00:52:58 +0000 (12:52 +1200)]
netcmd: domain: add error handling to domain claims commands

Similar to the auth commands commit prior to this.

Where we wre catching LdbError before we now catch ModelError, all
exceptions that are known and handled in the model layer will have a
user-friendly error message.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: add error handling to domain auth commands
Rob van der Linde [Fri, 23 Jun 2023 00:26:38 +0000 (12:26 +1200)]
netcmd: domain: add error handling to domain auth commands

Where we wre catching LdbError before we now catch ModelError, all
exceptions that are known and handled in the model layer will have a
user-friendly error message.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: add model exceptions and error handling
Rob van der Linde [Fri, 23 Jun 2023 00:24:24 +0000 (12:24 +1200)]
netcmd: domain: add model exceptions and error handling

* Only handle what we know, otherwise raise the existing LdbError
* Cutom messages added in the model layer so we don't have to do it in
  the commands themselves

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: model stores ldb message for save
Rob van der Linde [Mon, 19 Jun 2023 01:23:33 +0000 (13:23 +1200)]
netcmd: domain: model stores ldb message for save

The message is stored in self._apply which also gets called by
self.refresh()

This is the better thing to do than fetching in save.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: man page updates for auth silo and policy cli
Rob van der Linde [Thu, 8 Jun 2023 03:03:16 +0000 (15:03 +1200)]
netcmd: domain: man page updates for auth silo and policy cli

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: silo member command tests
Rob van der Linde [Tue, 6 Jun 2023 02:11:26 +0000 (14:11 +1200)]
netcmd: domain: silo member command tests

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: model field tests
Rob van der Linde [Thu, 25 May 2023 00:32:13 +0000 (12:32 +1200)]
netcmd: domain: model field tests

Add tests for model fields to ensure they behave as expected when
calling from_db_value and to_db_value methods.

Add a base class for the tests themselves via a mixin as unittest
doesn't support abstract test case classes.

For each field, from_db_value and to_db_value must either be a list or
a property that returns a list.

The list contains input values and expected values, the expected value
can also be a callback for more complex comparison, this is used for
the possible claim values xml.

It is important that singular values and list values are tested, and
also None to ensure that fields properly get unset when a model is
saved.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: silo member add and remove does not write whole list
Rob van der Linde [Wed, 17 May 2023 11:35:16 +0000 (23:35 +1200)]
netcmd: domain: silo member add and remove does not write whole list

Writing the whole list at once can lead to data loss if multiple
administrators are doing this at the same time.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: remove parse_guid and parse_text as they are no longer used
Rob van der Linde [Wed, 17 May 2023 04:27:54 +0000 (16:27 +1200)]
netcmd: domain: remove parse_guid and parse_text as they are no longer used

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: claims: base class is no longer required
Rob van der Linde [Tue, 16 May 2023 23:13:33 +0000 (11:13 +1200)]
netcmd: domain: claims: base class is no longer required

base.py has been removed as this has all been moved to the model layer

as the auth commands ldb is now just a local variable

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: claims: move claim value type lookup by attribute to model
Rob van der Linde [Tue, 16 May 2023 22:56:02 +0000 (10:56 +1200)]
netcmd: domain: claims: move claim value type lookup by attribute to model

Also, there was no need for the cached property previously in the
command, as the command only calls this once.

Fetching all value types seems excessive now with the new model layer,
we just fetch the one we need and get a model object back.

Use the method lookup, it's consistent with the rest, and raise either
LookupError or ValueError.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: claims: make use of AttributeSchema and ClassSchema models
Rob van der Linde [Tue, 16 May 2023 21:50:13 +0000 (09:50 +1200)]
netcmd: domain: claims: make use of AttributeSchema and ClassSchema models

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: add models for ClassSchema and AttributeSchema
Rob van der Linde [Tue, 16 May 2023 21:46:45 +0000 (09:46 +1200)]
netcmd: domain: add models for ClassSchema and AttributeSchema

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: auth silos: remove base class
Rob van der Linde [Tue, 16 May 2023 03:28:04 +0000 (15:28 +1200)]
netcmd: auth silos: remove base class

There is no point to the base class anymore.

And since the model layer has dramatically simplified the code in the
commands, ldb can just be a local variable.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: add test for silo if policy is a dn
Rob van der Linde [Tue, 6 Jun 2023 04:26:37 +0000 (16:26 +1200)]
netcmd: domain: add test for silo if policy is a dn

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: move get_policy method from base class to the model
Rob van der Linde [Tue, 16 May 2023 03:12:14 +0000 (15:12 +1200)]
netcmd: move get_policy method from base class to the model

There isn't much left of the base class, the next thing is to remove
it.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: move method print_json to command base class
Rob van der Linde [Tue, 16 May 2023 02:35:41 +0000 (14:35 +1200)]
netcmd: move method print_json to command base class

This is used in quite a few commands, move to base class.

This ensures the correct encoder class and settings are always used,
and they are only defined in one place.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: fix import sort/grouping as per python standard
Rob van der Linde [Tue, 16 May 2023 02:24:27 +0000 (14:24 +1200)]
netcmd: fix import sort/grouping as per python standard

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: move ldb_connect method to base class
Rob van der Linde [Tue, 16 May 2023 01:54:59 +0000 (13:54 +1200)]
netcmd: move ldb_connect method to base class

This method is needed by just about every command and moving it here
is another step towards elinimanting the base classes in domain/auth
and domain/claim.

The base classes are almost empty now, since introducing the model
layer. The next step is to get rid of these base classes completely.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: PEP257 fix incorrect docstring quotes
Rob van der Linde [Tue, 16 May 2023 01:39:12 +0000 (13:39 +1200)]
netcmd: PEP257 fix incorrect docstring quotes

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: claims: use consistent naming for options
Rob van der Linde [Tue, 16 May 2023 00:56:09 +0000 (12:56 +1200)]
netcmd: domain: claims: use consistent naming for options

The name of the option should be the same as the attribute name.

You can still tell where it's being used (display_name), especially
now with the model layer:

    ClaimType.get(ldb, display_name=name)

The silo commands tend to use the `cn` field, while the claims
commands use the `displayName` field, but the option is always called
`name` for consistency.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: claim commands use the model layer
Rob van der Linde [Tue, 16 May 2023 00:52:04 +0000 (12:52 +1200)]
netcmd: domain: claim commands use the model layer

This makes it consistent with the auth silo code, both should now make
use of the models.

Claims commands are now using the model layer with one exception and
that is the get_attribute_from_schema and get_class_from_schema
methods in the base class.

These will be made into models in another commit.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: fix claims constant name was wrong should be claim type CN
Rob van der Linde [Thu, 25 May 2023 02:43:19 +0000 (14:43 +1200)]
netcmd: domain: fix claims constant name was wrong should be claim type CN

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
11 months agonetcmd: domain: fix attributes created by test setUp method
Rob van der Linde [Tue, 16 May 2023 00:33:50 +0000 (12:33 +1200)]
netcmd: domain: fix attributes created by test setUp method

Discovered this while converting the claims cli commands to use the
models, some tests failed.

The reason for this was that they relied on the attributes in the list
ATTRIBUTES to exist.

However, then we have to also prefix the attributes we create in the
test_claim_type_create test.

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>