Skip to content

Commit

Permalink
Add support for DNSSDHostName configuration directive (Issue #5071)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael R Sweet committed Nov 3, 2017
1 parent 6646208 commit d7b3868
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
13 changes: 12 additions & 1 deletion man/cupsd.conf.man.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.\" which should have been included with this file. If this file is
.\" file is missing or damaged, see the license at "http:https://www.cups.org/".
.\"
.TH cupsd.conf 5 "CUPS" "19 October 2017" "Apple Inc."
.TH cupsd.conf 5 "CUPS" "3 November 2017" "Apple Inc."
.SH NAME
cupsd.conf \- server configuration file for cups
.SH DESCRIPTION
Expand Down Expand Up @@ -52,6 +52,12 @@ The default access log level is "actions".
.br
Specifies whether to purge job history data automatically when it is no longer required for quotas.
The default is "No".
.\"#BrowseDNSSDSubTypes
.TP 5
.BI BrowseDNSSDSubTypes _subtype[,...]
Specifies a list of Bonjour sub-types to advertise for each shared printer.
For example, "BrowseDNSSDSubTypes _cups,_print" will tell network clients that both CUPS sharing and IPP Everywhere are supported.
The default is "_cups" which is necessary for printer sharing to work between systems using CUPS.
.\"#BrowseLocalProtocols
.TP 5
\fBBrowseLocalProtocols all\fR
Expand Down Expand Up @@ -127,6 +133,11 @@ The default is "Yes".
Specifies the delay for updating of configuration and state files.
A value of 0 causes the update to happen as soon as possible, typically within a few milliseconds.
The default value is "30".
.\"#DNSSDHostName
.TP 5
.BI DNSSDHostName hostname.example.com
Specifies the fully-qualified domain name for the server that is used for Bonjour sharing.
The default is typically the server's ".local" hostname.
.\"#ErrorPolicy
.TP 5
\fBErrorPolicy abort-job\fR
Expand Down
4 changes: 4 additions & 0 deletions scheduler/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ static const cupsd_var_t cupsd_vars[] =
{ "DefaultPolicy", &DefaultPolicy, CUPSD_VARTYPE_STRING },
{ "DefaultShared", &DefaultShared, CUPSD_VARTYPE_BOOLEAN },
{ "DirtyCleanInterval", &DirtyCleanInterval, CUPSD_VARTYPE_TIME },
#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
{ "DNSSDHostName", &DNSSDSubTypes, CUPSD_VARTYPE_STRING },
#endif /* HAVE_DNSSD || HAVE_AVAHI */
{ "ErrorPolicy", &ErrorPolicy, CUPSD_VARTYPE_STRING },
{ "FilterLimit", &FilterLimit, CUPSD_VARTYPE_INTEGER },
{ "FilterNice", &FilterNice, CUPSD_VARTYPE_INTEGER },
Expand Down Expand Up @@ -746,6 +749,7 @@ cupsdReadConfiguration(void)

#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
cupsdSetString(&DNSSDSubTypes, "_cups,_print");
cupsdClearString(&DNSSDHostName);
#endif /* HAVE_DNSSD || HAVE_AVAHI */

cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
Expand Down
58 changes: 33 additions & 25 deletions scheduler/dirsvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

/*
Expand Down
4 changes: 0 additions & 4 deletions xcode/CUPS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,6 @@
728FB7EC1536161C005426E1 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
728FB7EF1536167A005426E1 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = /usr/lib/libiconv.dylib; sourceTree = "<absolute>"; };
728FB7F01536167A005426E1 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = /usr/lib/libresolv.dylib; sourceTree = "<absolute>"; };
729D4B561A2CB48700692B21 /* CHANGES-2.0.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "CHANGES-2.0.txt"; path = "../CHANGES-2.0.txt"; sourceTree = "<group>"; };
72A4332F155844CF002E172D /* libcups_static.a */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
72A8B3D61C188BDE00A1A547 /* ppd-util.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "ppd-util.c"; path = "../cups/ppd-util.c"; sourceTree = "<group>"; };
72C16CB8137B195D007E4BF4 /* file.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = file.c; path = ../scheduler/file.c; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -3570,7 +3569,6 @@
72E65BD818DC818400097E89 /* org.cups.cupsd.socket.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = org.cups.cupsd.socket.in; path = ../scheduler/org.cups.cupsd.socket.in; sourceTree = SOURCE_ROOT; };
72E65BD918DC850A00097E89 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; name = Makefile; path = ../Makefile; sourceTree = "<group>"; };
72E65BDC18DC852700097E89 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; name = Makefile; path = ../scheduler/Makefile; sourceTree = SOURCE_ROOT; };
72E65BDD18DCA35700097E89 /* CHANGES-1.7.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = "CHANGES-1.7.txt"; path = "../CHANGES-1.7.txt"; sourceTree = "<group>"; };
72E65BDE18DCA35700097E89 /* CHANGES.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CHANGES.md; path = ../CHANGES.md; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = "<none>"; };
72E65BDF18DCA35700097E89 /* CREDITS.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CREDITS.md; path = ../CREDITS.md; sourceTree = "<group>"; };
72E65BE018DCA35700097E89 /* INSTALL.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = INSTALL.md; path = ../INSTALL.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5221,8 +5219,6 @@
72E65BC818DC7A6B00097E89 /* api-ppd.shtml */,
72E65BCB18DC7A9800097E89 /* api-raster.header */,
72E65BCC18DC7A9800097E89 /* api-raster.shtml */,
72E65BDD18DCA35700097E89 /* CHANGES-1.7.txt */,
729D4B561A2CB48700692B21 /* CHANGES-2.0.txt */,
72E65BDE18DCA35700097E89 /* CHANGES.md */,
72E65BDF18DCA35700097E89 /* CREDITS.md */,
274561471F545B2E000378E4 /* cupspm.md */,
Expand Down

0 comments on commit d7b3868

Please sign in to comment.