]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/dirsvc.c
Add support for DNSSDHostName configuration directive (Issue #5071)
[thirdparty/cups.git] / scheduler / dirsvc.c
index dba2b7f598774bb0a28ed44b83c88e5b16acee22..c6f6be44312da6c91a2d5c607b845f4b0566fd0c 100644 (file)
@@ -1456,23 +1456,24 @@ dnssdUpdateDNSSDName(int from_callback) /* I - Called from callback? */
       cupsdSetString(&DNSSDComputerName, ServerName);
     }
 
-   /*
-    * Get the local hostname from the dynamic store...
-    */
-
-    cupsdClearString(&DNSSDHostName);
-
-    if ((nameRef = SCDynamicStoreCopyLocalHostName(sc)) != NULL)
+    if (!DNSSDHostName)
     {
-      if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer),
-                            kCFStringEncodingUTF8))
+     /*
+      * Get the local hostname from the dynamic store...
+      */
+
+      if ((nameRef = SCDynamicStoreCopyLocalHostName(sc)) != NULL)
       {
-        cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "Dynamic store host name is \"%s\".", nameBuffer);
-       cupsdSetString(&DNSSDHostName, nameBuffer);
-      }
+       if (CFStringGetCString(nameRef, nameBuffer, sizeof(nameBuffer),
+                              kCFStringEncodingUTF8))
+       {
+         cupsdLogMessage(CUPSD_LOG_DEBUG,
+                         "Dynamic store host name is \"%s\".", nameBuffer);
+         cupsdSetString(&DNSSDHostName, nameBuffer);
+       }
 
-      CFRelease(nameRef);
+       CFRelease(nameRef);
+      }
     }
 
     if (!DNSSDHostName)
@@ -1517,26 +1518,33 @@ dnssdUpdateDNSSDName(int from_callback) /* I - Called from callback? */
   if (DNSSDClient)
   {
     const char *host_name = avahi_client_get_host_name(DNSSDClient);
-    const char *host_fqdn = avahi_client_get_host_name_fqdn(DNSSDClient);
 
     cupsdSetString(&DNSSDComputerName, host_name ? host_name : ServerName);
 
-    if (host_fqdn)
-      cupsdSetString(&DNSSDHostName, host_fqdn);
-    else if (strchr(ServerName, '.'))
-      cupsdSetString(&DNSSDHostName, ServerName);
-    else
-      cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+    if (!DNSSDHostName)
+    {
+      const char *host_fqdn = avahi_client_get_host_name_fqdn(DNSSDClient);
+
+      if (host_fqdn)
+       cupsdSetString(&DNSSDHostName, host_fqdn);
+      else if (strchr(ServerName, '.'))
+       cupsdSetString(&DNSSDHostName, ServerName);
+      else
+       cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+    }
   }
   else
 #  endif /* HAVE_AVAHI */
   {
     cupsdSetString(&DNSSDComputerName, ServerName);
 
-    if (strchr(ServerName, '.'))
-      cupsdSetString(&DNSSDHostName, ServerName);
-    else
-      cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+    if (!DNSSDHostName)
+    {
+      if (strchr(ServerName, '.'))
+       cupsdSetString(&DNSSDHostName, ServerName);
+      else
+       cupsdSetStringf(&DNSSDHostName, "%s.local", ServerName);
+    }
   }
 
  /*