Skip to content

Commit

Permalink
Take domain sockets into account
Browse files Browse the repository at this point in the history
  • Loading branch information
zdohnal committed Mar 1, 2024
1 parent ade3c3b commit 47f6e5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion 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 || (printer->system->options & PAPPL_SOPTIONS_NO_DNS_SD) || !system->reghost)
if (!printer->dns_sd_name || !printer->system->is_running || (printer->system->options & PAPPL_SOPTIONS_NO_DNS_SD) || !system->reghost || !printer->system->reghost)
return (false);

papplLogPrinter(printer, PAPPL_LOGLEVEL_DEBUG, "Registering DNS-SD name '%s' on '%s'", printer->dns_sd_name, printer->system->reghost);
Expand Down
18 changes: 11 additions & 7 deletions pappl/system-accessors.c
Original file line number Diff line number Diff line change
Expand Up @@ -2598,8 +2598,10 @@ papplSystemSetPrinterDrivers(
// registered.
//
// This function sets the hostname under which services will be registered - it can
// be localhost or the current hostname, so it denies setting of different hostname
// to prevent masquerading itself as a different machine.
// be localhost or the current hostname, otherwise registration hostname will be empty
// and service registration will be disabled (to prevent publishing service for
// different machine or when application listens on domain socket). In case 'name' is NULL,
// the current hostname is set as registration hostname.
//

void
Expand All @@ -2616,18 +2618,20 @@ papplSystemSetRegHostName(

if (system->hostname)
{
if (name && (!strcasecmp(system->hostname, name) || !strcasecmp(name, "localhost")))
value = name;

if (!value)
if (!name)
value = system->hostname;
else if (!strcasecmp(name, system->hostname))
goto end;
else if (!strcasecmp(name, "localhost"))
value = "localhost";

if (system->reghost)
free(system->reghost);

system->reghost = strdup(value);
system->reghost = value ? strdup(value) : NULL;
}

end:
_papplRWUnlock(system);
}

Expand Down

0 comments on commit 47f6e5d

Please sign in to comment.