samba.git
2 years agos3:lib: Fix possible 32-bit arithmetic overflow
Pavel Filipenský [Mon, 28 Feb 2022 22:33:22 +0000 (23:33 +0100)]
s3:lib: Fix possible 32-bit arithmetic overflow

Reported by covscan.

Potentially overflowing expression "glue->gtimeout * 1000" with type "int"
(32 bits, signed) is evaluated using 32-bit arithmetic, and then used in
a context that expects an expression of type "uint64_t" (64 bits, unsigned).

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sat Mar  5 08:04:28 UTC 2022 on sn-devel-184

2 years agos3: smbd: Cleanup - Make rmdir_internals() use NTSTATUS internally without depending...
Jeremy Allison [Thu, 3 Mar 2022 17:49:15 +0000 (09:49 -0800)]
s3: smbd: Cleanup - Make rmdir_internals() use NTSTATUS internally without depending on errno.

As we already need to return NTSTATUS, map errno to NTSTATUS directly at point of failure
and don't depend on keeping it around. No change in client-visible behavior but makes
rmdir_internals() easier to understand (for me at least).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Mar  4 18:39:48 UTC 2022 on sn-devel-184

2 years agos3: smbd: Cleanup - make recursive_rmdir() return a more expressive NTSTATUS not...
Jeremy Allison [Thu, 3 Mar 2022 17:34:45 +0000 (09:34 -0800)]
s3: smbd: Cleanup - make recursive_rmdir() return a more expressive NTSTATUS not bool.

Next cleanup the internals of rmdir_internals() to do an early map
of errno -> NTSTATUS to avoid mapping back and forth.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Make complex if-expression in file_set_dosmode() easier to read
Volker Lendecke [Fri, 4 Mar 2022 07:39:01 +0000 (08:39 +0100)]
smbd: Make complex if-expression in file_set_dosmode() easier to read

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Fix indentation in rename_internals_fsp()
Volker Lendecke [Fri, 4 Mar 2022 07:36:04 +0000 (08:36 +0100)]
smbd: Fix indentation in rename_internals_fsp()

This one space character makes it more obvious where in the copmlex
if-expression lp_store_dos_attributes() lives.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Save a few lines in file_set_dosmode() with "goto done;"
Volker Lendecke [Thu, 3 Mar 2022 20:49:47 +0000 (21:49 +0100)]
smbd: Save a few lines in file_set_dosmode() with "goto done;"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Remove unused "lret" variable from file_set_dosmode()
Volker Lendecke [Thu, 3 Mar 2022 20:48:26 +0000 (21:48 +0100)]
smbd: Remove unused "lret" variable from file_set_dosmode()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Pass dirfsp instead of a parent filename to unix_mode
Volker Lendecke [Thu, 3 Mar 2022 10:52:12 +0000 (11:52 +0100)]
smbd: Pass dirfsp instead of a parent filename to unix_mode

This converts a STAT (with potential symlink race problems) into an
FSTAT on the O_PATH fd we have for the directory

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Log close_file_free() failure in copy_internals()
Volker Lendecke [Thu, 3 Mar 2022 19:13:25 +0000 (20:13 +0100)]
smbd: Log close_file_free() failure in copy_internals()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Pass dirfsp instead of an fname to open_file()
Volker Lendecke [Thu, 3 Mar 2022 10:32:20 +0000 (11:32 +0100)]
smbd: Pass dirfsp instead of an fname to open_file()

Moving slowly towards passing directory handles instead of names,
representing the idea that we hold a O_PATH file descriptor on
directories.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Inherit acl from an fsp instead of a fname
Volker Lendecke [Thu, 3 Mar 2022 10:32:20 +0000 (11:32 +0100)]
smbd: Inherit acl from an fsp instead of a fname

Moving slowly towards passing directory handles instead of names,
representing the idea that we hold a O_PATH file descriptor on
directories.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agosmbd: Remove a deref forgotten in c2ac6a9cd7b
Volker Lendecke [Thu, 3 Mar 2022 10:28:57 +0000 (11:28 +0100)]
smbd: Remove a deref forgotten in c2ac6a9cd7b

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2 years agoWHATSNEW: Bronze bit, S4U and RBDC support with MIT Kerberos 1.20
Andreas Schneider [Thu, 13 Jan 2022 07:43:23 +0000 (08:43 +0100)]
WHATSNEW: Bronze bit, S4U and RBDC support with MIT Kerberos 1.20

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Mar  4 14:58:20 UTC 2022 on sn-devel-184

2 years agogitlab-ci: Run krb5 tests also with MIT Kerberos 1.20 (prerelease)
Andreas Schneider [Tue, 18 Jan 2022 10:13:21 +0000 (11:13 +0100)]
gitlab-ci: Run krb5 tests also with MIT Kerberos 1.20 (prerelease)

This adds test against MIT Kerberos 1.20 (prerelease) in order to test
Bronze Bit, S4U and RBCD functionality supported only in current MIT Kerberos
git master. We created a Fedora COPR package for MIT KRB5 1.20 (prerelease).

MIT Kerberos 1.20 will be released in autumn 2022. As soon as MIT Kerberos 1.20
will be in a Fedora release, these runners will be removed again.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agogitlab-ci: Print the krb5 version
Andreas Schneider [Tue, 18 Jan 2022 15:22:41 +0000 (16:22 +0100)]
gitlab-ci: Print the krb5 version

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:mitkdc: Implement support for Resource Based Constrained Delegation (RBCD)
Andreas Schneider [Tue, 7 Dec 2021 15:02:35 +0000 (16:02 +0100)]
s4:mitkdc: Implement support for Resource Based Constrained Delegation (RBCD)

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:mitkdc: Implement mit_samba_check_allowed_to_delegate_from() for RBCD
Andreas Schneider [Tue, 14 Dec 2021 10:17:15 +0000 (11:17 +0100)]
s4:mitkdc: Implement mit_samba_check_allowed_to_delegate_from() for RBCD

This just implements a call in the MIT KDB shim layer. It will be used in the
next commits in the KDB plugin.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:kdc: Implement samba_kdc_check_s4u2proxy_rbcd()
Andreas Schneider [Tue, 14 Dec 2021 10:16:12 +0000 (11:16 +0100)]
s4:kdc: Implement samba_kdc_check_s4u2proxy_rbcd()

This will be used by the MIT KDB plugin in the next commits.

A security descriptor created by Windows looks like this:

    security_descriptor: struct security_descriptor
        revision                 : SECURITY_DESCRIPTOR_REVISION_1 (1)
        type                     : 0x8004 (32772)
               0: SEC_DESC_OWNER_DEFAULTED
               0: SEC_DESC_GROUP_DEFAULTED
               1: SEC_DESC_DACL_PRESENT
               0: SEC_DESC_DACL_DEFAULTED
               0: SEC_DESC_SACL_PRESENT
               0: SEC_DESC_SACL_DEFAULTED
               0: SEC_DESC_DACL_TRUSTED
               0: SEC_DESC_SERVER_SECURITY
               0: SEC_DESC_DACL_AUTO_INHERIT_REQ
               0: SEC_DESC_SACL_AUTO_INHERIT_REQ
               0: SEC_DESC_DACL_AUTO_INHERITED
               0: SEC_DESC_SACL_AUTO_INHERITED
               0: SEC_DESC_DACL_PROTECTED
               0: SEC_DESC_SACL_PROTECTED
               0: SEC_DESC_RM_CONTROL_VALID
               1: SEC_DESC_SELF_RELATIVE
        owner_sid                : *
            owner_sid                : S-1-5-32-544
        group_sid                : NULL
        sacl                     : NULL
        dacl                     : *
            dacl: struct security_acl
                revision                 : SECURITY_ACL_REVISION_ADS (4)
                size                     : 0x002c (44)
                num_aces                 : 0x00000001 (1)
                aces: ARRAY(1)
                    aces: struct security_ace
                        type                     : SEC_ACE_TYPE_ACCESS_ALLOWED (0)
                        flags                    : 0x00 (0)
                               0: SEC_ACE_FLAG_OBJECT_INHERIT
                               0: SEC_ACE_FLAG_CONTAINER_INHERIT
                               0: SEC_ACE_FLAG_NO_PROPAGATE_INHERIT
                               0: SEC_ACE_FLAG_INHERIT_ONLY
                               0: SEC_ACE_FLAG_INHERITED_ACE
                            0x00: SEC_ACE_FLAG_VALID_INHERIT (0)
                               0: SEC_ACE_FLAG_SUCCESSFUL_ACCESS
                               0: SEC_ACE_FLAG_FAILED_ACCESS
                        size                     : 0x0024 (36)
                        access_mask              : 0x000f01ff (983551)
                        object                   : union security_ace_object_ctr(case 0)
                        trustee                  : S-1-5-21-3001743926-1909451141-602466370-1108

Created with the following powershell code:

    $host1 = Get-ADComputer -Identity ServerA
    $host2 = Get-ADComputer -Identity ServerB
    Set-ADComputer $host2 -PrincipalsAllowedToDelegateToAccount $host1

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:auth: Also look up msDS-AllowedToActOnBehalfOfOtherIdentity for RBCD
Andreas Schneider [Wed, 8 Dec 2021 08:19:02 +0000 (09:19 +0100)]
s4:auth: Also look up msDS-AllowedToActOnBehalfOfOtherIdentity for RBCD

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:auth: Remove trailing spaces in sam.c
Andreas Schneider [Wed, 8 Dec 2021 08:18:40 +0000 (09:18 +0100)]
s4:auth: Remove trailing spaces in sam.c

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agokrb5-mit: Enable S4U client support for MIT build
Isaac Boukris [Fri, 27 Sep 2019 15:35:30 +0000 (18:35 +0300)]
krb5-mit: Enable S4U client support for MIT build

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:kdc: Implement new Microsoft forwardable flag behavior
Andreas Schneider [Thu, 9 Dec 2021 06:48:13 +0000 (07:48 +0100)]
s4:kdc: Implement new Microsoft forwardable flag behavior

Allow delegation to any target if we have delegations set up, but the target is
not specified.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:mitkdc: Add support for S4U2Self & S4U2Proxy
Andreas Schneider [Mon, 22 Nov 2021 19:09:31 +0000 (20:09 +0100)]
s4:mitkdc: Add support for S4U2Self & S4U2Proxy

Pair-Programmed-With: Alexander Bokovoy <ab@samba.org>
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:mitkdc: Add support for MIT Kerberos 1.20
Andreas Schneider [Mon, 4 Oct 2021 09:53:55 +0000 (11:53 +0200)]
s4:mitkdc: Add support for MIT Kerberos 1.20

This also addresses CVE-2020-17049.

MIT Kerberos 1.20 is in pre-release state at the time writing this commit. It
will be released in autumn 2022. We need to support MIT Kerberos 1.19 till
enough distributions have been released with MIT Kerberos 1.20.

Pair-Programmed-With: Robbie Harwood <rharwood@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:mitkdc: Set KRB5_KDB_NO_AUTH_DATA_REQUIRED based on sdb no_auth_data_reqd
Andreas Schneider [Mon, 11 Oct 2021 09:55:12 +0000 (11:55 +0200)]
s4:mitkdc: Set KRB5_KDB_NO_AUTH_DATA_REQUIRED based on sdb no_auth_data_reqd

This needs to be set so that the MIT KDC >= 1.20 will not call the handle_pac()
function which executes the issue_pac KDB callback.

Pair-Programmed-With: Alexander Bokovoy <ab@samba.org>
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agoselftest: More tests are passing with MIT KRB5 >= 1.20
Andreas Schneider [Thu, 7 Oct 2021 14:28:26 +0000 (16:28 +0200)]
selftest: More tests are passing with MIT KRB5 >= 1.20

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:kdc: Also cannoicalize krbtgt principals when enforcing canonicalization
Andreas Schneider [Tue, 21 Dec 2021 11:17:11 +0000 (12:17 +0100)]
s4:kdc: Also cannoicalize krbtgt principals when enforcing canonicalization

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:kdc: Align sflags type
Andreas Schneider [Tue, 25 Jan 2022 14:57:07 +0000 (15:57 +0100)]
s4:kdc: Align sflags type

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos3:script: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 13:11:19 +0000 (14:11 +0100)]
s3:script: Reformat shell scripts

shfmt -f source3/script/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Mar  3 01:53:16 UTC 2022 on sn-devel-184

2 years agos3:locale: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 13:10:29 +0000 (14:10 +0100)]
s3:locale: Reformat shell scripts

shfmt -f source3/locale/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoselftest: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 13:06:36 +0000 (14:06 +0100)]
selftest: Reformat shell scripts

shfmt -f selftest/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoscript: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 13:02:15 +0000 (14:02 +0100)]
script: Reformat shell scripts

shfmt -f script/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agorelease-scripts: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 13:00:54 +0000 (14:00 +0100)]
release-scripts: Reformat shell scripts

shfmt -f release-scripts/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agopython: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 12:59:33 +0000 (13:59 +0100)]
python: Reformat shell scripts

shfmt -f python/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3: smbd: Rename OpenDir_ntstatus() -> OpenDir().
Jeremy Allison [Mon, 28 Feb 2022 22:34:48 +0000 (14:34 -0800)]
s3: smbd: Rename OpenDir_ntstatus() -> OpenDir().

We now have a single OpenDir() function that returns an NTSTATUS.

Signed-off-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 Mar  2 21:58:32 UTC 2022 on sn-devel-184

2 years agos3: smbd: Remove now unused OpenDir().
Jeremy Allison [Mon, 28 Feb 2022 22:30:27 +0000 (14:30 -0800)]
s3: smbd: Remove now unused OpenDir().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: torture: In cmd_vfs, Move two more uses of OpenDir() -> OpenDir_nstatus().
Jeremy Allison [Mon, 28 Feb 2022 22:28:19 +0000 (14:28 -0800)]
s3: torture: In cmd_vfs, Move two more uses of OpenDir() -> OpenDir_nstatus().

Now we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: smbd: In form_junctions(), Move one more use of OpenDir() -> OpenDir_nstatus()
Jeremy Allison [Mon, 28 Feb 2022 22:25:25 +0000 (14:25 -0800)]
s3: smbd: In form_junctions(), Move one more use of OpenDir() -> OpenDir_nstatus()

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: smbd: In count_dfs_links(), Move one more use of OpenDir() -> OpenDir_nstatus()
Jeremy Allison [Mon, 28 Feb 2022 22:24:19 +0000 (14:24 -0800)]
s3: smbd: In count_dfs_links(), Move one more use of OpenDir() -> OpenDir_nstatus()

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: smbd: In rmdir_internals(), Move one more use of OpenDir() -> OpenDir_nstatus()
Jeremy Allison [Mon, 28 Feb 2022 22:22:03 +0000 (14:22 -0800)]
s3: smbd: In rmdir_internals(), Move one more use of OpenDir() -> OpenDir_nstatus()

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: smbd: In recursive_rmdir(), Move one more use of OpenDir() -> OpenDir_nstatus()
Jeremy Allison [Mon, 28 Feb 2022 22:20:37 +0000 (14:20 -0800)]
s3: smbd: In recursive_rmdir(), Move one more use of OpenDir() -> OpenDir_nstatus()

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: VFS: syncops: Move one more use of OpenDir() -> OpenDir_nstatus().
Jeremy Allison [Mon, 28 Feb 2022 22:13:04 +0000 (14:13 -0800)]
s3: VFS: syncops: Move one more use of OpenDir() -> OpenDir_nstatus().

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: VFS: shadow_copy: Move one more use of OpenDir() -> OpenDir_nstatus().
Jeremy Allison [Mon, 28 Feb 2022 22:11:04 +0000 (14:11 -0800)]
s3: VFS: shadow_copy: Move one more use of OpenDir() -> OpenDir_nstatus().

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: VFS: fruit: Move two more uses of OpenDir() -> OpenDir_nstatus().
Jeremy Allison [Mon, 28 Feb 2022 22:08:40 +0000 (14:08 -0800)]
s3: VFS: fruit: Move two more uses of OpenDir() -> OpenDir_nstatus().

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos3: VFS: ceph_snapshots: Move two more uses of OpenDir() -> OpenDir_nstatus().
Jeremy Allison [Mon, 28 Feb 2022 21:28:30 +0000 (13:28 -0800)]
s3: VFS: ceph_snapshots: Move two more uses of OpenDir() -> OpenDir_nstatus().

Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2 years agos4:kdc: hdb_samba4_audit() is only called once per request
Stefan Metzmacher [Tue, 1 Mar 2022 21:10:08 +0000 (10:10 +1300)]
s4:kdc: hdb_samba4_audit() is only called once per request

So we need to restructure the logic a bit.

NOTE: This commit finally works again!

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Joseph Sutton <jsutton@samba.org>
Autobuild-Date(master): Tue Mar  1 23:28:22 UTC 2022 on sn-devel-184

2 years agos4-kdc: Adapt to move from HDB auditing to KDC auditing constants
Andrew Bartlett [Tue, 1 Mar 2022 21:00:17 +0000 (10:00 +1300)]
s4-kdc: Adapt to move from HDB auditing to KDC auditing constants

This is to adapt to:

    commit 6530021f09a5cab631be19a1b5898a0ba6b32f16
    Author: Luke Howard <lukeh@padl.com>
    Date:   Thu Jan 13 14:37:29 2022 +1100

        kdc: move auth event definitions into KDC header

        Move KDC auth event macro definitions out of hdb.h and into a new KDC header,
        kdc-audit.h.

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

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agos4:kdc: Adapt to removal of publicly accessible request structure members
Joseph Sutton [Tue, 22 Feb 2022 20:53:27 +0000 (09:53 +1300)]
s4:kdc: Adapt to removal of publicly accessible request structure members

We now have to use the accessor functions instead.

This is an adaptation to Heimdal:

commit ec24edf7005c340018450a202d27ca75fcf322d4
Author: Luke Howard <lukeh@padl.com>
Date:   Thu Jan 20 09:15:24 2022 +1100

    kdc: add accessor functions for KDC request structure

    Add accessor functions for use by Samba and other plugin developers.
    Documentation is in kdc/kdc-accessors.h.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Adapt to hdb_entry_ex removal
Joseph Sutton [Tue, 22 Feb 2022 06:41:14 +0000 (19:41 +1300)]
s4:kdc: Adapt to hdb_entry_ex removal

Rather than having a 'free_entry' member that can be called to free an
hdb_entry, we now implement the free function in HDB. We perform the
free only if the context pointer is non-NULL.

We also remove the ZERO_STRUCTP() in sdb_entry_to_hdb_entry(), as the
context pointer is now part of the 'hdb_entry' structure itself, and
this would undesirably zero it out.

This is an adaptation to Heimdal commits:

commit c5551775e204d00c7ee8055ab6ddbba7e0590584
Author: Luke Howard <lukeh@padl.com>
Date:   Fri Jan 7 12:15:55 2022 +1100

    hdb: decorate HDB_entry with context member

    Decorate HDB_entry with context and move free_entry callback into HDB structure
    itself. Requires updating hdb_free_entry() signature to include HDB parameter.
    A follow-up commit will consolidate hdb_entry_ex (which has a single hdb_entry
    member) into hdb_entry.

commit 0e8c4ccc6ee0123ea39e53e8917fc3f6bb74e8c8
Author: Luke Howard <lukeh@padl.com>
Date:   Fri Jan 7 12:54:40 2022 +1100

    hdb: eliminate hdb_entry_ex

    Remove hdb_entry_ex and revert to the original design of hdb_entry (except with
    an additional context member in hdb_entry which is managed by the free_entry
    method in HDB).

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Increment plugin minor version
Joseph Sutton [Tue, 22 Feb 2022 03:30:27 +0000 (16:30 +1300)]
s4:kdc: Increment plugin minor version

This is an adaptation to Heimdal:

commit 40e4a4df09c2d6c3ba7bf14df1dee74a0bc18110
Author: Luke Howard <lukeh@padl.com>
Date:   Mon Jan 10 12:50:37 2022 +1100

    kdc: use astgs_request_t for client/server name (TGS)

    Store the client and server principal name from the TGT and request
    (respectively) in the astgs_request_t rather than using local variables.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agothird_party/heimdal_build: Don't generate .x source files
Joseph Sutton [Mon, 21 Feb 2022 06:12:28 +0000 (19:12 +1300)]
third_party/heimdal_build: Don't generate .x source files

This is an adaptation to Heimdal:

commit 9427796f1a65906f12768b28abdb5a928222f3c6
Author: Jeffrey Altman <jaltman@secure-endpoints.com>
Date:   Wed Jan 5 15:45:23 2022 -0500

    Generate .x source files as .c source files

    The generated .x source and .hx header files are plain C source files.
    Generate them as .c source files and avoid unnecessary file copying
    and special makefile rules.

    Change-Id: Ifc4bbe3c46dd357fdd642040ad964c7cfe1d395c

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Explicitly set plugin minor version
Joseph Sutton [Tue, 22 Feb 2022 02:56:32 +0000 (15:56 +1300)]
s4:kdc: Explicitly set plugin minor version

This is an adaptation to Heimdal:

commit 7cc4b7a9e624f5eecfbb38607d4cc0870a895671
Author: Luke Howard <lukeh@padl.com>
Date:   Wed Jan 5 13:08:11 2022 +1100

    kdc: KDC plugin API contract notes

    Add some notes about the KDC plugin API contract, and require plugins to
    explicitly indicate which version of the API they support (remove the macro
    alias for the current version).

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agothird_party/heimdal_build: Add SFU source file
Joseph Sutton [Tue, 22 Feb 2022 02:53:34 +0000 (15:53 +1300)]
third_party/heimdal_build: Add SFU source file

This is an adaptation to Heimdal:

commit 0287558838de79313e38026d2f0905ffc987d0b8
Author: Luke Howard <lukeh@padl.com>
Date:   Fri Dec 24 13:49:55 2021 +1100

    kdc: move Services for User implementation out of krb5tgs.c

    Move the Services for User (SFU/S4U) implementation -- protocol transition and
    constrained delegation -- into its own compilation unit, with an interface that
    only takes an astgs_request_t, so it can be easily factored out into a plugin
    module in the future.

    This refactoring is also careful to update all client names in the request
    structure after the SFU/S4U validation has successfully completed.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Adapt to removal of auth audit event types
Joseph Sutton [Tue, 22 Feb 2022 02:48:12 +0000 (15:48 +1300)]
s4:kdc: Adapt to removal of auth audit event types

This is an adaptation to Heimdal:

commit 06f8985c55fcd23e3efe0017ed2480c5b3c4524f
Author: Luke Howard <lukeh@padl.com>
Date:   Wed Jan 5 09:42:03 2022 +1100

    hdb: consolidate preauth audit event types

    Instead of having distinct preauth success/failure events for different
    mechanisms, have a single event; the mechanism can be disambiguated by querying
    the HDB_REQUEST_KV_PA_NAME key.

    Note: there is still an explicit event for long-term key-based success/failure
    in order to help the backend implement lockout.

    Audit failure (HDB_AUTH_EVENT_PREAUTH_FAILED) in the main preauth loop, rather
    than in each mechanism. Success is still audited in the mechanism to allow
    client pre-authentication success to be noted even if something subsequent
    (e.g. encoding a reply, memory allocation) fails. The generic catch-all for
    success remains.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Rename windc to kdc plugin
Joseph Sutton [Tue, 22 Feb 2022 01:39:13 +0000 (14:39 +1300)]
s4:kdc: Rename windc to kdc plugin

This is an adaptation to Heimdal:

commit fcff5933ade652343d7c169659da92fac0e6e0d4
Author: Luke Howard <lukeh@padl.com>
Date:   Mon Jan 3 11:10:18 2022 +1100

    kdc: rename windc to kdc plugin

    Rename the "windc" plugin API to the more general "kdc" plugin API, for two
    reasons: the Heimdal KDC uses the Windows PAC even when not emulating a domain
    controller, and the plugin API has accreted methods that are not specific to
    emulating a domain controller (such as referral_policy and finalize_reply).

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Add referral policy callback
Joseph Sutton [Mon, 21 Feb 2022 06:25:06 +0000 (19:25 +1300)]
s4:kdc: Add referral policy callback

This is now used instead of a configuration option.

This is an adaption to Heimdal:

commit 3fa47f5a1a422e178d968a8ec0d59889eaa71548
Author: Luke Howard <lukeh@padl.com>
Date:   Sun Jan 2 21:51:43 2022 +1100

    kdc: add referral_policy callback to windc plugin

    Add a referral policy hook to the TGS as a more elegant way of resolving
    referral detection for Samba). The hook can either rewrite the server_princ in
    the request, or it can return an error to disable built-in referral processing.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Add 'not authorised' auth events
Joseph Sutton [Mon, 21 Feb 2022 23:16:49 +0000 (12:16 +1300)]
s4:kdc: Add 'not authorised' auth events

This is an adaptation to Heimdal:

commit d683780b1d728bf8c5b794a1f66842e5a25bd360
Author: Luke Howard <lukeh@padl.com>
Date:   Sat Jan 1 23:44:05 2022 +1100

    kdc: separate PKINIT/GSS authorization failure

    Create a new audit event for PKINIT/GSS authorization (impersonation) failure

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Adapt to removal of auth event details
Joseph Sutton [Mon, 21 Feb 2022 07:45:45 +0000 (20:45 +1300)]
s4:kdc: Adapt to removal of auth event details

This is an adaptation to Heimdal:

commit e15e711b13e2fb33f4480a054cba60b6c4c0183b
Author: Luke Howard <lukeh@padl.com>
Date:   Sat Jan 1 18:05:51 2022 +1100

    kdc: remove auth_event_details audit key

    The auth event details audit key (formerly, parameter to auth_status)
    contained, variously, an encryption type name; a PKINIT client certificate
    name; or, a GSS initiator name. Audit these instead using individual keys that
    reflect the values' contents.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos4:kdc: Refactor HDB API
Joseph Sutton [Mon, 21 Feb 2022 07:28:42 +0000 (20:28 +1300)]
s4:kdc: Refactor HDB API

This is an adaptation to Heimdal:

commit b1dcc1a47485165ada778ef3c3463cfc0779d183
Author: Luke Howard <lukeh@padl.com>
Date:   Fri Dec 31 17:24:58 2021 +1100

    kdc: refactor Samba-specific auditing API in terms of existing API

    Make Samba-specific HDB auth status API a wrapper on the existing auditing API,
    with a view towards unifying the two APIs in a future commit.

    The term "auth status" is replaced with "auth event", and the HDB auth_status
    method is replaced with a more general purpose audit method which has access to
    the entire request structure.

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agothird_party/heimdal_build: Add source files to build
Joseph Sutton [Tue, 22 Feb 2022 01:09:52 +0000 (14:09 +1300)]
third_party/heimdal_build: Add source files to build

This is an adaptation to Heimdal:

commit be708ca3cf98900c61919f8ff7ced4428b5d1f32
Author: Nicolas Williams <nico@twosigma.com>
Date:   Wed Dec 22 17:01:12 2021 -0600

    gsskrb5: Add simple name attributes support

    This adds Kerberos mechanism support for:

     - composite principal name export/import
     - getting rudimentary name attributes from GSS names using
       gss_get_name_attribute():
        - all (raw) authorization data from the Ticket
        - all (raw) authorization data from the Authenticator
        - transit path
        - realm
        - component count
        - each component
     - gss_inquire_name()
     - gss_display_name_ext() (just for the hostbased service name type
                               though)

    The test exercises almost all of the functionality, except for:

     - getting the PAC
     - getting authz-data from the Authenticator
     - getting the transit path

    TBD (much) later:

     - amend test_context to do minimal name attribute checks as well
     - gss_set_name_attribute() (to request authz-data)
     - gss_delete_name_attribute()
     - getting specific authorization data elements via URN fragments (as
       opposed to all of them)
     - parsing the PAC, extracting SIDs (each one as a separate value)
     - some configurable local policy (?)
     - plugin interface for additional local policy

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agothird_party/heimdal: import lorikeet-heimdal-202203010107 (commit 0e7a12404c388e831fe...
Joseph Sutton [Tue, 1 Mar 2022 01:17:54 +0000 (14:17 +1300)]
third_party/heimdal: import lorikeet-heimdal-202203010107 (commit 0e7a12404c388e831fe6933fcc3c86e7eb334825)

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

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agothird_party/heimdal_build: Define fallthrough macro for switch statements
Joseph Sutton [Tue, 22 Feb 2022 03:41:52 +0000 (16:41 +1300)]
third_party/heimdal_build: Define fallthrough macro for switch statements

This is an adaptation to Heimdal:

commit ddc61136100b32346c4c4efa2bb6ddb5baedfb3e
Author: Nicolas Williams <nico@twosigma.com>
Date:   Fri Jan 14 16:32:04 2022 -0600

    Use fallthrough statement attribute

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

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agosmbd: Fix a use-after-free
Volker Lendecke [Wed, 23 Feb 2022 14:56:41 +0000 (15:56 +0100)]
smbd: Fix a use-after-free

stat_cache_lookup() allocates its result on top of talloc_tos().
filename_convert_smb1_search_path() creates a talloc_stackframe(),
which makes the names which were supposed to be allocated on the "ctx"
parameter of filename_convert_smb1_search_path() go away too
early. Reparent the results from stat_cache_lookup() properly.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14989

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): Tue Mar  1 20:59:55 UTC 2022 on sn-devel-184

2 years agosmbd: Fix a typo
Volker Lendecke [Wed, 23 Feb 2022 14:47:45 +0000 (15:47 +0100)]
smbd: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Set errno in an error return
Volker Lendecke [Tue, 22 Feb 2022 16:12:44 +0000 (17:12 +0100)]
vfs: Set errno in an error return

Don't leak an unrelated errno

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Fix a typo
Volker Lendecke [Tue, 22 Feb 2022 16:12:34 +0000 (17:12 +0100)]
vfs: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agovfs: Fix a typo
Volker Lendecke [Tue, 22 Feb 2022 14:49:37 +0000 (15:49 +0100)]
vfs: Fix a typo

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolib: Simplify parent_dirname() by using talloc_strndup()
Volker Lendecke [Tue, 22 Feb 2022 14:46:14 +0000 (15:46 +0100)]
lib: Simplify parent_dirname() by using talloc_strndup()

Don't duplicate the talloc_strndup() functionality.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agolib: Use cp_smb_filename_nostream() in adouble_path()
Volker Lendecke [Tue, 22 Feb 2022 14:42:41 +0000 (15:42 +0100)]
lib: Use cp_smb_filename_nostream() in adouble_path()

No need to TALLOC_FREE(smb_fname->stream_name) later

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agothird_party/heimdal_build: Determine whether time_t is signed
Joseph Sutton [Thu, 24 Feb 2022 02:24:13 +0000 (15:24 +1300)]
third_party/heimdal_build: Determine whether time_t is signed

Without this, Heimdal will assume time_t is unsigned, and a wrong
assumption will cause 'infinite' ticket lifetimes to be reckoned as from
the past, and thus requests will fail with KDC_ERR_NEVER_VALID.

This is an adaptation to Heimdal:

commit 9ae9902249732237aa1711591604a6adf24963fe
Author: Nicolas Williams <nico@twosigma.com>
Date:   Tue Feb 15 17:01:00 2022 -0600

    cf: Check if time_t is signed

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Mar  1 18:07:50 UTC 2022 on sn-devel-184

2 years agos4:kdc: Don't pass empty PAC buffers to krb5_pac_add_buffer()
Joseph Sutton [Thu, 24 Feb 2022 02:30:17 +0000 (15:30 +1300)]
s4:kdc: Don't pass empty PAC buffers to krb5_pac_add_buffer()

Heimdal will no longer allow us to pass a dummy zero-length buffer to
krb5_pac_add_buffer(), so we have to pass a buffer of length 1 instead.

This is an adaption to Heimdal:

commit 190263bb7a56fc775b50a6cd0dc91820d2b2e5eb
Author: Jeffrey Altman <jaltman@secure-endpoints.com>
Date:   Wed Jan 19 22:55:33 2022 -0500

    assert non-NULL ptrs before calling mem funcs

    The definitions of memcpy(), memmove(), and memset() state that
    the behaviour is undefined if any of the pointer arguments are
    NULL, and some compilers are known to make use of this to
    optimise away existing NULL checks in the source.

    Change-Id: I489bc256e3eac7ff41d91becb0b43aba73dbb3f9
Link: https://www.imperialviolet.org/2016/06/26/nonnull.html
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14995

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agothird_party/heimdal_build: Add KDC_LIB macro definitions
Joseph Sutton [Tue, 22 Feb 2022 02:30:17 +0000 (15:30 +1300)]
third_party/heimdal_build: Add KDC_LIB macro definitions

This is an adaptation to Heimdal:

commit 7bb00a40eabbed2bc1c268f5244bfb9736d9bebe
Author: Luke Howard <lukeh@padl.com>
Date:   Tue Jan 4 13:08:35 2022 +1100

    kdc: fix Windows build

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agoauth: Cope with NULL upn_name in PAC
Joseph Sutton [Tue, 22 Feb 2022 01:15:43 +0000 (14:15 +1300)]
auth: Cope with NULL upn_name in PAC

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2 years agos4:sam: Don't use talloc_steal for msg attributes in authsam_make_user_info_dc()
Stefan Metzmacher [Fri, 25 Feb 2022 06:40:17 +0000 (07:40 +0100)]
s4:sam: Don't use talloc_steal for msg attributes in authsam_make_user_info_dc()

This is most likely not a problem for the current callers,
but that it is unexpected and will likely cause problems with future
changes.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agovfs_shadow_copy2: remove async getxattrat
Ralph Boehme [Wed, 23 Feb 2022 10:36:29 +0000 (11:36 +0100)]
vfs_shadow_copy2: remove async getxattrat

vfswrap_getxattrat_send() is handle based using smb_fname->fsp. As
the open of smb_fname->fsp was processed by this module, the handle
is already correctly opened on the file in the snapshot. In the end
this means we can just call directly call the next function here.

Note that the same reasoning might apply to other modules that use
vfs_not_implemented_getxattrat_send(), but checking and adjusting those is a job
for another day. Currently they will continue to go via the sync fallback of the
caller.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb 28 20:53:35 UTC 2022 on sn-devel-184

2 years agoCI: add a test for async dosmode on a file in a shadow_copy2 snapshot
Ralph Boehme [Wed, 23 Feb 2022 17:10:59 +0000 (18:10 +0100)]
CI: add a test for async dosmode on a file in a shadow_copy2 snapshot

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoCI: enable "smbd async dosmode" on shadow_write share
Ralph Boehme [Wed, 23 Feb 2022 17:14:38 +0000 (18:14 +0100)]
CI: enable "smbd async dosmode" on shadow_write share

Existing tests don't care, upcoming new test needs it.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: also check for NT_STATUS_NOT_SUPPORTED
Ralph Boehme [Fri, 17 Dec 2021 14:02:06 +0000 (15:02 +0100)]
smbd: also check for NT_STATUS_NOT_SUPPORTED

If a VFS module fails SMB_VFS_GETXATTRAT_SEND/RECV with ENOSYS like currently
vfs_shadow_copy2 or any other module that uses
vfs_not_implemented_getxattrat_send() the ENOSYS error that
vfs_not_implemented_getxattrat_send() sets gets mapped to
NT_STATUS_NOT_SUPPORTED by map_nt_error_from_unix().

Unfortunately when checking whether the async SMB_VFS_GETXATTRAT_SEND() failed
and to determine if the sync fallback should be triggered, we currently only
check for NT_STATUS_NOT_IMPLEMENTED which is the error we get when "store dos
attributes" is disabled.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoCI: add test "smb2.async_dosmode"
Ralph Boehme [Tue, 25 Jan 2022 16:59:37 +0000 (17:59 +0100)]
CI: add test "smb2.async_dosmode"

Verifies async-dosmode sync fallback works with shadow_copy2 which returns
ENOSYS for SMB_VFS_GET_DOS_ATTRIBUTES_SEND().

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agosmbd: check "store dos attributes" settings in the async dosmode code
Ralph Boehme [Mon, 24 Jan 2022 15:45:11 +0000 (16:45 +0100)]
smbd: check "store dos attributes" settings in the async dosmode code

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoCI: remove shares referencing removed functionality
Ralph Boehme [Mon, 24 Jan 2022 15:54:29 +0000 (16:54 +0100)]
CI: remove shares referencing removed functionality

The whole "smbd:force sync [user|root] [path|chdir] safe threadpool" stuff was
removed long ago by 29dd6f3e59055a17fa3d6a63619773f940e63374.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 years agoeditorconfig: We always inserted a new line so keep doing that
Andreas Schneider [Mon, 28 Feb 2022 09:18:52 +0000 (10:18 +0100)]
editorconfig: We always inserted a new line so keep doing that

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Feb 28 10:22:34 UTC 2022 on sn-devel-184

2 years agopackaging: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 12:53:56 +0000 (13:53 +0100)]
packaging: Reformat shell scripts

shfmt -f packaging/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Feb 24 10:13:36 UTC 2022 on sn-devel-184

2 years agonsswitch: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 10:20:53 +0000 (11:20 +0100)]
nsswitch: Reformat shell scripts

shfmt -f nsswitch/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:tevent: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 10:18:40 +0000 (11:18 +0100)]
lib:tevent: Reformat shell scripts

shfmt -f lib/tevent/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:tdb: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 10:17:52 +0000 (11:17 +0100)]
lib:tdb: Reformat shell scripts

shfmt -f lib/tdb/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:replace: Reformat shell scripts
Andreas Schneider [Mon, 21 Feb 2022 10:16:58 +0000 (11:16 +0100)]
lib:replace: Reformat shell scripts

shfmt -f lib/replace/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:ldb: Reformat shell scripts
Andreas Schneider [Sat, 19 Feb 2022 15:09:04 +0000 (16:09 +0100)]
lib:ldb: Reformat shell scripts

shfmt -f lib/ldb/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agolib:fuzzing: Reformat shell scripts
Andreas Schneider [Sat, 19 Feb 2022 15:08:16 +0000 (16:08 +0100)]
lib:fuzzing: Reformat shell scripts

shfmt -f lib/fuzzing/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agos3:winbind: Use the canonical principal name to renew the credentials
Samuel Cabrero [Tue, 22 Feb 2022 13:28:44 +0000 (14:28 +0100)]
s3:winbind: Use the canonical principal name to renew the credentials

The principal name stored in the winbindd ccache entry might be an
enterprise principal name if enterprise principals are enabled. Use
the canonical name to renew the credentials.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Feb 23 16:17:29 UTC 2022 on sn-devel-184

2 years agos3:winbind: Store canonical principal and realm in ccache entry
Samuel Cabrero [Tue, 22 Feb 2022 12:19:02 +0000 (13:19 +0100)]
s3:winbind: Store canonical principal and realm in ccache entry

They will be used later to refresh the tickets.

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agos3:libads: Return canonical principal and realm from kerberos_return_pac()
Samuel Cabrero [Tue, 22 Feb 2022 12:08:56 +0000 (13:08 +0100)]
s3:libads: Return canonical principal and realm from kerberos_return_pac()

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

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agolib:krb5_wrap: Fix wrong debug message and use newer debug macro
Samuel Cabrero [Tue, 22 Feb 2022 13:28:28 +0000 (14:28 +0100)]
lib:krb5_wrap: Fix wrong debug message and use newer debug macro

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agolib:krb5_wrap: Improve debug message and use newer debug macro
Samuel Cabrero [Tue, 22 Feb 2022 12:00:05 +0000 (13:00 +0100)]
lib:krb5_wrap: Improve debug message and use newer debug macro

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agos3:libads: Fix memory leak in kerberos_return_pac() error path
Samuel Cabrero [Tue, 22 Feb 2022 11:59:44 +0000 (12:59 +0100)]
s3:libads: Fix memory leak in kerberos_return_pac() error path

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2 years agoautobuild: Run admem_idmap_autorid tests
Andreas Schneider [Tue, 15 Feb 2022 11:38:00 +0000 (12:38 +0100)]
autobuild: Run admem_idmap_autorid tests

They will be part of the samba-admem runners.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Feb 23 11:54:01 UTC 2022 on sn-devel-184

2 years agos3:tests: Run test_idmap_rid.sh against admem_idmap_autorid
Andreas Schneider [Tue, 15 Feb 2022 11:33:33 +0000 (12:33 +0100)]
s3:tests: Run test_idmap_rid.sh against admem_idmap_autorid

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2 years agoselftest: Add ad member with idmap_autorid backend
Andreas Schneider [Tue, 15 Feb 2022 08:44:34 +0000 (09:44 +0100)]
selftest: Add ad member with idmap_autorid backend

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
2 years agos3:trusts_utils: use a password length of 120 for machine accounts
Stefan Metzmacher [Mon, 21 Feb 2022 14:28:53 +0000 (15:28 +0100)]
s3:trusts_utils: use a password length of 120 for machine accounts

This is important when we change the machine password against
an RODC that proxies the request to an RWDC.

An RODC using NetrServerPasswordSet2() to proxy PasswordUpdateForward via
NetrLogonSendToSam() ignores a return of NT_STATUS_INVALID_PARAMETER
and reports NT_STATUS_OK as result of NetrServerPasswordSet2().
This hopefully found the last hole in our very robust machine account
password handling logic inside of trust_pw_change().

The lesson is: try to be as identical to how windows works as possible,
everything else may use is untested code paths on Windows.

A similar problem was fixed by this commit:

    commit 609ca657652862fd9c81fd11f818efb74f72ff55
    Author: Joseph Sutton <josephsutton@catalyst.net.nz>
    Date:   Wed Feb 24 02:03:25 2021 +1300

        provision: Decrease the length of random machine passwords

        The current length of 128-255 UTF-16 characters currently causes
        generation of crypt() passwords to typically fail. This commit
        decreases the length to 120 UTF-16 characters, which is the same as
        that used by Windows.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14984

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Feb 23 08:49:54 UTC 2022 on sn-devel-184

2 years agoupgradehelpers.py: add a comment to update_krbtgt_account_password()
Stefan Metzmacher [Mon, 21 Feb 2022 14:23:54 +0000 (15:23 +0100)]
upgradehelpers.py: add a comment to update_krbtgt_account_password()

The backend generates its own random krbtgt password values.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>