The branch, v4-23-test has been updated
       via  5bbb682b0fc s3:net: Pass down the server from cmdline to 
sync_pw2keytabs()
       via  5294b24f6e2 tests: Add test for 'net ads join' to a preferred DC
       via  65181b65b83 selftest: Add the short name for localvampiredc to 
hosts file
       via  1e6a3af2058 ctdb: fix build against PCP 7.0.0
      from  a2f9e7392ea VERSION: Bump version up to Samba 4.23.0rc5...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-23-test


- Log -----------------------------------------------------------------
commit 5bbb682b0fc5852ef6ea21a7ee51b545481efc46
Author: Andreas Schneider <[email protected]>
Date:   Mon Jul 28 10:43:36 2025 +0200

    s3:net: Pass down the server from cmdline to sync_pw2keytabs()
    
    This makes sure that during 'net ads join' the keytab create code
    - sync_pw2keytabs() talks to the same DC at what the machine account
    was created.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15905
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Signed-off-by: Pavel Filipenský <[email protected]>
    Pair-Programmed-With: Pavel Filipenský <[email protected]>
    
    Reviewed-by: Alexander Bokovoy <[email protected]>
    
    Autobuild-User(master): Pavel Filipensky <[email protected]>
    Autobuild-Date(master): Fri Sep  5 13:38:33 UTC 2025 on atb-devel-224
    
    (cherry picked from commit 5d1d3a8b568b5a07ed1ed537d20aa93820cecc14)
    
    Autobuild-User(v4-23-test): Jule Anger <[email protected]>
    Autobuild-Date(v4-23-test): Tue Sep  9 12:46:31 UTC 2025 on atb-devel-224

commit 5294b24f6e2df1906830638ab50b5967d546f765
Author: Pavel Filipenský <[email protected]>
Date:   Mon Aug 4 11:20:54 2025 +0200

    tests: Add test for 'net ads join' to a preferred DC
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15905
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    (cherry picked from commit 36f6ac547c09f492d1dcab11570e8bcbd377cf26)

commit 65181b65b83f038e1f36ebfe094e17655fcf973d
Author: Pavel Filipenský <[email protected]>
Date:   Tue Jul 29 11:19:07 2025 +0200

    selftest: Add the short name for localvampiredc to hosts file
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15905
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    (cherry picked from commit 5d2f60ae5aa96751b74901ae5384291ef338b152)

commit 1e6a3af20586fd0e7079181df6d27bcdb7ba27cd
Author: Alexander Bokovoy <[email protected]>
Date:   Wed Sep 3 15:42:46 2025 +0300

    ctdb: fix build against PCP 7.0.0
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15904
    
    Signed-off-by: Alexander Bokovoy <[email protected]>
    Reviewed-by: Martin Schwenke <[email protected]>
    
    Autobuild-User(master): Martin Schwenke <[email protected]>
    Autobuild-Date(master): Mon Sep  8 04:47:37 UTC 2025 on atb-devel-224
    
    (cherry picked from commit 83ff87f3dab0d6b22031614e9481b880f1dd99e8)

-----------------------------------------------------------------------

Summary of changes:
 ctdb/utils/pmda/pmda_ctdb.c                        | 11 +++-
 ctdb/wscript                                       | 21 ++++----
 selftest/target/Samba4.pm                          |  2 +-
 source3/include/secrets.h                          | 25 +++++----
 source3/libads/ads_proto.h                         |  2 +-
 source3/libads/kerberos_keytab.c                   | 24 +++++++--
 source3/libads/trusts_util.c                       | 15 +++---
 source3/libads/util.c                              | 10 ++--
 source3/libnet/libnet_join.c                       |  2 +-
 source3/passdb/machine_account_secrets.c           | 10 ++--
 source3/utils/net.c                                | 10 ++--
 source3/utils/net_ads.c                            |  2 +-
 source4/selftest/tests.py                          |  1 +
 .../blackbox/test_net_ads_join_to_preferred_dc.sh  | 61 ++++++++++++++++++++++
 14 files changed, 150 insertions(+), 46 deletions(-)
 create mode 100755 testprogs/blackbox/test_net_ads_join_to_preferred_dc.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/utils/pmda/pmda_ctdb.c b/ctdb/utils/pmda/pmda_ctdb.c
index 7ac8a3b38d1..9845f26defb 100644
--- a/ctdb/utils/pmda/pmda_ctdb.c
+++ b/ctdb/utils/pmda/pmda_ctdb.c
@@ -39,10 +39,19 @@
 
 #define pmID_cluster(id)       id->cluster
 #define pmID_item(id)          id->item
+#endif
+
+#ifndef HAVE_PMGETPROGNAME
 #define pmGetProgname()                pmProgname
+#endif
+#ifndef HAVE_PMSETPROGNAME
 #define pmSetProgname(a)       __pmSetProgname(a)
 #endif
 
+#ifdef HAVE_STRUCT_PMRESULT
+#define pmdaResult pmResult
+#endif
+
 #include "domain.h"
 
 /*
@@ -450,7 +459,7 @@ err_out:
  * instance domain evaluation.
  */
 static int
-pmda_ctdb_fetch(int numpmid, pmID pmidlist[], pmResult **resp, pmdaExt *pmda)
+pmda_ctdb_fetch(int numpmid, pmID pmidlist[], pmdaResult **resp, pmdaExt *pmda)
 {
        int ret;
 
diff --git a/ctdb/wscript b/ctdb/wscript
index e9cd89436a3..6ab68dce870 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -226,16 +226,17 @@ def configure(conf):
 
     have_pmda = False
     if Options.options.ctdb_pmda:
-        pmda_support = True
-
-        if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
-                                  together=True):
-            pmda_support = False
-        if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
-            pmda_support = False
-        if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
-            pmda_support = False
-        if pmda_support:
+        checks = [conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
+                                     together=True),
+                  conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda')]
+
+        have_progname = [conf.CHECK_FUNCS_IN('pmProgname', 'pcp'),
+                         conf.CHECK_FUNCS_IN('pmGetProgname', 'pcp'),
+                         conf.CHECK_FUNCS_IN('pmSetProgname', 'pcp')]
+
+        conf.CHECK_TYPE_IN('struct pmResult', 'pcp/pmapi.h')
+
+        if all(checks) and any(have_progname):
             conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
             have_pmda = True
         else:
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 9635629d291..8d30fefbab2 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -878,7 +878,7 @@ nogroup:x:65534:nobody
 
        my $hostname = lc($ctx->{hostname});
        open(HOSTS, ">>$ctx->{nsswrap_hosts}");
-       if ($hostname eq "localdc") {
+       if ($hostname eq "localdc" || $hostname eq "localvampiredc") {
                print HOSTS "$ctx->{ipv4} ${hostname}.$ctx->{dnsname} 
$ctx->{dnsname} ${hostname}\n";
                print HOSTS "$ctx->{ipv6} ${hostname}.$ctx->{dnsname} 
$ctx->{dnsname} ${hostname}\n";
        } else {
diff --git a/source3/include/secrets.h b/source3/include/secrets.h
index a454c8bb8ff..061b9c6ef34 100644
--- a/source3/include/secrets.h
+++ b/source3/include/secrets.h
@@ -125,12 +125,15 @@ char *secrets_domain_info_string(TALLOC_CTX *mem_ctx, 
const struct secrets_domai
 NTSTATUS secrets_fetch_or_upgrade_domain_info(const char *domain,
                                        TALLOC_CTX *mem_ctx,
                                        struct secrets_domain_info1 **pinfo);
-NTSTATUS secrets_prepare_password_change(const char *domain, const char 
*dcname,
-                                        const char *cleartext_unix,
-                                        TALLOC_CTX *mem_ctx,
-                                        struct secrets_domain_info1 **pinfo,
-                                        struct secrets_domain_info1_change 
**pprev,
-                                        NTSTATUS (*sync_pw2keytabs_fn)(void));
+NTSTATUS secrets_prepare_password_change(
+       const char *domain,
+       const char *dcname,
+       const char *cleartext_unix,
+       TALLOC_CTX *mem_ctx,
+       struct secrets_domain_info1 **pinfo,
+       struct secrets_domain_info1_change **pprev,
+       NTSTATUS (*sync_pw2keytabs_fn)(const char *),
+       const char *opt_host);
 NTSTATUS secrets_failed_password_change(const char *change_server,
                                        NTSTATUS local_status,
                                        NTSTATUS remote_status,
@@ -139,10 +142,12 @@ NTSTATUS secrets_defer_password_change(const char 
*change_server,
                                       NTSTATUS local_status,
                                       NTSTATUS remote_status,
                                       const struct secrets_domain_info1 *info);
-NTSTATUS secrets_finish_password_change(const char *change_server,
-                                       NTTIME change_time,
-                                       const struct secrets_domain_info1 *info,
-                                       NTSTATUS (*sync_pw2keytabs_fn)(void));
+NTSTATUS secrets_finish_password_change(
+       const char *change_server,
+       NTTIME change_time,
+       const struct secrets_domain_info1 *info,
+       NTSTATUS (*sync_pw2keytabs_fn)(const char *),
+       const char *prefer_dc);
 bool secrets_delete_machine_password_ex(const char *domain, const char *realm);
 bool secrets_delete_domain_sid(const char *domain);
 char *secrets_fetch_prev_machine_password(const char *domain);
diff --git a/source3/libads/ads_proto.h b/source3/libads/ads_proto.h
index e5b68530866..a368e04d7e4 100644
--- a/source3/libads/ads_proto.h
+++ b/source3/libads/ads_proto.h
@@ -229,6 +229,6 @@ struct spn_struct {
 /* parse a windows style SPN, returns NULL if parsing fails */
 struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc);
 
-NTSTATUS sync_pw2keytabs(void);
+NTSTATUS sync_pw2keytabs(const char *prefer_dc);
 
 #endif /* _LIBADS_ADS_PROTO_H_ */
diff --git a/source3/libads/kerberos_keytab.c b/source3/libads/kerberos_keytab.c
index ed26c6af499..364d8421bda 100644
--- a/source3/libads/kerberos_keytab.c
+++ b/source3/libads/kerberos_keytab.c
@@ -84,6 +84,7 @@ struct pw2kt_global_state {
        char *ad_upn;
        char *ad_sam_account;
        char **ad_spn_array;
+       const char *prefer_dc;
        size_t ad_num_spns;
        /* This is from secrets.db */
        struct secrets_domain_info1 *info;
@@ -869,8 +870,11 @@ static ADS_STATUS pw2kt_get_dc_info(struct 
pw2kt_global_state *state)
        int count;
        bool ok;
        TALLOC_CTX *tmp_ctx = talloc_stackframe();
-       ADS_STRUCT *ads = ads_init(
-               tmp_ctx, lp_realm(), lp_workgroup(), NULL, ADS_SASL_SIGN);
+       ADS_STRUCT *ads = ads_init(tmp_ctx,
+                                  lp_realm(),
+                                  lp_workgroup(),
+                                  state->prefer_dc,
+                                  ADS_SASL_SIGN);
 
        if (ads == NULL) {
                DBG_ERR("ads_init() failed\n");
@@ -1029,7 +1033,20 @@ static bool pw2kt_default_keytab_name(char *name_str, 
size_t name_size)
        return true;
 }
 
-NTSTATUS sync_pw2keytabs(void)
+/**
+ * @internal
+ *
+ * @brief Sync machine password from secrets to keytab
+ *
+ * @param prefer_dc  The DC we should talk to. This is especially important
+ *                   during domain join. Pass NULL if we should pick a random
+ *                   one.
+ *
+ * @return An NTSTATUS error code.
+ *
+ * @see NT_STATUS_IS_OK()
+ */
+NTSTATUS sync_pw2keytabs(const char *prefer_dc)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        const struct loadparm_substitution *lp_sub =
@@ -1055,6 +1072,7 @@ NTSTATUS sync_pw2keytabs(void)
                TALLOC_FREE(frame);
                return NT_STATUS_NO_MEMORY;
        }
+       state->prefer_dc = prefer_dc;
 
        lp_ptr = lp_sync_machine_password_to_keytab();
        if (lp_ptr == NULL) {
diff --git a/source3/libads/trusts_util.c b/source3/libads/trusts_util.c
index 9bea87990b6..2a1f732f298 100644
--- a/source3/libads/trusts_util.c
+++ b/source3/libads/trusts_util.c
@@ -359,10 +359,11 @@ NTSTATUS trust_pw_change(struct 
netlogon_creds_cli_context *context,
                                                         &info,
                                                         &prev,
 #ifdef HAVE_ADS
-                                                        sync_pw2keytabs);
+                                                        sync_pw2keytabs,
 #else
-                                                        NULL);
+                                                        NULL,
 #endif
+                                                        NULL /* opt_host */);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("secrets_prepare_password_change() failed for 
domain %s!\n",
                                  domain));
@@ -609,10 +610,11 @@ NTSTATUS trust_pw_change(struct 
netlogon_creds_cli_context *context,
                        prev->password->change_time,
                        info,
 #ifdef HAVE_ADS
-                       sync_pw2keytabs);
+                       sync_pw2keytabs,
 #else
-                       NULL);
+                       NULL,
 #endif
+                       prev->password->change_server);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("secrets_prepare_password_change() failed for 
domain %s!\n",
                                  domain));
@@ -758,10 +760,11 @@ NTSTATUS trust_pw_change(struct 
netlogon_creds_cli_context *context,
                        info->next_change->change_time,
                        info,
 #ifdef HAVE_ADS
-                       sync_pw2keytabs);
+                       sync_pw2keytabs,
 #else
-                       NULL);
+                       NULL,
 #endif
+                       info->next_change->change_server);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(0, ("secrets_finish_password_change() failed for 
domain %s!\n",
                                  domain));
diff --git a/source3/libads/util.c b/source3/libads/util.c
index 243dd09f3d0..360e556ab9b 100644
--- a/source3/libads/util.c
+++ b/source3/libads/util.c
@@ -59,10 +59,11 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT 
*ads, char *host_princip
                                                 &info,
                                                 &prev,
 #ifdef HAVE_ADS
-                                                sync_pw2keytabs);
+                                                sync_pw2keytabs,
 #else
-                                                NULL);
+                                                NULL,
 #endif
+                                                ads->auth.kdc_server);
        if (!NT_STATUS_IS_OK(status)) {
                return ADS_ERROR_NT(status);
        }
@@ -138,10 +139,11 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT 
*ads, char *host_princip
                                                now,
                                                info,
 #ifdef HAVE_ADS
-                                               sync_pw2keytabs);
+                                               sync_pw2keytabs,
 #else
-                                               NULL);
+                                               NULL,
 #endif
+                                               ads->auth.kdc_server);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1,("Failed to save machine password\n"));
                return ADS_ERROR_NT(status);
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index c33724494aa..609b2b96222 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -869,7 +869,7 @@ static ADS_STATUS libnet_join_set_etypes(TALLOC_CTX 
*mem_ctx,
 static bool libnet_join_create_keytab(TALLOC_CTX *mem_ctx,
                                      struct libnet_JoinCtx *r)
 {
-       NTSTATUS ntstatus = sync_pw2keytabs();
+       NTSTATUS ntstatus = sync_pw2keytabs(r->in.dc_name);
 
        return NT_STATUS_IS_OK(ntstatus);
 }
diff --git a/source3/passdb/machine_account_secrets.c 
b/source3/passdb/machine_account_secrets.c
index 971dd15aa5f..525092b2e1a 100644
--- a/source3/passdb/machine_account_secrets.c
+++ b/source3/passdb/machine_account_secrets.c
@@ -1673,7 +1673,8 @@ NTSTATUS secrets_prepare_password_change(const char 
*domain, const char *dcname,
                                         TALLOC_CTX *mem_ctx,
                                         struct secrets_domain_info1 **pinfo,
                                         struct secrets_domain_info1_change 
**pprev,
-                                        NTSTATUS (*sync_pw2keytabs_fn)(void))
+                                        NTSTATUS (*sync_pw2keytabs_fn)(const 
char *),
+                                        const char *opt_host)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct db_context *db = NULL;
@@ -1770,7 +1771,7 @@ NTSTATUS secrets_prepare_password_change(const char 
*domain, const char *dcname,
        }
 
        if (prev == NULL && sync_pw2keytabs_fn != NULL) {
-               status = sync_pw2keytabs_fn();
+               status = sync_pw2keytabs_fn(opt_host);
                if (!NT_STATUS_IS_OK(status)) {
                        DBG_ERR("Sync of machine password failed.\n");
                        TALLOC_FREE(frame);
@@ -2022,7 +2023,8 @@ NTSTATUS secrets_defer_password_change(const char 
*change_server,
 NTSTATUS secrets_finish_password_change(const char *change_server,
                                        NTTIME change_time,
                                        const struct secrets_domain_info1 
*cookie,
-                                       NTSTATUS (*sync_pw2keytabs_fn)(void))
+                                       NTSTATUS (*sync_pw2keytabs_fn)(const 
char *),
+                                       const char *prefer_dc)
 {
        const char *domain = cookie->domain_info.name.string;
        TALLOC_CTX *frame = talloc_stackframe();
@@ -2101,7 +2103,7 @@ NTSTATUS secrets_finish_password_change(const char 
*change_server,
        }
 
        if (sync_pw2keytabs_fn != NULL) {
-               status = sync_pw2keytabs_fn();
+               status = sync_pw2keytabs_fn(prefer_dc);
                if (!NT_STATUS_IS_OK(status)) {
                        DBG_ERR("Sync of machine password failed.\n");
                        TALLOC_FREE(frame);
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 7ce93ced79e..ecabd980d0c 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -235,10 +235,11 @@ static int net_changesecretpw(struct net_context *c, int 
argc,
                                                         &info,
                                                         &prev,
 #ifdef HAVE_ADS
-                                                        sync_pw2keytabs);
+                                                        sync_pw2keytabs,
 #else
-                                                        NULL);
+                                                        NULL,
 #endif
+                                                        c->opt_host);
                if (!NT_STATUS_IS_OK(status)) {
                        d_fprintf(stderr,
                                _("Unable to write the machine account password 
in the secrets database"));
@@ -261,10 +262,11 @@ static int net_changesecretpw(struct net_context *c, int 
argc,
                                                        now,
                                                        info,
 #ifdef HAVE_ADS
-                                                       sync_pw2keytabs);
+                                                       sync_pw2keytabs,
 #else
-                                                       NULL);
+                                                       NULL,
 #endif
+                                                       c->opt_host);
                if (!NT_STATUS_IS_OK(status)) {
                        d_fprintf(stderr,
                                _("Unable to write the machine account password 
in the secrets database"));
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 6c11faeb091..d49b7537e71 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -2935,7 +2935,7 @@ static int net_ads_keytab_create(struct net_context *c, 
int argc, const char **a
                net_use_krb_machine_account(c);
        }
 
-       ntstatus = sync_pw2keytabs();
+       ntstatus = sync_pw2keytabs(c->opt_host);
        ret = NT_STATUS_IS_OK(ntstatus) ? 0 : 1;
        return ret;
 }
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 0cd0a822c94..5f6598c4b03 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -902,6 +902,7 @@ plantestsuite("samba4.blackbox.rfc2307_mapping",
 plantestsuite("samba4.blackbox.chgdcpass", "chgdcpass", [os.path.join(bbdir, 
"test_chgdcpass.sh"), '$SERVER', r"CHGDCPASS\$", '$REALM', '$DOMAIN', 
'$PREFIX/chgdcpass', "aes256-cts-hmac-sha1-96", '$PREFIX/chgdcpass', 
smbclient3])
 plantestsuite("samba4.blackbox.samba_upgradedns(chgdcpass:local)", 
"chgdcpass:local", [os.path.join(bbdir, "test_samba_upgradedns.sh"), '$SERVER', 
'$REALM', '$PREFIX', '$SELFTEST_PREFIX/chgdcpass'])
 plantestsuite("samba4.blackbox.net_ads", "ad_dc:client", [os.path.join(bbdir, 
"test_net_ads.sh"), '$DC_SERVER', '$DC_USERNAME', '$DC_PASSWORD', '$PREFIX'])
+plantestsuite("samba4.blackbox.net_ads_join", "vampire_dc:client", 
[os.path.join(bbdir, "test_net_ads_join_to_preferred_dc.sh"), '$DC_SERVER', 
'$DC_USERNAME', '$DC_PASSWORD', '$PREFIX'])
 plantestsuite("samba4.blackbox.net_offlinejoin", "ad_dc:client", 
[os.path.join(bbdir, "test_net_offline.sh"), '$DC_SERVER', '$DC_USERNAME', 
'$DC_PASSWORD', '$PREFIX'])
 plantestsuite("samba4.blackbox.client_etypes_all(ad_dc:client)", 
"ad_dc:client", [os.path.join(bbdir, "test_client_etypes.sh"), '$DC_SERVER', 
'$DC_USERNAME', '$DC_PASSWORD', '$PREFIX', 'all', '17_18_23'])
 plantestsuite("samba4.blackbox.client_etypes_legacy(ad_dc:client)", 
"ad_dc:client", [os.path.join(bbdir, "test_client_etypes.sh"), '$DC_SERVER', 
'$DC_USERNAME', '$DC_PASSWORD', '$PREFIX', 'legacy', '23'])
diff --git a/testprogs/blackbox/test_net_ads_join_to_preferred_dc.sh 
b/testprogs/blackbox/test_net_ads_join_to_preferred_dc.sh
new file mode 100755
index 00000000000..1bebc2f4dbe
--- /dev/null
+++ b/testprogs/blackbox/test_net_ads_join_to_preferred_dc.sh
@@ -0,0 +1,61 @@
+if [ $# -lt 4 ]; then
+       cat <<EOF
+Usage: test_net_ads.sh DC_SERVER DC_USERNAME DC_PASSWORD BASEDIR
+EOF
+       exit 1
+fi
+
+DC_SERVER=$1
+DC_USERNAME=$2
+DC_PASSWORD=$3
+BASEDIR=$4
+
+HOSTNAME=$(dd if=/dev/urandom bs=1 count=32 2>/dev/null | sha1sum | cut -b 
1-10)
+
+RUNDIR=$(pwd)
+cd $BASEDIR
+WORKDIR=$(mktemp -d -p .)
+WORKDIR=$(basename $WORKDIR)
+cp -a client/* $WORKDIR/
+sed -ri "s@(dir|directory) = (.*)/client/@\1 = \2/$WORKDIR/@" 
$WORKDIR/client.conf
+sed -ri "s/netbios name = .*/netbios name = $HOSTNAME/" $WORKDIR/client.conf
+rm -f $WORKDIR/private/secrets.tdb
+cd $RUNDIR
+
+failed=0
+
+net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf 
--option=security=ads"
+
+# Load test functions
+. $(dirname $0)/subunit.sh
+. "$(dirname "${0}")/common_test_fns.inc"
+
+# This test is run in environment with two DCs ('localdc' and 'localvampiredc')
+# The 'net ads join' has these two steps:
+#   1. create machine account at DC ('-S' points to 'localvampiredc')
+#   2. create keytab and sync the KVNO from a DC
+#
+# It must be ensured that in step #2 the keytab code contacts the same DC
+# ('localvampiredc'). The configuration below tries to break it.
+# We disable [SAF/DOMAIN/...] and [SAFJOIN/DOMAIN/...] by setting TTL to '-1'
+# And via setting 'password server' to 'localdc' we manage that
+# get_dc_list() returns 'localdc' instead of 'localvampiredc'
+#
+# As long as the keytab code is not explicitly told to use the same DC as join,
+# we get failure:
+# gensec_gse_client_prepare_ccache: Kinit for [email protected] to 
access ldap/localdc.samba.example.com failed: Client not found in Kerberos 
database: NT_STATUS_LOGON_FAILURE
+
+cat <<EOF >>$BASEDIR/$WORKDIR/client.conf
+sync machine password to keytab = 
$BASEDIR/keytab:account_name:machine_password:sync_kvno
+password server = $DC_SERVER
+saf: join ttl = -1
+saf: ttl = -1
+EOF
+
+testit "join" $VALGRIND $net_tool ads join -S$SERVER 
-U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
+
+testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || 
failed=$(expr $failed + 1)
+
+rm -rf $BASEDIR/$WORKDIR
+
+exit $failed


-- 
Samba Shared Repository

Reply via email to