From: Alexander Bokovoy Date: Tue, 3 Sep 2024 05:48:24 +0000 (+0300) Subject: sync machine password to keytab: handle FreeIPA use case X-Git-Tag: tdb-1.4.13~1214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f577c7b6894132be4842944f2f950b087312b16;p=thirdparty%2Fsamba.git sync machine password to keytab: handle FreeIPA use case FreeIPA uses own procedure to retrieve keytabs and during the setup of Samba on FreeIPA client the keytab is already present, only machine account needs to be set in the secrets database. 'sync machine password to keytab' option handling broke this use case by always attempting to contact a domain controller and failing to do so (Fedora bug https://bugzilla.redhat.com/show_bug.cgi?id=2309199). The original synchronizing machine account password to keytab feature did not have a mechanism to disable its logic at all. Signed-off-by: Alexander Bokovoy Reviewed-by: Pavel Filipenský Autobuild-User(master): Alexander Bokovoy Autobuild-Date(master): Fri Sep 13 13:16:09 UTC 2024 on atb-devel-224 --- diff --git a/docs-xml/smbdotconf/security/syncmachinepasswordtokeytab.xml b/docs-xml/smbdotconf/security/syncmachinepasswordtokeytab.xml index 4cad9da73f2..f7dc30023d4 100644 --- a/docs-xml/smbdotconf/security/syncmachinepasswordtokeytab.xml +++ b/docs-xml/smbdotconf/security/syncmachinepasswordtokeytab.xml @@ -18,7 +18,11 @@ or by winbindd doing regular updates (see +If no value is present and is different from +'secrets only', the behavior differs between winbind and net utility: + + + + winbind uses value + /path/to/keytab:sync_spns:sync_kvno:machine_password + where the path to the keytab is obtained either from the krb5 library or from + . + + + + net changesecretpw -f command uses the default 'disabled' value. + + No other net subcommands use the 'disabled' value. + + + +If a single value 'disabled' is present, the synchronization process is +disabled. This is required for FreeIPA domain member setup where keytab +synchronization uses a protocol not implemented by Samba. diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c index 6ede567b75f..dbf8af44c1f 100644 --- a/source3/libads/kerberos_keytab.c +++ b/source3/libads/kerberos_keytab.c @@ -904,6 +904,11 @@ NTSTATUS sync_pw2keytabs(void) goto params_ready; } + if ((*lp_ptr != NULL) && strequal_m(*lp_ptr, "disabled")) { + DBG_DEBUG("'sync machine password to keytab' is explicitly disabled.\n"); + return NT_STATUS_OK; + } + line = lp_ptr; while (*line) { DBG_DEBUG("Scanning line: %s\n", *line); diff --git a/source3/utils/net.c b/source3/utils/net.c index 7b40d2bee95..c432ebe991f 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -207,6 +207,14 @@ static int net_changesecretpw(struct net_context *c, int argc, struct timeval tv = timeval_current(); NTTIME now = timeval_to_nttime(&tv); +#ifdef HAVE_ADS + if (USE_KERBEROS_KEYTAB) { + if (lp_sync_machine_password_to_keytab() == NULL) { + lp_do_parameter(-1, "sync machine password to keytab", "disabled"); + } + } +#endif + if (c->opt_stdin) { set_line_buffering(stdin); set_line_buffering(stdout); diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index e3ed336a79a..a31a7a8a30a 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -803,7 +803,8 @@ static int do_global_checks(void) "instead of 'kerberos method'.\n\n"); } - if (lp_ptr != NULL) { + if (lp_ptr != NULL && + ((*lp_ptr != NULL) && !strequal_m(*lp_ptr, "disabled"))) { while (*lp_ptr) { ret |= pw2kt_check_line(*lp_ptr++); }