The branch, master has been updated
via 062dc07e9b9 s3-libnet: avoid using lp_dns_hostname() in join code
via 6d4ad4d6824 selfest: add test for non-local offlinejoin provision
via f02a4002d5c s3-libads: dump ADS_MODSLIST before attempting the LDAP
modify
from 1260fcb61c8 s3:rpc_server: Handle an np_read_send with len==0
correctly
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 062dc07e9b9c8e260548d0bca4d02819bdc60326
Author: Günther Deschner <[email protected]>
Date: Tue Jan 14 19:16:31 2025 +0100
s3-libnet: avoid using lp_dns_hostname() in join code
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15777
This codepath is also used for provisiong non-local machines into AD
during offlinejoin operations. When creating accounts for non-local
machines we certainly need to be able to use arbitrary hostname other
than lp_netbios_name() (which is used internally by lp_dns_hostname()).
This partly reverts 0e96092c1895ecb41d4064111566b4ada71fe457.
Guenther
Signed-off-by: Guenther Deschner <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
Autobuild-User(master): Andreas Schneider <[email protected]>
Autobuild-Date(master): Thu Jan 30 07:35:05 UTC 2025 on atb-devel-224
commit 6d4ad4d6824e81ef85dd924d550222dd6a322a15
Author: Günther Deschner <[email protected]>
Date: Mon Jan 13 20:26:01 2025 +0100
selfest: add test for non-local offlinejoin provision
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15777
Guenther
Signed-off-by: Guenther Deschner <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
commit f02a4002d5c3cfcd7f36b3bcf13310ffd155de90
Author: Günther Deschner <[email protected]>
Date: Tue Jan 14 01:40:05 2025 +0100
s3-libads: dump ADS_MODSLIST before attempting the LDAP modify
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15777
Guenther
Signed-off-by: Guenther Deschner <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
source3/libads/ldap.c | 66 ++++++++++++++++++++++++++++++++++
source3/libnet/libnet_join.c | 9 ++++-
testprogs/blackbox/test_net_offline.sh | 14 ++++++++
3 files changed, 88 insertions(+), 1 deletion(-)
Changeset truncated at 500 lines:
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 48c5b263ff9..e30f84e3ffb 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1966,6 +1966,67 @@ static ADS_STATUS ads_modlist_add(TALLOC_CTX *ctx,
ADS_MODLIST *mods,
return ADS_ERROR(LDAP_SUCCESS);
}
+/*
+ dump a ADS_MODSLIST via DEBUG
+*/
+static void ads_dump_modlist(ADS_MODLIST *mods)
+{
+ LDAPMod **modlist = (LDAPMod **)*mods;
+ const char *op = NULL;
+ size_t i, j;
+ char *buf = NULL;
+
+ if (mods == NULL || DEBUGLEVEL < DBGLVL_DEBUG) {
+ return;
+ }
+
+ buf = talloc_strdup(talloc_tos(), "");
+
+ for (i = 0; modlist[i] != NULL; i++) {
+
+ /* only ever used three ops */
+
+ switch (modlist[i]->mod_op) {
+ case LDAP_MOD_DELETE:
+ op = "LDAP_MOD_DELETE";
+ break;
+ case LDAP_MOD_REPLACE:
+ op = "LDAP_MOD_REPLACE";
+ break;
+ case LDAP_MOD_REPLACE | LDAP_MOD_BVALUES:
+ op = "LDAP_MOD_REPLACE | LDAP_MOD_BVALUES";
+ break;
+ default:
+ op = "unknown";
+ break;
+ }
+
+ talloc_asprintf_addbuf(&buf, "mod[%zu]: mod_op: %s\n", i, op);
+ talloc_asprintf_addbuf(&buf,
+ "mod[%zu]: mod_type: %s\n",
+ i,
+ modlist[i]->mod_type);
+
+ if (modlist[i]->mod_op & LDAP_MOD_BVALUES) {
+ continue;
+ }
+
+ for (j = 0; modlist[i]->mod_values[j] != NULL; j++) {
+ talloc_asprintf_addbuf(
+ &buf,
+ "mod[%zu]: mod_values[%zu]: %s\n",
+ i,
+ j,
+ modlist[i]->mod_values[j]);
+ }
+ }
+
+ if (buf != NULL) {
+ DBG_DEBUG("%s", buf);
+ TALLOC_FREE(buf);
+ }
+}
+
/**
* Add a single string value to a mod list
* @param ctx An initialized TALLOC_CTX
@@ -2073,6 +2134,9 @@ ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char
*mod_dn, ADS_MODLIST mods)
for(i=0;(mods[i]!=0)&&(mods[i]!=(LDAPMod *) -1);i++);
/* make sure the end of the list is NULL */
mods[i] = NULL;
+
+ ads_dump_modlist(&mods);
+
ret = ldap_modify_ext_s(ads->ldap.ld, utf8_dn,
(LDAPMod **) mods, controls, NULL);
ads_print_error(ret, ads->ldap.ld);
@@ -2105,6 +2169,8 @@ ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char
*new_dn, ADS_MODLIST mods)
/* make sure the end of the list is NULL */
mods[i] = NULL;
+ ads_dump_modlist(&mods);
+
ret = ldap_add_ext_s(ads->ldap.ld, utf8_dn, (LDAPMod**)mods, NULL,
NULL);
ads_print_error(ret, ads->ldap.ld);
TALLOC_FREE(utf8_dn);
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 23c3d50f2f6..5796c68e2e0 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -553,7 +553,14 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX
*mem_ctx,
* Register dns_hostname if needed, add_uniq_spn() will avoid
* duplicates.
*/
- dns_hostname = lp_dns_hostname();
+ if (r->in.dnshostname != NULL) {
+ dns_hostname = talloc_strdup(frame, r->in.dnshostname);
+ } else {
+ dns_hostname = talloc_asprintf(frame,
+ "%s.%s",
+ r->in.machine_name,
+ r->out.dns_domain_name);
+ }
if (dns_hostname == NULL) {
status = ADS_ERROR_LDAP(LDAP_NO_MEMORY);
goto done;
diff --git a/testprogs/blackbox/test_net_offline.sh
b/testprogs/blackbox/test_net_offline.sh
index d885b337cea..e5b57e5431a 100755
--- a/testprogs/blackbox/test_net_offline.sh
+++ b/testprogs/blackbox/test_net_offline.sh
@@ -34,6 +34,20 @@ samba_texpect="$BINDIR/texpect"
netbios=$(grep "netbios name" $BASEDIR/$WORKDIR/client.conf | cut -f2 -d= |
awk '{$1=$1};1')
+# 0. Test with machine_name != lp_netbios_name()
+
+NONLOCALMACHINE=win11
+
+testit "provision with non local machine name" \
+ ${VALGRIND} ${net_tool} offlinejoin provision domain="${REALM}"
machine_name="${NONLOCALMACHINE}" savefile="${ODJFILE}"
-U"${DC_USERNAME}%${DC_PASSWORD}" || \
+ failed=$((failed + 1))
+
+testit "net rpc user delete" \
+ ${VALGRIND} ${net_tool} rpc user delete "${NONLOCALMACHINE}$"
-U"${DC_USERNAME}%${DC_PASSWORD}" -S "${DC_SERVER}" || \
+ failed=$((failed + 1))
+
+rm -f "${ODJFILE}"
+
# 1. Test w/o dcname
testit "provision without dcname" $VALGRIND $net_tool offlinejoin provision
domain=$REALM machine_name=$netbios savefile=$ODJFILE
-U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
--
Samba Shared Repository