]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
docs-xml: Add smb.conf option 'dns hostname'
authorAndreas Schneider <asn@samba.org>
Tue, 9 Jan 2024 14:47:48 +0000 (15:47 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 May 2024 20:33:36 +0000 (20:33 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
docs-xml/smbdotconf/misc/dnsclientname.xml [new file with mode: 0644]
lib/param/loadparm.c
python/samba/tests/docs.py
source3/param/loadparm.c
source3/param/loadparm.h

diff --git a/docs-xml/smbdotconf/misc/dnsclientname.xml b/docs-xml/smbdotconf/misc/dnsclientname.xml
new file mode 100644 (file)
index 0000000..9de2bde
--- /dev/null
@@ -0,0 +1,17 @@
+<samba:parameter name="dns hostname"
+                 context="G"
+                 type="string"
+                 function="_dns_hostname"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+    This value is used either register with AD during a join or by calling
+    <programlisting>
+        net ads dns register
+    </programlisting>
+    or during Kerberos authentication to create service principal names. This
+    is not supported in samba-tool yet.
+</description>
+
+<value type="default">[netbios name].[realm]</value>
+<value type="example">client-hostname.example.com</value>
+</samba:parameter>
index f779affe54a0258698a886571d8257e669ca14aa..009713090422337e86a28b1200fdbf028907b0f9 100644 (file)
@@ -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;
+}
index df20b04bc7e9370a95543708ef03c2715070c284..661892772600db8085a9023c15241cdd55323b7e 100644 (file)
@@ -217,6 +217,7 @@ class SmbDotConfTests(TestCase):
         'max open files',
         'include system krb5 conf',
         'smbd max async dosmode',
+        'dns hostname',
     ])
 
     def setUp(self):
index 414d19d7439799c0e8a3246e7356b008baa9d825..12307846c4816a875b303f6491cd007ad23c3d03 100644 (file)
@@ -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
  *
index 78162911953d129054e36a09e9ebb7d3cd9658be..622e2290d3cfc93eec2e8d5e019c778f6a7e3b6d 100644 (file)
@@ -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);