samba.git
7 months agos4:kdc: Call samba_kdc_get_user_info_dc() to get client information
Joseph Sutton [Tue, 10 Oct 2023 02:19:47 +0000 (15:19 +1300)]
s4:kdc: Call samba_kdc_get_user_info_dc() to get client information

Among other things, this function can deal with RODC‐issued PACs.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Add comment regarding RODC‐issued evidence tickets for constrained delegation
Joseph Sutton [Tue, 10 Oct 2023 02:16:24 +0000 (15:16 +1300)]
s4:kdc: Add comment regarding RODC‐issued evidence tickets for constrained delegation

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Factor creation of user_info_dc out of samba_kdc_check_s4u2proxy_rbcd() into...
Joseph Sutton [Tue, 10 Oct 2023 02:12:30 +0000 (15:12 +1300)]
s4:kdc: Factor creation of user_info_dc out of samba_kdc_check_s4u2proxy_rbcd() into its callers

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Adapt interface to new Heimdal revision
Joseph Sutton [Tue, 10 Oct 2023 02:03:22 +0000 (15:03 +1300)]
s4:kdc: Adapt interface to new Heimdal revision

NOTE: This commit finally works again!

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agothird_party/heimdal: import lorikeet-heimdal-202310092248 (commit cd12cddd8058d9fe627...
Andrew Bartlett [Thu, 12 Oct 2023 22:14:55 +0000 (11:14 +1300)]
third_party/heimdal: import lorikeet-heimdal-202310092248 (commit cd12cddd8058d9fe627b5b203e471b8d761dcfbb)

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
7 months agothird_party/heimdal: Fix PKINIT freshness token memory handling (Import lorikeet...
Joseph Sutton [Mon, 9 Oct 2023 22:59:34 +0000 (11:59 +1300)]
third_party/heimdal: Fix PKINIT freshness token memory handling (Import lorikeet-heimdal-202310092148 (commit 38aa80e35b6b1e16b081fa9c005c03b1e6994204))

The issue here is that only the size of the pointer, not the size
of the struture was allocated with calloc().

This means that the malloc() for the freshness token bytes would
have the memory address written beyond the end of the allocated memory.

Additionally, the allocation was not free()ed, resulting in a memory
leak.  This means that a user could trigger ongoing memory allocation
in the server.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Use claims and device info to evaluate server authentication policy
Joseph Sutton [Mon, 9 Oct 2023 06:35:10 +0000 (19:35 +1300)]
s4:kdc: Use claims and device info to evaluate server authentication policy

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Make samba_kdc_get_user_info_dc() non‐static
Joseph Sutton [Mon, 9 Oct 2023 06:37:08 +0000 (19:37 +1300)]
s4:kdc: Make samba_kdc_get_user_info_dc() non‐static

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Use ‘claims_data’ functions to create client claims blob
Joseph Sutton [Mon, 9 Oct 2023 06:32:24 +0000 (19:32 +1300)]
s4:kdc: Use ‘claims_data’ functions to create client claims blob

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Use device claims to evaluate client authentication policy
Joseph Sutton [Mon, 9 Oct 2023 06:27:59 +0000 (19:27 +1300)]
s4:kdc: Use device claims to evaluate client authentication policy

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Use claims and device info to evaluate server authentication policy
Joseph Sutton [Mon, 9 Oct 2023 06:00:09 +0000 (19:00 +1300)]
s4:kdc: Use claims and device info to evaluate server authentication policy

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Have samba_kdc_allowed_to_authenticate_to() take claims and device info
Joseph Sutton [Mon, 9 Oct 2023 05:19:36 +0000 (18:19 +1300)]
s4:kdc: Have samba_kdc_allowed_to_authenticate_to() take claims and device info

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Fetch device claims for server restrictions
Joseph Sutton [Mon, 9 Oct 2023 02:50:19 +0000 (15:50 +1300)]
s4:kdc: Fetch device claims for server restrictions

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Do not perform compound authentication for services without Compound Identity...
Joseph Sutton [Mon, 9 Oct 2023 01:19:13 +0000 (14:19 +1300)]
s4:kdc: Do not perform compound authentication for services without Compound Identity support

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agotests/krb5: Correctly test services that do not support Compound Identity
Joseph Sutton [Mon, 9 Oct 2023 01:08:43 +0000 (14:08 +1300)]
tests/krb5: Correctly test services that do not support Compound Identity

These two tests now pass against Windows.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Make samba_kdc_add_compounded_auth() static
Joseph Sutton [Mon, 9 Oct 2023 02:24:57 +0000 (15:24 +1300)]
s4:kdc: Make samba_kdc_add_compounded_auth() static

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Remove ‘compounded_auth’ parameter from samba_kdc_add_compounded_auth()
Joseph Sutton [Mon, 9 Oct 2023 02:24:06 +0000 (15:24 +1300)]
s4:kdc: Remove ‘compounded_auth’ parameter from samba_kdc_add_compounded_auth()

It’s only ever equal to SAMBA_COMPOUNDED_AUTH_INCLUDE.

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Change the type of ‘compounded_auth’ to boolean
Andrew Bartlett [Wed, 11 Oct 2023 04:25:48 +0000 (17:25 +1300)]
s4:kdc: Change the type of ‘compounded_auth’ to boolean

View with ‘git show -b’.

This allows us to make the call to authsam_shallow_copy_user_info_dc()
and samba_kdc_add_compounded_auth() only if required.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Remove ‘claims_valid’ parameter from samba_kdc_add_claims_valid()
Joseph Sutton [Mon, 9 Oct 2023 02:19:01 +0000 (15:19 +1300)]
s4:kdc: Remove ‘claims_valid’ parameter from samba_kdc_add_claims_valid()

It’s only ever equal to SAMBA_CLAIMS_VALID_INCLUDE.

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Introduce helper variable ‘server_restrictions_present’
Joseph Sutton [Mon, 9 Oct 2023 00:41:59 +0000 (13:41 +1300)]
s4:kdc: Introduce helper variable ‘server_restrictions_present’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Simplify creation of device claims blob
Joseph Sutton [Thu, 5 Oct 2023 03:39:47 +0000 (16:39 +1300)]
s4:kdc: Simplify creation of device claims blob

Let samba_kdc_get_claims_data() and claims_data_encoded_claims_set()
handle the work for us.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Note use of parent memory context
Joseph Sutton [Thu, 5 Oct 2023 03:35:52 +0000 (16:35 +1300)]
s4:kdc: Note use of parent memory context

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Simplify samba_kdc_check_device() by calling samba_kdc_get_user_info_dc()
Joseph Sutton [Thu, 5 Oct 2023 03:11:57 +0000 (16:11 +1300)]
s4:kdc: Simplify samba_kdc_check_device() by calling samba_kdc_get_user_info_dc()

The latter function accomplishes most of what we were doing ourselves.

No intended change in behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Create the Requester SID blob only if we actually need it
Joseph Sutton [Thu, 5 Oct 2023 03:07:55 +0000 (16:07 +1300)]
s4:kdc: Create the Requester SID blob only if we actually need it

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Remove unused function get_claims_blob_for_principal()
Joseph Sutton [Thu, 5 Oct 2023 02:34:55 +0000 (15:34 +1300)]
s4:kdc: Remove unused function get_claims_blob_for_principal()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Modify samba_kdc_get_claims_blob() to use claims_data functions
Joseph Sutton [Thu, 5 Oct 2023 02:34:41 +0000 (15:34 +1300)]
s4:kdc: Modify samba_kdc_get_claims_blob() to use claims_data functions

The chief advantage of these functions is that the claims got from the
database are retained in the ‘samba_kdc_entry’ object, allowing them to
be reused should they be needed later during the same request.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Add functions to fetch claims from the DB or from the PAC
Joseph Sutton [Thu, 5 Oct 2023 02:33:42 +0000 (15:33 +1300)]
s4:kdc: Add functions to fetch claims from the DB or from the PAC

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:auth: Explicitly initialize claims structures
Joseph Sutton [Thu, 5 Oct 2023 00:43:54 +0000 (13:43 +1300)]
s4:auth: Explicitly initialize claims structures

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:auth: Have claims_data_encoded_claims_set() return a reference to the encoded...
Joseph Sutton [Thu, 5 Oct 2023 02:11:42 +0000 (15:11 +1300)]
s4:auth: Have claims_data_encoded_claims_set() return a reference to the encoded claims

Having the lifetime of the encoded claims be tied in a predictable
fashion to a caller‐controlled memory context is less prone to error.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Declare ‘auth_entry’ to be of type ‘samba_kdc_entry_pac’
Joseph Sutton [Wed, 4 Oct 2023 22:07:48 +0000 (11:07 +1300)]
s4:kdc: Declare ‘auth_entry’ to be of type ‘samba_kdc_entry_pac’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename samba_kdc_obtain_user_info_dc() to samba_kdc_get_user_info_dc()
Joseph Sutton [Mon, 2 Oct 2023 23:57:45 +0000 (12:57 +1300)]
s4:kdc: Rename samba_kdc_obtain_user_info_dc() to samba_kdc_get_user_info_dc()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Cache user info and resource groups from PACs
Joseph Sutton [Wed, 4 Oct 2023 04:19:31 +0000 (17:19 +1300)]
s4:kdc: Cache user info and resource groups from PACs

When authentication policies are implemented, we shall need to fetch
SIDs (and claims) from the PACs of users and devices repeatedly — not
just when first looking up a user, but every time a policy needs to be
evaluated.

This will likely be more efficient if we can cache this information,
removing the need to derive it more than once.

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4-kdc: Do not modify the returned user_info_dc from samba_kdc_get_user_info_dc()
Andrew Bartlett [Wed, 11 Oct 2023 04:07:02 +0000 (17:07 +1300)]
s4-kdc: Do not modify the returned user_info_dc from samba_kdc_get_user_info_dc()

We have the duplicated shallow copy in each caller so that the caller is
clear on what memory can be changed.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
7 months agos4:kdc: Always fetch resource groups
Joseph Sutton [Wed, 4 Oct 2023 04:10:35 +0000 (17:10 +1300)]
s4:kdc: Always fetch resource groups

No behaviour change, and if the caller doesn’t need the resource groups
after all, the cost incurred is little more than the allocation of a
couple of dozen bytes of memory.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Label ‘resource_groups_out’ parameter
Joseph Sutton [Wed, 4 Oct 2023 03:38:28 +0000 (16:38 +1300)]
s4:kdc: Label ‘resource_groups_out’ parameter

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Remove ‘group_inclusion’ parameter from samba_kdc_obtain_user_info_dc()
Joseph Sutton [Wed, 4 Oct 2023 03:31:41 +0000 (16:31 +1300)]
s4:kdc: Remove ‘group_inclusion’ parameter from samba_kdc_obtain_user_info_dc()

It could be equal only to AUTH_EXCLUDE_RESOURCE_GROUPS.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Pass AUTH_EXCLUDE_RESOURCE_GROUPS into samba_kdc_obtain_user_info_dc()
Joseph Sutton [Wed, 4 Oct 2023 03:23:12 +0000 (16:23 +1300)]
s4:kdc: Pass AUTH_EXCLUDE_RESOURCE_GROUPS into samba_kdc_obtain_user_info_dc()

As the ‘group_inclusion’ parameter has an effect only if the
‘resource_groups_out’ parameter is non‐NULL, this does not result in a
change in behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Pass resource groups parameter only if we are creating a TGT
Joseph Sutton [Tue, 3 Oct 2023 21:35:14 +0000 (10:35 +1300)]
s4:kdc: Pass resource groups parameter only if we are creating a TGT

No change in behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Make ‘resource_groups_out’ parameter const
Joseph Sutton [Tue, 3 Oct 2023 07:08:03 +0000 (20:08 +1300)]
s4:kdc: Make ‘resource_groups_out’ parameter const

The caller shouldn’t need to modify this.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Check parameters of samba_kdc_get_user_info_from_pac()
Joseph Sutton [Tue, 3 Oct 2023 07:06:29 +0000 (20:06 +1300)]
s4:kdc: Check parameters of samba_kdc_get_user_info_from_pac()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Simplify memory management with talloc stackframe
Joseph Sutton [Tue, 3 Oct 2023 07:04:44 +0000 (20:04 +1300)]
s4:kdc: Simplify memory management with talloc stackframe

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Remove common out path from samba_kdc_obtain_user_info_dc()
Joseph Sutton [Tue, 3 Oct 2023 06:27:20 +0000 (19:27 +1300)]
s4:kdc: Remove common out path from samba_kdc_obtain_user_info_dc()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Split samba_kdc_get_user_info_from_pac() out of samba_kdc_obtain_user_info_dc()
Joseph Sutton [Tue, 3 Oct 2023 05:45:17 +0000 (18:45 +1300)]
s4:kdc: Split samba_kdc_get_user_info_from_pac() out of samba_kdc_obtain_user_info_dc()

View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename variable ‘user_info_dc’ to ‘info’
Joseph Sutton [Tue, 3 Oct 2023 06:44:41 +0000 (19:44 +1300)]
s4:kdc: Rename variable ‘user_info_dc’ to ‘info’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename parameter ‘user_info_dc_out’ to ‘info_out’
Joseph Sutton [Tue, 3 Oct 2023 06:43:21 +0000 (19:43 +1300)]
s4:kdc: Rename parameter ‘user_info_dc_out’ to ‘info_out’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Fix leak
Joseph Sutton [Tue, 3 Oct 2023 05:45:14 +0000 (18:45 +1300)]
s4:kdc: Fix leak

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Introduce intermediate variable ‘resource_groups’
Joseph Sutton [Tue, 3 Oct 2023 05:41:59 +0000 (18:41 +1300)]
s4:kdc: Introduce intermediate variable ‘resource_groups’

No change in behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Initialize out parameter of samba_kdc_get_user_info_from_db()
Joseph Sutton [Tue, 3 Oct 2023 04:01:07 +0000 (17:01 +1300)]
s4:kdc: Initialize out parameter of samba_kdc_get_user_info_from_db()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Check parameters of samba_kdc_get_user_info_from_db()
Joseph Sutton [Tue, 3 Oct 2023 04:00:43 +0000 (17:00 +1300)]
s4:kdc: Check parameters of samba_kdc_get_user_info_from_db()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename local variable ‘user_info_dc’ to ‘info’
Joseph Sutton [Tue, 3 Oct 2023 02:35:27 +0000 (15:35 +1300)]
s4:kdc: Rename local variable ‘user_info_dc’ to ‘info’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Pass ‘samdb’ into samba_kdc_get_user_info_from_db()
Joseph Sutton [Tue, 3 Oct 2023 01:53:17 +0000 (14:53 +1300)]
s4:kdc: Pass ‘samdb’ into samba_kdc_get_user_info_from_db()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Add ‘samdb’ parameter to samba_kdc_get_device_info_blob()
Joseph Sutton [Tue, 3 Oct 2023 01:58:52 +0000 (14:58 +1300)]
s4:kdc: Add ‘samdb’ parameter to samba_kdc_get_device_info_blob()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Add ‘samdb’ parameter to samba_kdc_verify_pac()
Joseph Sutton [Tue, 3 Oct 2023 01:58:10 +0000 (14:58 +1300)]
s4:kdc: Add ‘samdb’ parameter to samba_kdc_verify_pac()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Make boolean members into bit‐fields
Joseph Sutton [Tue, 3 Oct 2023 01:33:48 +0000 (14:33 +1300)]
s4:kdc: Make boolean members into bit‐fields

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Modify samba_kdc_get_user_info_from_db() to return a Kerberos error code
Joseph Sutton [Tue, 3 Oct 2023 00:39:48 +0000 (13:39 +1300)]
s4:kdc: Modify samba_kdc_get_user_info_from_db() to return a Kerberos error code

instead of an NT status code.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Pass Kerberos context into samba_kdc_get_device_info_blob()
Joseph Sutton [Tue, 3 Oct 2023 00:48:11 +0000 (13:48 +1300)]
s4:kdc: Pass Kerberos context into samba_kdc_get_device_info_blob()

We shall need it in order to produce an error string.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename samba_kdc_entry::user_info_dc to samba_kdc_entry::info_from_db
Joseph Sutton [Mon, 2 Oct 2023 23:33:25 +0000 (12:33 +1300)]
s4:kdc: Rename samba_kdc_entry::user_info_dc to samba_kdc_entry::info_from_db

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename samba_kdc_get_user_info_dc() to samba_kdc_get_user_info_from_db()
Joseph Sutton [Mon, 2 Oct 2023 23:32:13 +0000 (12:32 +1300)]
s4:kdc: Rename samba_kdc_get_user_info_dc() to samba_kdc_get_user_info_from_db()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Inline samba_kdc_get_user_info_from_db() into its only caller
Joseph Sutton [Mon, 2 Oct 2023 23:28:58 +0000 (12:28 +1300)]
s4:kdc: Inline samba_kdc_get_user_info_from_db() into its only caller

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Replace calls to samba_kdc_get_user_info_from_db() with calls to samba_kdc_ge...
Joseph Sutton [Mon, 2 Oct 2023 22:58:05 +0000 (11:58 +1300)]
s4:kdc: Replace calls to samba_kdc_get_user_info_from_db() with calls to samba_kdc_get_user_info_dc()

The latter function behaves identically, except that it makes a shallow
copy of the returned structure, thus avoiding lifetime issues.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Add ‘msg’ parameter to samba_kdc_get_user_info_dc()
Joseph Sutton [Mon, 2 Oct 2023 22:14:30 +0000 (11:14 +1300)]
s4:kdc: Add ‘msg’ parameter to samba_kdc_get_user_info_dc()

We want to call this function from more places. But some potential
callers, found in db-glue.c, have only a partially‐initialized
‘samba_kdc_entry’ structure, without the crucial ‘msg’ member. These
callers need to be able to pass in the ldb message as a separate
parameter.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename ‘user_info_dc_out’ parameter of samba_kdc_get_user_info_dc() to ‘info_out’
Joseph Sutton [Tue, 3 Oct 2023 02:07:55 +0000 (15:07 +1300)]
s4:kdc: Rename ‘user_info_dc_out’ parameter of samba_kdc_get_user_info_dc() to ‘info_out’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename ‘skdc_entry’ parameter of samba_kdc_get_user_info_dc() to ‘entry’
Joseph Sutton [Tue, 3 Oct 2023 02:07:18 +0000 (15:07 +1300)]
s4:kdc: Rename ‘skdc_entry’ parameter of samba_kdc_get_user_info_dc() to ‘entry’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename ‘user_info_dc’ parameter of samba_kdc_get_user_info_from_db() to ...
Joseph Sutton [Tue, 3 Oct 2023 02:05:08 +0000 (15:05 +1300)]
s4:kdc: Rename ‘user_info_dc’ parameter of samba_kdc_get_user_info_from_db() to ‘info_out’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agos4:kdc: Rename ‘skdc_entry’ parameter of samba_kdc_get_user_info_from_db() to ‘entry’
Joseph Sutton [Tue, 3 Oct 2023 02:03:23 +0000 (15:03 +1300)]
s4:kdc: Rename ‘skdc_entry’ parameter of samba_kdc_get_user_info_from_db() to ‘entry’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agolibcli/security: Initialize conditional ACE token
Joseph Sutton [Tue, 10 Oct 2023 01:35:07 +0000 (14:35 +1300)]
libcli/security: Initialize conditional ACE token

If the ‘flags’ member is not initialized, we invoke undefined behaviour
when trying to push or evaluate the parsed conditional ACE.

One way this issue can manifest is in the mysterious failure of Unicode
comparisons owing to the CLAIM_SECURITY_ATTRIBUTE_VALUE_CASE_SENSITIVE
flag being set when it shouldn’t.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
7 months agolibsmb: Use cli_smb2_qpathinfo_send() for SMB_QUERY_FILE_ALT_NAME_INFO
Volker Lendecke [Fri, 30 Jun 2023 21:21:13 +0000 (23:21 +0200)]
libsmb: Use cli_smb2_qpathinfo_send() for SMB_QUERY_FILE_ALT_NAME_INFO

Remove one sync-only wrapper

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Oct 12 17:51:44 UTC 2023 on atb-devel-224

7 months agoexamples: Enable posix for teststat
Volker Lendecke [Thu, 14 Sep 2023 11:45:04 +0000 (13:45 +0200)]
examples: Enable posix for teststat

Show that we can properly detect non-regular files created by the
Windows NFS server. Tested manually against Windows 2022.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmbclient: Read the file type from the server with posix enabled
Volker Lendecke [Wed, 23 Aug 2023 14:04:00 +0000 (16:04 +0200)]
libsmbclient: Read the file type from the server with posix enabled

This does not really request posix extensions, but it depends on them
being activated because it changes behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmbclient: Add smbc_[gs]etOptionPosixExtensions()
Volker Lendecke [Wed, 16 Aug 2023 07:13:50 +0000 (09:13 +0200)]
libsmbclient: Add smbc_[gs]etOptionPosixExtensions()

This is an obvious part of MR2888, not used anywhere yet. It will
eventually result in us requesting SMB311 posix semantics, but for now
it will just allow to change behaviour of libsmbclient that could
break unsuspecting applications.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmb: Parse reparse tag in query_directory response
Volker Lendecke [Mon, 2 Jan 2023 13:28:44 +0000 (14:28 +0100)]
libsmb: Parse reparse tag in query_directory response

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmb: Query reparse tag in cli_qpathinfo2
Volker Lendecke [Wed, 23 Aug 2023 13:07:29 +0000 (15:07 +0200)]
libsmb: Query reparse tag in cli_qpathinfo2

Convert what we find to a file type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmb: Add placeholder "mode" parameter to cli_qpathinfo2()
Volker Lendecke [Wed, 23 Aug 2023 11:47:20 +0000 (13:47 +0200)]
libsmb: Add placeholder "mode" parameter to cli_qpathinfo2()

Unused so far: Patch stripped out to not clutter the real patches that
follow.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agoexamples: Print file type as part of teststat
Volker Lendecke [Mon, 14 Aug 2023 15:30:24 +0000 (17:30 +0200)]
examples: Print file type as part of teststat

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agolibsmb: Ask for posix semantics if requested
Volker Lendecke [Tue, 19 Sep 2023 19:29:11 +0000 (12:29 -0700)]
libsmb: Ask for posix semantics if requested

This is so far only for the getattr-style smb311 calls to request
case-sensitive semantics when "posix" was requested over smb311.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbclient: Always ask for SMB311 posix in negprot
Volker Lendecke [Tue, 19 Sep 2023 18:55:32 +0000 (11:55 -0700)]
smbclient: Always ask for SMB311 posix in negprot

This does not mean that we're actually using it (yet). We just probe
whether the server is willing to do it.

Enable the posix cli command for smb311 posix extensions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agos3:winbindd: Call winbind_add_failed_connection_entry() for the correct dc name
Pavel Filipenský [Mon, 18 Sep 2023 09:16:39 +0000 (11:16 +0200)]
s3:winbindd: Call winbind_add_failed_connection_entry() for the correct dc name

We were calling winbind_add_failed_connection_entry() for saf_servername
which is NULL.  domain->dcname should be used instead.

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Wed Oct 11 16:42:15 UTC 2023 on atb-devel-224

8 months agos3:winbindd: Skip check_negative_conn_cache() if saf_servername == NULL
Pavel Filipenský [Mon, 18 Sep 2023 09:15:21 +0000 (11:15 +0200)]
s3:winbindd: Skip check_negative_conn_cache() if saf_servername == NULL

saf_servername can be NULL even after calling saf_fetch().  Avoid
calling check_negative_conn_cache() like it was before commit 0fcf0012

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agogitlab-ci: run samba-codecheck on ubuntu22.04
Stefan Metzmacher [Wed, 11 Oct 2023 10:15:42 +0000 (10:15 +0000)]
gitlab-ci: run samba-codecheck on ubuntu22.04

There's no reason to run it on fedora38
and it makes sure autobuild and gitlab-ci use the same.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Oct 11 12:52:57 UTC 2023 on atb-devel-224

8 months agobootstrap: install codespell, shfmt and shellcheck also on debian/ubuntu
Stefan Metzmacher [Wed, 11 Oct 2023 10:15:42 +0000 (10:15 +0000)]
bootstrap: install codespell, shfmt and shellcheck also on debian/ubuntu

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months ago.codespellignore: adjust in order to pass on ubuntu 22.04
Stefan Metzmacher [Wed, 11 Oct 2023 09:47:09 +0000 (09:47 +0000)]
.codespellignore: adjust in order to pass on ubuntu 22.04

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
8 months agos4:torture/smb2: fix typo in acls.c
Ralph Boehme [Wed, 11 Oct 2023 09:17:07 +0000 (11:17 +0200)]
s4:torture/smb2: fix typo in acls.c

This fixes the failing samba-codecheck CI job and is not part of the functional
security fix.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
8 months agolibcli: Make debug_unix_user_token() use just one DEBUG statement
Volker Lendecke [Wed, 30 Aug 2023 11:02:02 +0000 (13:02 +0200)]
libcli: Make debug_unix_user_token() use just one DEBUG statement

This avoids messing up the debug logs when multiple processes are
writing into the same file.

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): Wed Oct 11 00:24:58 UTC 2023 on atb-devel-224

8 months agolibcli: Make security_token_debug() use just one DEBUG statement
Volker Lendecke [Wed, 30 Aug 2023 10:46:18 +0000 (12:46 +0200)]
libcli: Make security_token_debug() use just one DEBUG statement

This avoids messing up the debug logs when multiple processes are
writing into the same file.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agolibcli: Convert security_token_debug_privileges() to talloc_asprintf
Volker Lendecke [Wed, 30 Aug 2023 10:39:00 +0000 (12:39 +0200)]
libcli: Convert security_token_debug_privileges() to talloc_asprintf

Reduces the number of DEBUGADD calls which leads to messed debug logs
between processes.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: is_in_path() deals with a NULL namelist
Volker Lendecke [Fri, 1 Sep 2023 11:21:09 +0000 (13:21 +0200)]
smbd: is_in_path() deals with a NULL namelist

Don't need to check in the callers

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Remove a pointless NULL check
Volker Lendecke [Fri, 1 Sep 2023 11:18:14 +0000 (13:18 +0200)]
smbd: Remove a pointless NULL check

boolean short-circuiting already gives us this condition.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Use SMB_VFS_FSTATAT() instead of SMB_LSTAT()
Volker Lendecke [Thu, 31 Aug 2023 14:35:47 +0000 (16:35 +0200)]
smbd: Use SMB_VFS_FSTATAT() instead of SMB_LSTAT()

Use the dirfsp when we have it available

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Fix a typo
Volker Lendecke [Thu, 31 Aug 2023 10:50:09 +0000 (12:50 +0200)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agovfs: Fix a typo
Volker Lendecke [Thu, 31 Aug 2023 10:01:13 +0000 (12:01 +0200)]
vfs: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Modernize two DBG statements
Volker Lendecke [Thu, 31 Aug 2023 09:37:00 +0000 (11:37 +0200)]
smbd: Modernize two DBG statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Reduce indentation, remove a nested if-statement
Volker Lendecke [Thu, 31 Aug 2023 09:33:02 +0000 (11:33 +0200)]
smbd: Reduce indentation, remove a nested if-statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agolibsmb: Remove unused smb2_create_blob_remove()
Volker Lendecke [Thu, 31 Aug 2023 09:23:58 +0000 (11:23 +0200)]
libsmb: Remove unused smb2_create_blob_remove()

Trivial to re-add if needed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agosmbd: Avoid casts in a DBG statement
Volker Lendecke [Thu, 31 Aug 2023 09:17:02 +0000 (11:17 +0200)]
smbd: Avoid casts in a DBG statement

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agorpc_server3: Avoid a pointless DEBUGADD
Volker Lendecke [Wed, 30 Aug 2023 11:32:38 +0000 (13:32 +0200)]
rpc_server3: Avoid a pointless DEBUGADD

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agorpc_server3: Remove a duplicate comment
Volker Lendecke [Wed, 30 Aug 2023 11:28:57 +0000 (13:28 +0200)]
rpc_server3: Remove a duplicate comment

Review with "git sh -U20"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agorpc_netlogon4: Simplify dcesrv_netr_ServerAuthenticate3_helper()
Volker Lendecke [Fri, 6 Oct 2023 06:26:11 +0000 (08:26 +0200)]
rpc_netlogon4: Simplify dcesrv_netr_ServerAuthenticate3_helper()

Use a switch/case statement instead of a if/else chain. Easier to read
to me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agodsdb: Slightly simplify dsdb_trust_get_incoming_passwords()
Volker Lendecke [Fri, 6 Oct 2023 06:00:06 +0000 (08:00 +0200)]
dsdb: Slightly simplify dsdb_trust_get_incoming_passwords()

Use talloc_memdup() instead of a manual copy.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agolsa_srv4: Fix a typo
Volker Lendecke [Fri, 6 Oct 2023 05:52:12 +0000 (07:52 +0200)]
lsa_srv4: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 months agopdb: Slightly simplify pdb_samba_dsdb_set_trusteddom_pw()
Volker Lendecke [Fri, 6 Oct 2023 05:51:27 +0000 (07:51 +0200)]
pdb: Slightly simplify pdb_samba_dsdb_set_trusteddom_pw()

This is easier to read to me.

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