]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix default hostname on macOS - current versions of macOS use new ".lan" domain
authorMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Oct 2020 20:37:52 +0000 (16:37 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Oct 2020 20:37:52 +0000 (16:37 -0400)
for mDNS instead of ".local", which causes the IPP Everywhere self-certification
tests to fail.

tools/ippeveprinter.c

index 96d4c71b039aa85d093a17aaa279b8c807ea881d..5467c13b54b6eae1b854940440ea0d6a41a1b6f7 100644 (file)
@@ -1712,17 +1712,21 @@ create_printer(
   }
   else
   {
-    char       temp[1024];             /* Temporary string */
+    char       temp[1024],             /* Temporary string */
+               *tempptr;               /* Pointer into temporary string */
 
 #ifdef HAVE_AVAHI
     const char *avahi_name = avahi_client_get_host_name_fqdn(DNSSDClient);
 
     if (avahi_name)
-      printer->hostname = strdup(avahi_name);
+      strlcpy(temp, avahi_name, sizeof(temp));
     else
 #endif /* HAVE_AVAHI */
 
-    printer->hostname = strdup(httpGetHostname(NULL, temp, sizeof(temp)));
+    if ((tempptr = strstr(httpGetHostname(NULL, temp, sizeof(temp)), ".lan")) != NULL && !tempptr[5])
+      strlcpy(tempptr, ".local", sizeof(temp) - (size_t)(tempptr - temp));
+
+    printer->hostname = strdup(temp);
   }
 
   _cupsRWInit(&(printer->rwlock));