From: Michael R Sweet Date: Wed, 7 Oct 2020 20:37:52 +0000 (-0400) Subject: Fix default hostname on macOS - current versions of macOS use new ".lan" domain X-Git-Tag: v2.3.3op1~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9122816d5d5ccedb155aca7748025ca25487d719;p=thirdparty%2Fcups.git Fix default hostname on macOS - current versions of macOS use new ".lan" domain for mDNS instead of ".local", which causes the IPP Everywhere self-certification tests to fail. --- diff --git a/tools/ippeveprinter.c b/tools/ippeveprinter.c index 96d4c71b03..5467c13b54 100644 --- a/tools/ippeveprinter.c +++ b/tools/ippeveprinter.c @@ -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));