]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
2 years agos3: smbd: Now we have shown dst_dirfsp is always NULL, remove the parameter from...
Jeremy Allison [Tue, 19 Sep 2023 17:03:05 +0000 (10:03 -0700)] 
s3: smbd: Now we have shown dst_dirfsp is always NULL, remove the parameter from rename_internals().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agos3: smbd: As rename_internals() calls rename_internals_fsp(), show we can pass dst_di...
Jeremy Allison [Tue, 19 Sep 2023 16:55:12 +0000 (09:55 -0700)] 
s3: smbd: As rename_internals() calls rename_internals_fsp(), show we can pass dst_dirfsp as NULL here too.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agos3: smbd: Now we've proved dst_dirfsp parameter is always NULL, remove the parameter...
Jeremy Allison [Tue, 19 Sep 2023 16:52:16 +0000 (09:52 -0700)] 
s3: smbd: Now we've proved dst_dirfsp parameter is always NULL, remove the parameter from rename_internals_fsp().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agos3: smbd: rename_internals_fsp() has to reopen the parent directory of the target...
Jeremy Allison [Tue, 19 Sep 2023 16:49:25 +0000 (09:49 -0700)] 
s3: smbd: rename_internals_fsp() has to reopen the parent directory of the target as a pathref to check permissions.

So it never looks at any passed in dst_dirfsp.

Prove this by passing NULL.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agoselftest: add some basic testing for the io_uring vfs module
Stefan Metzmacher [Sat, 16 Sep 2023 18:00:33 +0000 (20:00 +0200)] 
selftest: add some basic testing for the io_uring vfs module

We're now able to build it on all linux systems and
the ci runners have at least a 5.4 kernel. That's
all the current vfs_io_uring requires.

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): Sun Sep 17 18:04:18 UTC 2023 on atb-devel-224

2 years agos3:param: Remove unused lp_set_cmdline()
Andreas Schneider [Tue, 5 Sep 2023 08:06:24 +0000 (10:06 +0200)] 
s3:param: Remove unused lp_set_cmdline()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Sep 14 22:30:06 UTC 2023 on atb-devel-224

2 years agos3:client: Use lpcfg_set_cmdline()
Andreas Schneider [Wed, 2 Aug 2023 07:23:44 +0000 (09:23 +0200)] 
s3:client: Use lpcfg_set_cmdline()

This lp_set_cmdline() leaks memory and we want to get rid of it.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:libsmb: Use lpcfg_set_cmdline()
Pavel Kalugin [Sun, 3 Sep 2023 20:21:35 +0000 (23:21 +0300)] 
s3:libsmb: Use lpcfg_set_cmdline()

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:netapi: Fix a leak in libnetapi_net_init()
Pavel Kalugin [Sun, 20 Aug 2023 20:50:38 +0000 (23:50 +0300)] 
s3:netapi: Fix a leak in libnetapi_net_init()

Allow libnetapi_net_init() to be called more than once without
leaking libnetapi_ctx allocated on a previous call, which is
currently the case in the `net rpc` code.

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibnetapi: Use lpcfg_set_cmdline()
Pavel Kalugin [Sun, 20 Aug 2023 20:06:56 +0000 (23:06 +0300)] 
libnetapi: Use lpcfg_set_cmdline()

Replace lp_set_cmdline() with lpcfg_set_cmdline() in netapi.c.
For this purpose:
1. Add loadparm_context to the libnetapi_ctx because we need it
   in libnetapi_set_debuglevel() and libnetapi_set_logfile().
2. Move loadparm_context creation from libnetapi_net_init()
   to libnetapi_init() and add the lp_ctx parameter to the former.

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:utils: Use lpcfg_set_cmdline() in smbpasswd
Pavel Kalugin [Mon, 14 Aug 2023 03:57:27 +0000 (06:57 +0300)] 
s3:utils: Use lpcfg_set_cmdline() in smbpasswd

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:torture: Use lpcfg_set_cmdline()
Pavel Kalugin [Mon, 14 Aug 2023 03:01:28 +0000 (06:01 +0300)] 
s3:torture: Use lpcfg_set_cmdline()

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:notifyd: Use lpcfg_set_cmdline()
Pavel Kalugin [Mon, 14 Aug 2023 01:37:16 +0000 (04:37 +0300)] 
s3:notifyd: Use lpcfg_set_cmdline()

Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agobuild: Reduce heimdal_no_error_flags to a more minimal set
Andrew Bartlett [Wed, 13 Sep 2023 20:14:55 +0000 (08:14 +1200)] 
build: Reduce heimdal_no_error_flags to a more minimal set

Heimdal does not seem to give as many errors as in the past, so we
can reduce the set of errors we ignore warnings for.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agobuild: Remove -Wno-error=missing-field-initializers from Heimdal build
Andrew Bartlett [Wed, 13 Sep 2023 20:02:50 +0000 (08:02 +1200)] 
build: Remove -Wno-error=missing-field-initializers from Heimdal build

This allows this warning (error) to be used in Samba for cases where a
non-designated initialiser is under-specified.  We can do this now as
the GCC versions we build on do not regard foo = {} as an error.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:dsdb: Fix comment
Joseph Sutton [Wed, 6 Sep 2023 04:35:03 +0000 (16:35 +1200)] 
s4:dsdb: Fix comment

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:winbindd: Add zero digit to literal
Joseph Sutton [Wed, 6 Sep 2023 04:34:00 +0000 (16:34 +1200)] 
s3:winbindd: Add zero digit to literal

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agodsgetdcname: Remove excess zero digits from literals
Joseph Sutton [Wed, 6 Sep 2023 04:33:03 +0000 (16:33 +1200)] 
dsgetdcname: Remove excess zero digits from literals

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agofsrvp.idl: Remove excess zero digit from literal
Joseph Sutton [Wed, 6 Sep 2023 04:32:31 +0000 (16:32 +1200)] 
fsrvp.idl: Remove excess zero digit from literal

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotests/krb5: Rename ‘client_claims’ to ‘claims_metadata’
Joseph Sutton [Wed, 6 Sep 2023 03:09:00 +0000 (15:09 +1200)] 
tests/krb5: Rename ‘client_claims’ to ‘claims_metadata’

This variable is used not only for client claims, but for device claims
as well.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:net: Check return value of data_blob_talloc()
Joseph Sutton [Wed, 6 Sep 2023 01:32:55 +0000 (13:32 +1200)] 
s3:net: Check return value of data_blob_talloc()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Don’t prepend useless colon to MIT KDC logging messages
Joseph Sutton [Wed, 6 Sep 2023 01:09:24 +0000 (13:09 +1200)] 
s4:kdc: Don’t prepend useless colon to MIT KDC logging messages

If we pass an empty string as the ‘whoami’ parameter, MIT’s logging
facilities will prepend a mysterious colon to the message. Printing
“mitkdc: ” ought at least to be more sensible, and perhaps more closely
to match our behaviour prior to commit
dd8138236bec3635c25e5b482b7a14faa0a9c36b.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:wrepl_server: Correctly read ‘type’ element
Joseph Sutton [Tue, 5 Sep 2023 23:03:02 +0000 (11:03 +1200)] 
s4:wrepl_server: Correctly read ‘type’ element

winsdb_message() stores this element as hexadecimal, which format
ldb_msg_find_attr_as_uint() cannot cope with. Permit this element to be
in either decimal or hexadecimal format.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoldb: Prefer explicit initialization to ZERO_STRUCT()
Joseph Sutton [Tue, 5 Sep 2023 22:54:25 +0000 (10:54 +1200)] 
ldb: Prefer explicit initialization to ZERO_STRUCT()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Remove ks_is_tgs_principal()
Joseph Sutton [Tue, 5 Sep 2023 05:06:00 +0000 (17:06 +1200)] 
s4:kdc: Remove ks_is_tgs_principal()

This function is a near‐duplicate of smb_krb5_principal_is_tgs().

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agotestprogs: Fix script usage lines
Joseph Sutton [Tue, 5 Sep 2023 04:22:01 +0000 (16:22 +1200)] 
testprogs: Fix script usage lines

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:setup: Fix script usage line
Joseph Sutton [Tue, 5 Sep 2023 04:21:50 +0000 (16:21 +1200)] 
s4:setup: Fix script usage line

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:selftest: Fix script usage lines
Joseph Sutton [Tue, 5 Sep 2023 04:21:34 +0000 (16:21 +1200)] 
s4:selftest: Fix script usage lines

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:script: Fix script usage lines
Joseph Sutton [Tue, 5 Sep 2023 04:21:19 +0000 (16:21 +1200)] 
s3:script: Fix script usage lines

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agonsswitch: Fix script usage
Joseph Sutton [Tue, 5 Sep 2023 04:20:53 +0000 (16:20 +1200)] 
nsswitch: Fix script usage

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:krb5_wrap: Remove Heimdal‐only krb5_princ_component() implementation
Joseph Sutton [Tue, 5 Sep 2023 03:37:14 +0000 (15:37 +1200)] 
lib:krb5_wrap: Remove Heimdal‐only krb5_princ_component() implementation

This implementation is no longer called: using a variable of static
storage duration as a conduit for return values is only asking for
trouble.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:rpc_server: Switch to using smb_krb5_princ_component()
Joseph Sutton [Tue, 5 Sep 2023 04:46:17 +0000 (16:46 +1200)] 
s4:rpc_server: Switch to using smb_krb5_princ_component()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Switch to using smb_krb5_princ_component()
Joseph Sutton [Tue, 5 Sep 2023 04:46:08 +0000 (16:46 +1200)] 
s4:kdc: Switch to using smb_krb5_princ_component()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Switch to using smb_krb5_princ_component()
Joseph Sutton [Tue, 5 Sep 2023 04:38:23 +0000 (16:38 +1200)] 
s4:dsdb: Switch to using smb_krb5_princ_component()

This function has the handy feature of being able to be called twice in
succession without mysteriously breaking your code. Now, doesn’t that
sound useful?

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:krb5_wrap: Add Heimdal‐specific smb_krb5_princ_component() implementation
Joseph Sutton [Tue, 5 Sep 2023 03:07:05 +0000 (15:07 +1200)] 
lib:krb5_wrap: Add Heimdal‐specific smb_krb5_princ_component() implementation

This implementation doesn’t rely on a variable of static storage
duration being used as a conduit for the return value.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:krb5_wrap: Add smb_krb5_princ_component()
Joseph Sutton [Tue, 5 Sep 2023 02:52:02 +0000 (14:52 +1200)] 
lib:krb5_wrap: Add smb_krb5_princ_component()

For now this function is a mere wrapper round krb5_princ_component(),
but one whose interface allows for a more sensible implementation.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:krb5_wrap: Have smb_krb5_principal_get_realm() check the return values of interme...
Joseph Sutton [Tue, 5 Sep 2023 03:47:06 +0000 (15:47 +1200)] 
lib:krb5_wrap: Have smb_krb5_principal_get_realm() check the return values of intermediate functions

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:krb5_wrap: Eliminate redundant code from smb_krb5_sockaddr_to_kaddr()
Joseph Sutton [Tue, 5 Sep 2023 03:27:29 +0000 (15:27 +1200)] 
lib:krb5_wrap: Eliminate redundant code from smb_krb5_sockaddr_to_kaddr()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix leaks
Joseph Sutton [Tue, 5 Sep 2023 02:23:10 +0000 (14:23 +1200)] 
s4:kdc: Fix leaks

Create a temporary memory context on which to allocate things.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Be sure not to pass a NULL pointer into strcmp()
Joseph Sutton [Tue, 5 Sep 2023 02:17:36 +0000 (14:17 +1200)] 
s4:kdc: Be sure not to pass a NULL pointer into strcmp()

To do so is to invoke undefined behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Prefer explicit initialization to ZERO_STRUCTP()
Joseph Sutton [Tue, 5 Sep 2023 02:17:14 +0000 (14:17 +1200)] 
s4:kdc: Prefer explicit initialization to ZERO_STRUCTP()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Make RODC ID checks easier to understand with more clearly‐named variables
Joseph Sutton [Tue, 5 Sep 2023 02:15:11 +0000 (14:15 +1200)] 
s4:kdc: Make RODC ID checks easier to understand with more clearly‐named variables

No change in behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Rename ‘status’ variables to ‘reply_status’
Joseph Sutton [Tue, 5 Sep 2023 02:08:25 +0000 (14:08 +1200)] 
s4:kdc: Rename ‘status’ variables to ‘reply_status’

This makes it clearer what these variables are used for, and avoids
confusion with the similarly‐named ‘nt_status’ variables — also used in
these functions.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Have samba_krbtgt_is_in_db() take a const KDC entry
Joseph Sutton [Tue, 5 Sep 2023 02:04:47 +0000 (14:04 +1200)] 
s4:kdc: Have samba_krbtgt_is_in_db() take a const KDC entry

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Have samba_krbtgt_is_in_db() return a krb5_error_code
Joseph Sutton [Tue, 5 Sep 2023 02:04:17 +0000 (14:04 +1200)] 
s4:kdc: Have samba_krbtgt_is_in_db() return a krb5_error_code

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Make pac_blobs_remove_blob() never fail
Joseph Sutton [Tue, 5 Sep 2023 00:55:04 +0000 (12:55 +1200)] 
s4:kdc: Make pac_blobs_remove_blob() never fail

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Make ‘struct pac_blobs’ memory handling safer and more consistent
Joseph Sutton [Tue, 5 Sep 2023 01:23:35 +0000 (13:23 +1200)] 
s4:kdc: Make ‘struct pac_blobs’ memory handling safer and more consistent

Having pac_blobs::type_blobs be managed both by talloc and by the
‘pac_blobs’ structure itself (with pac_blobs_destroy()) is very prone to
error. So is the current situation of having the other ‘pac_blobs’
functions each take in a memory context.

Improve these circumstances by requiring ‘pac_blobs’ to be managed by
talloc. Now the other functions can dispense with their ‘mem_ctx’
parameters, being instead able to allocate on to the ‘pac_blobs’
structure itself. pac_blobs_init() no longer must be a separate
function; inline it into pac_blobs_from_krb5_pac(). pac_blobs_destroy(),
being no longer of use, can go too.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Don’t corrupt pac_blobs structure if talloc_realloc() fails
Joseph Sutton [Tue, 5 Sep 2023 01:04:50 +0000 (13:04 +1200)] 
s4:kdc: Don’t corrupt pac_blobs structure if talloc_realloc() fails

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Add common out path to pac_blobs_from_krb5_pac()
Joseph Sutton [Tue, 5 Sep 2023 01:02:59 +0000 (13:02 +1200)] 
s4:kdc: Add common out path to pac_blobs_from_krb5_pac()

This helps to make error‐checking and cleanup more systematic.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Introduce a temporary talloc context in samba_kdc_update_pac()
Joseph Sutton [Tue, 5 Sep 2023 00:44:54 +0000 (12:44 +1200)] 
s4:kdc: Introduce a temporary talloc context in samba_kdc_update_pac()

This avoids allocating working structures on to a potentially long‐lived
context.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Use temporary memory context in samba_kdc_verify_pac()
Joseph Sutton [Tue, 5 Sep 2023 00:35:27 +0000 (12:35 +1200)] 
s4:kdc: Use temporary memory context in samba_kdc_verify_pac()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix leak
Joseph Sutton [Tue, 5 Sep 2023 00:28:55 +0000 (12:28 +1200)] 
s4:kdc: Fix leak

Introduce a temporary memory context and allocate working structures on
to it.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Allocate variables on to more suitable memory context
Joseph Sutton [Tue, 5 Sep 2023 00:20:39 +0000 (12:20 +1200)] 
s4:kdc: Allocate variables on to more suitable memory context

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Increment PAC_DEVICE_INFO::domain_group_count only after SID has been success...
Joseph Sutton [Mon, 4 Sep 2023 23:06:50 +0000 (11:06 +1200)] 
s4:kdc: Increment PAC_DEVICE_INFO::domain_group_count only after SID has been successfully added

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Directly zero‐initialize PAC_DOMAIN_GROUP_MEMBERSHIP structure
Joseph Sutton [Mon, 4 Sep 2023 23:04:59 +0000 (11:04 +1200)] 
s4:kdc: Directly zero‐initialize PAC_DOMAIN_GROUP_MEMBERSHIP structure

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Assign RID and attribute together
Joseph Sutton [Mon, 4 Sep 2023 23:02:37 +0000 (11:02 +1200)] 
s4:kdc: Assign RID and attribute together

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Don’t corrupt domain groups structure if talloc_realloc() fails
Joseph Sutton [Mon, 4 Sep 2023 22:44:55 +0000 (10:44 +1200)] 
s4:kdc: Don’t corrupt domain groups structure if talloc_realloc() fails

Introduce a temporary variable instead of assigning the result of
talloc_realloc() directly to samr_RidWithAttributeArray::rids. In this
way we avoid having a structure with a non‐zero ‘count’ but with ‘rids’
set to the NULL pointer.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Check for overflow when adding a domain group SID
Joseph Sutton [Mon, 4 Sep 2023 22:32:26 +0000 (10:32 +1200)] 
s4:kdc: Check for overflow when adding a domain group SID

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Avoid potential use‐after‐free
Joseph Sutton [Mon, 4 Sep 2023 22:28:02 +0000 (10:28 +1200)] 
s4:kdc: Avoid potential use‐after‐free

We must allocate the domain groups on to the correct memory context,
lest they get freed prematurely.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix leak
Joseph Sutton [Mon, 4 Sep 2023 22:24:43 +0000 (10:24 +1200)] 
s4:kdc: Fix leak

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Use common exit point for functions
Joseph Sutton [Mon, 4 Sep 2023 22:20:04 +0000 (10:20 +1200)] 
s4:kdc: Use common exit point for functions

This makes it less likely that we forget to clean up resources.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix leaks
Joseph Sutton [Mon, 4 Sep 2023 05:00:04 +0000 (17:00 +1200)] 
s4:kdc: Fix leaks

Allocate variables on to a temporary context rather than on to the
potentially long‐lived context passed in by the caller.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Add correct Asserted Identity SID in response to an S4U2Self request
Joseph Sutton [Mon, 4 Sep 2023 01:20:34 +0000 (13:20 +1200)] 
s4:kdc: Add correct Asserted Identity SID in response to an S4U2Self request

I’m not sure exactly how this check was supposed to work. But in any
case, within fast_unwrap_request() the Heimdal KDC replaces the outer
padata with the padata from the inner FAST request. Hence, this check
does not accomplish anything useful: at no point should the KDC plugin
see the outer padata.

A couple of unwanted consequences resulted from this check. One was that
a client who sent empty FX‐FAST padata within the inner FAST request
would receive the *Authentication Authority* Asserted Identity SID
instead of the *Service* Asserted Identity SID. Another consequence was
that a client could in the same manner bypass the restriction on
performing S4U2Self with an RODC‐issued TGT.

Overall, samba_wdc_is_s4u2self_req() is somewhat of a hack. But the
Heimdal plugin API gives us nothing better to work with.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:auth: Fix leaks
Joseph Sutton [Sun, 3 Sep 2023 22:02:41 +0000 (10:02 +1200)] 
s4:auth: Fix leaks

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:auth: Check return values of talloc functions
Joseph Sutton [Sun, 3 Sep 2023 22:02:28 +0000 (10:02 +1200)] 
s4:auth: Check return values of talloc functions

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Prefer explicit initialization to ZERO_STRUCT()
Joseph Sutton [Fri, 1 Sep 2023 01:29:17 +0000 (13:29 +1200)] 
s4:dsdb: Prefer explicit initialization to ZERO_STRUCT()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:dsdb: Parenthesize macro expression
Joseph Sutton [Fri, 1 Sep 2023 01:29:03 +0000 (13:29 +1200)] 
s4:dsdb: Parenthesize macro expression

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:scripting: Prefer ‘x not in y’ to ‘not x in y’
Joseph Sutton [Fri, 1 Sep 2023 01:26:04 +0000 (13:26 +1200)] 
s4:scripting: Prefer ‘x not in y’ to ‘not x in y’

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:scripting: Fix comments
Joseph Sutton [Fri, 1 Sep 2023 01:25:29 +0000 (13:25 +1200)] 
s4:scripting: Fix comments

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Inline samba_get_pac_attrs_blob()
Joseph Sutton [Thu, 31 Aug 2023 00:32:42 +0000 (12:32 +1200)] 
s4:kdc: Inline samba_get_pac_attrs_blob()

A wrapper doesn’t add much utility to a function this small. We might as
well join these two into a single function.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:rpc_server: Fix inverted error messages
Joseph Sutton [Wed, 30 Aug 2023 01:58:18 +0000 (13:58 +1200)] 
s3:rpc_server: Fix inverted error messages

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Fix invalid escape sequence
Joseph Sutton [Tue, 29 Aug 2023 23:58:18 +0000 (11:58 +1200)] 
python:tests: Fix invalid escape sequence

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Remove unused variables
Joseph Sutton [Tue, 29 Aug 2023 23:58:07 +0000 (11:58 +1200)] 
python:tests: Remove unused variables

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agodocs-xml: Add missing paragraph section
Joseph Sutton [Tue, 29 Aug 2023 01:49:18 +0000 (13:49 +1200)] 
docs-xml: Add missing paragraph section

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix leaks
Joseph Sutton [Thu, 24 Aug 2023 23:53:28 +0000 (11:53 +1200)] 
s4:kdc: Fix leaks

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Don’t operate directly on caller‐owned pointer
Joseph Sutton [Thu, 24 Aug 2023 23:49:27 +0000 (11:49 +1200)] 
s4:kdc: Don’t operate directly on caller‐owned pointer

This is more consistent with the other PAC blob functions, and easier to
reason about.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Allocate contents of PAC blobs on blob talloc contexts
Joseph Sutton [Thu, 24 Aug 2023 23:41:39 +0000 (11:41 +1200)] 
s4:kdc: Allocate contents of PAC blobs on blob talloc contexts

The lifetime of a blob’s contents should be tied to the lifetime of the
blob itself.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Inline samba_get_requester_sid_pac_blob()
Joseph Sutton [Thu, 24 Aug 2023 23:35:12 +0000 (11:35 +1200)] 
s4:kdc: Inline samba_get_requester_sid_pac_blob()

A wrapper doesn’t add much utility to a function this small. We might as
well join these two into a single function.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Fix error message
Joseph Sutton [Thu, 7 Sep 2023 21:13:51 +0000 (09:13 +1200)] 
s4:kdc: Fix error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Initialize pointers to NULL
Joseph Sutton [Thu, 24 Aug 2023 23:30:27 +0000 (11:30 +1200)] 
s4:kdc: Initialize pointers to NULL

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Correct error message
Joseph Sutton [Thu, 24 Aug 2023 23:29:24 +0000 (11:29 +1200)] 
s4:kdc: Correct error message

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Check return value of smb_krb5_principal_get_comp_string()
Joseph Sutton [Thu, 24 Aug 2023 23:28:07 +0000 (11:28 +1200)] 
s4:kdc: Check return value of smb_krb5_principal_get_comp_string()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Remove unused talloc context
Joseph Sutton [Thu, 24 Aug 2023 23:18:34 +0000 (11:18 +1200)] 
s4:kdc: Remove unused talloc context

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Check return value of samdb_result_dom_sid()
Joseph Sutton [Thu, 24 Aug 2023 23:17:24 +0000 (11:17 +1200)] 
s4:kdc: Check return value of samdb_result_dom_sid()

We should not pass a NULL pointer into dom_sid_split_rid().

Unlike samdb_result_dom_sid(), samdb_result_dom_sid_buf() produces an
error code on failure and does not require a heap allocation.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoclaims.idl: Be more lenient in our expectations for the compression of claims
Joseph Sutton [Thu, 24 Aug 2023 23:04:32 +0000 (11:04 +1200)] 
claims.idl: Be more lenient in our expectations for the compression of claims

384 bytes is not a strict threshold below which claims are never to be
compressed. Windows has been known to compress claims a mere 368 bytes
in size.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoclaims.idl: Allow empty claim value buffers
Joseph Sutton [Thu, 24 Aug 2023 23:01:09 +0000 (11:01 +1200)] 
claims.idl: Allow empty claim value buffers

Windows doesn’t reject these, nor do we have any reason to do so.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Make functions to add special SIDs non‐static
Joseph Sutton [Mon, 21 Aug 2023 01:55:27 +0000 (13:55 +1200)] 
s4:kdc: Make functions to add special SIDs non‐static

This allows us to call them from elsewhere.

Change their names accordingly to start with ‘samba_kdc_’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Check result of talloc_realloc()
Joseph Sutton [Mon, 21 Aug 2023 01:52:14 +0000 (13:52 +1200)] 
s4:kdc: Check result of talloc_realloc()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Handle invalid enum values
Joseph Sutton [Mon, 21 Aug 2023 01:51:27 +0000 (13:51 +1200)] 
s4:kdc: Handle invalid enum values

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Check result of dom_sid_parse()
Joseph Sutton [Mon, 21 Aug 2023 01:49:38 +0000 (13:49 +1200)] 
s4:kdc: Check result of dom_sid_parse()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Remove unused flags
Joseph Sutton [Mon, 21 Aug 2023 01:46:57 +0000 (13:46 +1200)] 
s4:kdc: Remove unused flags

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Use smb_krb5_data_from_blob()
Joseph Sutton [Fri, 18 Aug 2023 03:00:20 +0000 (15:00 +1200)] 
s4:kdc: Use smb_krb5_data_from_blob()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Remove duplicate function signature
Joseph Sutton [Fri, 18 Aug 2023 03:00:04 +0000 (15:00 +1200)] 
s4:kdc: Remove duplicate function signature

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Prefer explicit initialization to ZERO_STRUCT()
Joseph Sutton [Thu, 7 Sep 2023 04:35:39 +0000 (16:35 +1200)] 
s4:kdc: Prefer explicit initialization to ZERO_STRUCT()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibcli:security: Prefer explicit initialization to ZERO_STRUCTP()
Joseph Sutton [Fri, 18 Aug 2023 00:33:01 +0000 (12:33 +1200)] 
libcli:security: Prefer explicit initialization to ZERO_STRUCTP()

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:scripting: Remove unused imports
Joseph Sutton [Tue, 29 Aug 2023 23:58:34 +0000 (11:58 +1200)] 
s4:scripting: Remove unused imports

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython:tests: Remove unused imports
Joseph Sutton [Wed, 16 Aug 2023 23:10:06 +0000 (11:10 +1200)] 
python:tests: Remove unused imports

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibrpc:ndr: Avoid overflow in size calculation
Joseph Sutton [Tue, 15 Aug 2023 00:38:35 +0000 (12:38 +1200)] 
librpc:ndr: Avoid overflow in size calculation

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolibgpo: Remove unnecessary cast
Joseph Sutton [Wed, 9 Aug 2023 04:52:46 +0000 (16:52 +1200)] 
libgpo: Remove unnecessary cast

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:tdr: Remove unnecessary cast
Joseph Sutton [Wed, 9 Aug 2023 04:51:46 +0000 (16:51 +1200)] 
lib:tdr: Remove unnecessary cast

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