[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#878148: cups: Default ServerName wrong/not in sync with manual



Le jeudi, 12 octobre 2017, 16.34:48 h CEST Dominik George a écrit :
> I said that I cannot access CUPS from the local network, not from loopback.

The title of this bug is "Default ServerName wrong/not in sync with manual". 
I'm not sure I understand whether you think the documentation should be 
changed, or whether the _code_ should be changed. Could you please clarify?

From the documentation, you need to have both a network-accessible IP in a 
`Listen` stanza, as well as the hostnames you want the scheduler to be 
accesssible to be listed in either `ServerName` and/or `ServerAlias`.

What I can say is that from the source (scheduler/conf.c, around lines 956 in 
stable) https://sources.debian.net/src/cups/2.2.1-8/scheduler/conf.c/#L956

>   else
>   {
>     if (gethostname(temp, sizeof(temp)))
>     {  
>       cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",    
>                       strerror(errno));
>       strlcpy(temp, "localhost", sizeof(temp));
>     }
>     cupsdSetString(&ServerName, temp);

… ServerName is set from gethostname(2), which, by their manpages, return the 
same value as hostname(1), aka uname(2)'s nodename, which you can retrieve 
from $ uname -n.

ServerName is set around these lines and there are various heuristics which 
add ServerAliases to that configuration. All these are logged at the 'debug' 
level. I've added a patch to log the ServerName cups takes:

--- a/scheduler/conf.c
+++ b/scheduler/conf.c
@@ -891,6 +891,7 @@ cupsdReadConfiguration(void)
     }
 
     cupsdSetString(&ServerName, temp);
+    cupsdLogMessage(CUPSD_LOG_DEBUG, "Set ServerName %s", temp);

With this in place, and debugging enabled via `cupsctl --debug-logging` (see 
[0] for a very good documentation), a restart of the server gives me:

D [12/Oct/2017:17:21:25 +0200] Set ServerName gyllingar
D [12/Oct/2017:17:21:25 +0200] Added auto ServerAlias gyllingar

And:
$ hostname -f
gyllingar

What is it that you get? And do you still think there's discrepancy between 
code and documentation? If so, which one do you think is wrong?

Thanks in advance,

Cheers,
    OdyX

[0] https://wiki.debian.org/
DissectingandDebuggingtheCUPSPrintingSystem#The_CUPS_Error_Log

Reply to: