Bug 909454 - gtk printer widget gives "Getting printer information failed" for cups printer
Summary: gtk printer widget gives "Getting printer information failed" for cups printer
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gtk2
Version: 6.3
Hardware: Unspecified
OS: Unspecified
high
medium
Target Milestone: rc
: ---
Assignee: Marek Kašík
QA Contact: Desktop QE
URL:
Whiteboard:
Keywords:
Depends On:
Blocks: 994246
TreeView+ depends on / blocked
 
Reported: 2013-02-08 20:16 UTC by Rui Gouveia
Modified: 2018-12-09 16:56 UTC (History)
6 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2014-10-14 07:40:28 UTC


Attachments (Terms of Use)
Print Dialog with error (34.63 KB, image/png)
2013-02-08 20:16 UTC, Rui Gouveia
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1554 normal SHIPPED_LIVE gtk2, gdk-pixbuf2, librsvg2, and libwmf bug fix and enhancement update 2014-10-14 01:27:57 UTC
GNOME Bugzilla 693738 None None None Never

Description Rui Gouveia 2013-02-08 20:16:46 UTC
Created attachment 695227 [details]
Print Dialog with error

Description of problem:
All the GTK applications are hitting in the bug:
"Getting printer information failed" in Print Dialog

Other application work.

This is very similar to the following bug the IPv6 stack is not an issue here:

gtk printer widget gives "Getting printer information failed" for cups printer and IPv6
https://bugzilla.redhat.com/show_bug.cgi?id=672064

Adding "Listen ::1:631" in cupsd.conf solves the IPv6 issue.


Version-Release number of selected component (if applicable):
cups-1.4.2-48.el6_3.3.x86_64
gtk2-2.18.9-10.el6.x86_64


How reproducible:
Always.


Steps to Reproduce:
1. Install a Print Server (RHEL6.3).
2. Install a Client (RHEL6.3)
3. Try to print in a GTK application. For example, Firefox, gnome-help or gimp. (with others it works).

  
Actual results:

The client can see the shared printers, but the Print Dialog has the Print button disabled and the message is "Getting printer information failed". See attached image.



Expected results:

No error. The button is enabled and printing is possible.


Additional info:

Comment 2 Rui Gouveia 2013-02-13 17:32:52 UTC
Hi,

Doing an strace while the print dialog is invoked I can see that it's trying to connect to the printer server on the default port and not on the configured port.


2665  connect(22, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("192.168.122.99")}, 16) = -1 EINPROGRESS (Operation now in progress)
2665  connect(22, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("192.168.122.99")}, 16) = -1 ECONNREFUSED (Connection refused)
2665  close(22)                         = 0

Comment 3 Rui Gouveia 2013-02-13 19:38:07 UTC
Hi,
Some more digging. Hope it helps.

The lpoptions appear well defined. The printer is accessible at "printer-uri-supported=ipp://192.168.122.99:63101/printers/HP-LaserJet-5200" :

# lpoptions 
auth-info-required=none copies=1 device-uri=ipp://192.168.122.99:63101/printers/HP-LaserJet-5200 job-hold-until=no-hold job-priority=50 marker-change-time=1360357008 marker-colors=none marker-levels=24 marker-names='Black Cartridge HP Q7516A' marker-types=tonerCartridge number-up=1 printer-info='HP LaserJet 5200' printer-is-accepting-jobs=true printer-is-shared=false printer-location='GSS 2' printer-make-and-model='HP LaserJet 5200 Postscript (recommended) on 192.168.122.99' printer-state=3 printer-state-change-time=1360356574 printer-state-reasons=none printer-type=27439302 printer-uri-supported=ipp://192.168.122.99:63101/printers/HP-LaserJet-5200

But the strace shows that the port number is ignored and the default ipp port is used instead :

2665  connect(22, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("192.168.122.99")}, 16) = -1 EINPROGRESS (Operation now in progress)
2665  connect(22, {sa_family=AF_INET, sin_port=htons(631), sin_addr=inet_addr("192.168.122.99")}, 16) = -1 ECONNREFUSED (Connection refused)
2665  close(22)                         = 0

The following is a tcpdump from the server side :

# tcpdump -nn -v -i any host 192.168.122.228
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
19:15:56.413416 IP (tos 0x0, ttl 64, id 52810, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.122.228.50929 > 192.168.122.99.631: Flags [S], cksum 0x1a9c (correct), seq 2187211175, win 14600, options [mss 1460,sackOK,TS val 6815725 ecr 0,nop,wscale 7], length 0
19:15:56.413462 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.122.99.631 > 192.168.122.228.50929: Flags [R.], cksum 0xbbc8 (correct), seq 0, ack 2187211176, win 0, length 0
19:16:06.240436 IP (tos 0x0, ttl 64, id 55959, offset 0, flags [DF], proto TCP (6), length 209)


Versions:

# rpm -q cups gtk2
cups-1.4.2-48.el6_3.3.x86_64
gtk2-2.18.9-10.el6.x86_64


I'm not a programmer (simple scripts only), but in the following code, from .../rpmbuild/SOURCES/gtk+-2.18.9/modules/printbackends/cups/gtkprintbackendcups.c , I don't understand where the variable port is instantiated:

      if (!printer)
        {
          GtkPrinterCups *cups_printer;
          char uri[HTTP_MAX_URI];       /* Printer URI */
          char method[HTTP_MAX_URI];    /* Method/scheme name */
          char username[HTTP_MAX_URI];  /* Username:password */
          char hostname[HTTP_MAX_URI];  /* Hostname */
          char resource[HTTP_MAX_URI];  /* Resource name */
          int  port;                    /* Port number */
          char *cups_server;            /* CUPS server */
          
          list_has_changed = TRUE;
          cups_printer = gtk_printer_cups_new (printer_name, backend);

          cups_printer->device_uri = g_strdup_printf ("/printers/%s", printer_name);

          /* Check to see if we are looking at a class */
          if (member_uris)
            {
              cups_printer->printer_uri = g_strdup (member_uris);
              /* TODO if member_uris is a class we need to recursivly find a printer */
              GTK_NOTE (PRINTING,
                        g_print ("CUPS Backend: Found class with printer %s\n", member_uris));
            }
          else
            {
              cups_printer->printer_uri = g_strdup (printer_uri);
              GTK_NOTE (PRINTING,
                        g_print ("CUPS Backend: Found printer %s\n", printer_uri));
            }

#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 2) || CUPS_VERSION_MAJOR > 1
          httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->printer_uri, 
                           method, sizeof (method), 
                           username, sizeof (username),
                           hostname, sizeof (hostname),
                           &port, 
                           resource, sizeof (resource));

#else
          httpSeparate (cups_printer->printer_uri, 
                        method, 
                        username, 
                        hostname,
                        &port, 
                        resource);
#endif

          if (strncmp (resource, "/printers/", 10) == 0)
            {
              cups_printer->ppd_name = g_strdup (resource + 10);
              GTK_NOTE (PRINTING,
                        g_print ("CUPS Backend: Setting ppd name '%s' for printer/class '%s'\n", cups_printer->ppd_name, printer_name));
            }

          gethostname (uri, sizeof (uri));
          cups_server = g_strdup (cupsServer());

          if (strcasecmp (uri, hostname) == 0)
            strcpy (hostname, "localhost");

          /* if the cups server is local and listening at a unix domain socket 
		* then use the socket connection
           */
          if ((strstr (hostname, "localhost") != NULL) &&
              (cups_server[0] == '/'))
            strcpy (hostname, cups_server);

          g_free (cups_server);

          cups_printer->default_cover_before = g_strdup (default_cover_before);
          cups_printer->default_cover_after = g_strdup (default_cover_after);

          cups_printer->hostname = g_strdup (hostname);
          cups_printer->port = port;
          
          cups_printer->auth_info_required = g_strdupv (auth_info_required);
          g_strfreev (auth_info_required);

          printer = GTK_PRINTER (cups_printer);



Thank you

Comment 4 RHEL Product and Program Management 2013-02-18 06:47:11 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 10 Rui Gouveia 2013-08-21 12:57:47 UTC
Hi,

FYI, I did more testes regarding this issue, suspecting a wrong configuration, but I just confirmed the issue.

Server has in cupsd.conf:

  Port 63101
  BrowsePort 63101

Client has cupsd.conf:

  BrowsePoll 192.168.122.99:63101
  BrowsePort 63101


Firewall allows traffic:

7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp
dpt:63101 
8    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp
dpt:63101 

SELinux allows the non-standaard port 63101 in the server and the client:

# semanage port -l | grep ipp
ipp_port_t                     tcp      63101, 631, 8610-8614
ipp_port_t                     udp      63101, 631, 8610-8614


All the non-Gtk application work as expected, using only the port 63101/tcp and
udp, but when the Gtk Print Dialog starts the following communications is
attempted and fails:

20:24:33.886932 IP 192.168.122.228.52755 > 192.168.122.99.631: Flags [S], seq
1291153458, win 14600, options [mss 1460,sackOK,TS val 5593038 ecr 0,nop,wscale
7], length 0
20:24:33.887248 IP 192.168.122.99.631 > 192.168.122.228.52755: Flags [R.], seq
0, ack 1291153459, win 0, length 0

I tried setting the IPP_PORT Env variable without success.


Thank you

Comment 11 Rui Gouveia 2013-08-21 13:18:28 UTC
Looking at the function _cupsSetDefaults(void)...

If I define the ENV vars: IPP_PORT and CUPS_SERVER it works!!! :)

Since the server is parsed correctly, the problem must be in the port
selection. Agree? Correct me if I'm wrong.

### If cg->ipp_port is not defined

  if (!cg->ipp_port)
  {
    const char          *ipp_port;      /* IPP_PORT environment variable */
    struct servent      *service;       /* Port number info */  

### ipp_port takes the value from ENV(IPP_PORT) and is not null.

    if ((ipp_port = getenv("IPP_PORT")) != NULL)
    {

### If conversion from string to integer generates an
### error cg->ipp_port takes the default value CUPS_DEFAULT_IPP_PORT

      if ((cg->ipp_port = atoi(ipp_port)) <= 0)
        cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    }

### else, if ipp does not exists in the system services
### or service->s_port has an invalid value, then
### cg->ipp_port takes the default value CUPS_DEFAULT_IPP_PORT

    else if ((service = getservbyname("ipp", NULL)) == NULL ||
             service->s_port <= 0)
      cg->ipp_port = CUPS_DEFAULT_IPP_PORT;

### else, cg->ipp_port takes the value of the services value.

    else
      cg->ipp_port = ntohs(service->s_port);
  }


So, if IPP_PORT is defined, all is ok, but if not, this code jumps directly to getting the default value in services.

So, where is the value in the configuration read ? I may be analysing the wrong code...

Help is appreciated.


Thank you

Comment 12 RHEL Product and Program Management 2013-10-14 04:16:06 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 13 Rui Gouveia 2013-10-14 08:50:35 UTC
Hi,

I found a workaround. Define:

$ export CUPS_SERVER=<Print server IP or name>
$ export IPP_PORT=<non-standard port>

Comment 16 Marek Kašík 2014-06-13 16:02:04 UTC
Created attachment 908637 [details]
The patch

Comment 20 errata-xmlrpc 2014-10-14 07:40:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1554.html


Note You need to log in before you can comment on or make changes to this bug.