Invalid server URI in printer/classes pages in the web interface #3022

Closed
michaelrsweet opened this Issue Nov 25, 2008 · 14 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Nov 25, 2008

Version: 1.3.9
CUPS.org User: ppoilbarbe

When accessing to the "/printers" or "/classes" page via the web administration tool, the server address is systematically set to 127.0.0.1 whatever was the address when accessing the page.
For example if you access: http://mycupsserver.domain.tld:631/printers you have all the defined printers but when you try to access the printer (clic on icon) or manipulate it (clic on buttons) there is an access error since we are not on the machine where the cups server is running.
The ServerName directive in cupsd.conf is set to mycupsserver.domùain.tld.
If we try whith the ip address, there is the same kind of result.
I have just upgraded the cupsd server to 1.3.9 (compiled from sources) and it was working in previous version (1.1)

Collaborator

michaelrsweet commented Nov 27, 2008

CUPS.org User: mike

Is mycupsserver.domain.tld mapped to 127.0.0.1, even as a secondary address?

Collaborator

michaelrsweet commented Dec 5, 2008

CUPS.org User: hebron

This is the same problem I had with version 1.3.9.
Version 1.3.8 works okay, though. See STR #3026.

Collaborator

michaelrsweet commented Dec 5, 2008

CUPS.org User: mike

Please attach the /etc/cups/cupsd.conf, /etc/hosts, /etc/resolv.conf, and /var/log/cups/error_log files from the affected system.

Collaborator

michaelrsweet commented Dec 8, 2008

CUPS.org User: ppoilbarbe

The ip address of the server (this is a master server of a cluster) has its own address on a line in the hosts file, with its fully qualified name as the first name.

Collaborator

michaelrsweet commented Dec 8, 2008

CUPS.org User: mike

What does the "hostname" command report?

Collaborator

michaelrsweet commented Dec 9, 2008

CUPS.org User: ppoilbarbe

oscar.cls.fr as expected/

Collaborator

michaelrsweet commented Dec 11, 2008

CUPS.org User: hebron

/etc/nsswitch.conf might also be of importance in this issue.
In my case the hosts line reads:

hosts: files nis

and so /etc/resolv.conf shouldn't matter. Our host name
lookups come from nis. But it appears that cups 1.3.9 is
ignoring nis lookups and is trying to do a DNS lookup.

Collaborator

michaelrsweet commented Dec 12, 2008

CUPS.org User: ppoilbarbe

We don't have nis on hosts line in nsswitch.conf, just:

hosts: files dns

Collaborator

michaelrsweet commented Dec 15, 2008

CUPS.org User: hebron

Please attach the /etc/cups/cupsd.conf, /etc/hosts,
/etc/resolv.conf, and /var/log/cups/error_log files from the
affected system.

I've posted these files from my system
(conf_and_log_files2.tar.bz2). The system is CentOS Linux 5.2
running on x86_64. I did a fresh build of cups 1.3.9 and
configured it as indicated in the posted files.

The problem happens when accessing the CUPS web interface from
another machine which is not running CUPS. If I go to the
"printers" tab and then hover the cursor over any of the printer
modification buttons, such as "Modify Printer" or "Set Printer
Options", the status bar of the browser shows:

https://127.0.0.1:631/admin/...

This link doesn't work, of course, because my local machine is
not running cups and doesn't have port 631 active.

Best regards,

John

Collaborator

michaelrsweet commented Dec 16, 2008

CUPS.org User: ppoilbarbe

Yes I did forget to say this, the computer running the web browser does not have a cups server running (on one has it).

Collaborator

michaelrsweet commented Jan 9, 2009

CUPS.org User: mike

Try the attached patch - it basically adds the raw IP addresses to the list of "local" server addresses.

Collaborator

michaelrsweet commented Jan 12, 2009

CUPS.org User: ppoilbarbe

It works. Thanks.

Collaborator

michaelrsweet commented Jan 12, 2009

CUPS.org User: mike

Fixed in Subversion repository.

Collaborator

michaelrsweet commented Jan 12, 2009

"str3022.patch":

Index: cgi-bin/ipp-var.c

--- cgi-bin/ipp-var.c (revision 8214)
+++ cgi-bin/ipp-var.c (working copy)
@@ -778,7 +778,7 @@
int urlsize, /* I - Size of URL buffer /
const char *newresource) /
I - Replacement resource */
{

  • char method[HTTP_MAX_URI],

  • char scheme[HTTP_MAX_URI],
    userpass[HTTP_MAX_URI],
    hostname[HTTP_MAX_URI],
    rawresource[HTTP_MAX_URI],
    @@ -825,13 +825,13 @@

  • Convert the URI to a URL...
    */

  • httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,

  • httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass,
    sizeof(userpass), hostname, sizeof(hostname), &port,
    rawresource, sizeof(rawresource));

  • if (!strcmp(method, "ipp") ||

  •  !strcmp(method, "http") ||
    
  •  !strcmp(method, "https"))
    
  • if (!strcmp(scheme, "ipp") ||

  •  !strcmp(scheme, "http") ||
    
  •  !strcmp(scheme, "https"))
    

    {
    if (newresource)
    {
    @@ -870,7 +870,9 @@

    • Map local access to a local URI...
      */
  • if (!strcasecmp(hostname, "localhost") ||

  • if (!strcasecmp(hostname, "127.0.0.1") ||

  • !strcasecmp(hostname, "[::1]") ||

  • !strcasecmp(hostname, "localhost") ||
    !strncasecmp(hostname, "localhost.", 10) ||
    !strcasecmp(hostname, server) ||
    !strcasecmp(hostname, servername))

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment