From: Andreas Schneider Date: Tue, 9 Jan 2024 14:47:48 +0000 (+0100) Subject: docs-xml: Add smb.conf option 'dns hostname' X-Git-Tag: tdb-1.4.11~601 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=758bb9aacd587daef31a4320b845e92cb09427ac;p=thirdparty%2Fsamba.git docs-xml: Add smb.conf option 'dns hostname' Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- diff --git a/docs-xml/smbdotconf/misc/dnsclientname.xml b/docs-xml/smbdotconf/misc/dnsclientname.xml new file mode 100644 index 00000000000..9de2bde918a --- /dev/null +++ b/docs-xml/smbdotconf/misc/dnsclientname.xml @@ -0,0 +1,17 @@ + + + This value is used either register with AD during a join or by calling + + net ads dns register + + or during Kerberos authentication to create service principal names. This + is not supported in samba-tool yet. + + +[netbios name].[realm] +client-hostname.example.com + diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index f779affe54a..00971309042 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -3763,3 +3763,40 @@ int32_t lpcfg_parse_enum_vals(const char *param_name, return ret; } + +const char *lpcfg_dns_hostname(struct loadparm_context *lp_ctx) +{ + const char *dns_hostname = lpcfg__dns_hostname(lp_ctx); + const char *dns_domain = lpcfg_dnsdomain(lp_ctx); + char *netbios_name = NULL; + char *hostname = NULL; + + if (dns_hostname != NULL && dns_hostname[0] != '\0') { + return dns_hostname; + } + + netbios_name = strlower_talloc(lp_ctx, lpcfg_netbios_name(lp_ctx)); + if (netbios_name == NULL) { + return NULL; + } + + /* If it isn't set, try to initialize with [netbios name].[realm] */ + if (dns_domain != NULL && dns_domain[0] != '\0') { + hostname = talloc_asprintf(lp_ctx, + "%s.%s", + netbios_name, + dns_domain); + } else { + hostname = talloc_strdup(lp_ctx, netbios_name); + } + TALLOC_FREE(netbios_name); + if (hostname == NULL) { + return NULL; + } + + lpcfg_string_set(lp_ctx->globals->ctx, + &lp_ctx->globals->_dns_hostname, + hostname); + + return hostname; +} diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py index df20b04bc7e..66189277260 100644 --- a/python/samba/tests/docs.py +++ b/python/samba/tests/docs.py @@ -217,6 +217,7 @@ class SmbDotConfTests(TestCase): 'max open files', 'include system krb5 conf', 'smbd max async dosmode', + 'dns hostname', ]) def setUp(self): diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 414d19d7439..12307846c48 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4785,6 +4785,41 @@ int lp_rpc_high_port(void) return Globals.rpc_high_port; } +const char *lp_dns_hostname(void) +{ + const char *dns_hostname = lp__dns_hostname(); + const char *dns_domain = lp_dnsdomain(); + char *netbios_name = NULL; + + if (dns_hostname != NULL && dns_hostname[0] != '\0') { + return dns_hostname; + } + + netbios_name = talloc_strdup(talloc_tos(), lp_netbios_name()); + if (netbios_name == NULL) { + return NULL; + } + strlower_m(netbios_name); + + /* If it isn't set, try to initialize with [netbios name].[realm] */ + if (dns_domain != NULL && dns_domain[0] != '\0') { + Globals._dns_hostname = talloc_asprintf(Globals.ctx, + "%s.%s", + netbios_name, + dns_domain); + } else { + Globals._dns_hostname = talloc_strdup(Globals.ctx, + netbios_name); + } + TALLOC_FREE(netbios_name); + if (Globals._dns_hostname == NULL) { + return NULL; + } + dns_hostname = Globals._dns_hostname; + + return dns_hostname; +} + /* * Do not allow LanMan auth if unless NTLMv1 is also allowed * diff --git a/source3/param/loadparm.h b/source3/param/loadparm.h index 78162911953..622e2290d3c 100644 --- a/source3/param/loadparm.h +++ b/source3/param/loadparm.h @@ -66,6 +66,7 @@ int lp_cups_encrypt(void); bool lp_widelinks(int ); int lp_rpc_low_port(void); int lp_rpc_high_port(void); +const char *lp_dns_hostname(void); bool lp_lanman_auth(void); enum samba_weak_crypto lp_weak_crypto(void);