Skip to content

Commit

Permalink
Added PAPPL_SOPTIONS_NO_DNS_SD system option to disable DNS-SD regist…
Browse files Browse the repository at this point in the history
…rations (Issue #303)
  • Loading branch information
michaelrsweet committed Oct 31, 2023
1 parent f51179f commit 88d232d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changes in v2.0b1

- Now require libcups v3 or higher.
- Increased `PAPPL_MAX_TYPE` to 128 (Issue #268)
- Added `PAPPL_SOPTIONS_NO_DNS_SD` system option to disable DNS-SD registrations
(Issue #303)
- Added `papplSystemGet/SetIdleShutdown` APIs to get/set the idle shutdown
time in seconds (Issue #304)
- Added "smi55357-device-uri" and "smi55357-driver" Printer Status attributes
Expand Down
3 changes: 2 additions & 1 deletion doc/pappl.html
Original file line number Diff line number Diff line change
Expand Up @@ -7718,7 +7718,8 @@ <h4 class="constants">Constants</h4>
<tr><th>PAPPL_SOPTIONS_DNSSD_HOST </th><td class="description">Use hostname in DNS-SD service names instead of serial number/UUID</td></tr>
<tr><th>PAPPL_SOPTIONS_MULTI_QUEUE </th><td class="description">Support multiple printers</td></tr>
<tr><th>PAPPL_SOPTIONS_NONE </th><td class="description">No options</td></tr>
<tr><th>PAPPL_SOPTIONS_NO_TLS <span class="info">&#160;PAPPL 1.1&#160;</span></th><td class="description">Disable TLS support </td></tr>
<tr><th>PAPPL_SOPTIONS_NO_DNS_SD </th><td class="description">Disable DNS-SD registrations</td></tr>
<tr><th>PAPPL_SOPTIONS_NO_TLS </th><td class="description">Disable TLS support</td></tr>
<tr><th>PAPPL_SOPTIONS_RAW_SOCKET </th><td class="description">Accept jobs via raw sockets</td></tr>
<tr><th>PAPPL_SOPTIONS_USB_PRINTER </th><td class="description">Accept jobs via USB for default printer (embedded Linux only)</td></tr>
<tr><th>PAPPL_SOPTIONS_WEB_INTERFACE </th><td class="description">Enable the standard web pages</td></tr>
Expand Down
6 changes: 5 additions & 1 deletion man/pappl-system.3
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,13 @@ PAPPL_SOPTIONS_NONE
.br
No options
.TP 5
PAPPL_SOPTIONS_NO_DNS_SD
.br
Disable DNS-SD registrations
.TP 5
PAPPL_SOPTIONS_NO_TLS
.br
Disable TLS support
Disable TLS support
.TP 5
PAPPL_SOPTIONS_RAW_SOCKET
.br
Expand Down
4 changes: 2 additions & 2 deletions pappl/dnssd.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ _papplPrinterRegisterDNSSDNoLock(
const char *papermax; // PaperMax string value (legacy)


if (!printer->dns_sd_name || !printer->system->is_running)
if (!printer->dns_sd_name || !printer->system->is_running || (printer->system->options & PAPPL_SOPTIONS_NO_DNS_SD))
return (false);

papplLogPrinter(printer, PAPPL_LOGLEVEL_DEBUG, "Registering DNS-SD name '%s' on '%s'", printer->dns_sd_name, printer->system->hostname);
Expand Down Expand Up @@ -298,7 +298,7 @@ _papplSystemRegisterDNSSDNoLock(


// Make sure we have all of the necessary information to register the system...
if (!system->dns_sd_name || !system->hostname || !system->uuid || !system->is_running)
if (!system->dns_sd_name || !system->hostname || !system->uuid || !system->is_running || (system->options & PAPPL_SOPTIONS_NO_DNS_SD))
return (false);

papplLog(system, PAPPL_LOGLEVEL_DEBUG, "Registering DNS-SD name '%s' on '%s'", system->dns_sd_name, system->hostname);
Expand Down
7 changes: 5 additions & 2 deletions pappl/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,11 @@ papplSystemCreate(
// Load base localizations...
_papplLocLoadAll(system);

// Enable DNS-SD...
system->dns_sd = cupsDNSSDNew((cups_dnssd_error_cb_t)log_dns_sd_error, (void *)system);
if (!(options & PAPPL_SOPTIONS_NO_DNS_SD))
{
// Enable DNS-SD...
system->dns_sd = cupsDNSSDNew((cups_dnssd_error_cb_t)log_dns_sd_error, (void *)system);
}

return (system);

Expand Down
3 changes: 2 additions & 1 deletion pappl/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ enum pappl_soptions_e // System option bits
PAPPL_SOPTIONS_WEB_REMOTE = 0x0080, // Allow remote queue management (vs. localhost only)
PAPPL_SOPTIONS_WEB_SECURITY = 0x0100, // Enable the user/password settings page
PAPPL_SOPTIONS_WEB_TLS = 0x0200, // Enable the TLS settings page
PAPPL_SOPTIONS_NO_TLS = 0x0400 // Disable TLS support @since PAPPL 1.1@
PAPPL_SOPTIONS_NO_TLS = 0x0400, // Disable TLS support
PAPPL_SOPTIONS_NO_DNS_SD = 0x0800 // Disable DNS-SD registrations
};
typedef unsigned pappl_soptions_t; // Bitfield for system options

Expand Down

0 comments on commit 88d232d

Please sign in to comment.