← Back to team overview

touch-packages team mailing list archive

[Bug 1352809] Re: /usr/bin/lp on Trusty using -h option doesn't work as expected

 

Analysis of the upstream patch that fixes the problem
================================
The new _cupsSetDefaults() in cups v2.1 has been refactored to use a _cups_client_conf_t structure that holds the user defined value. This structure gets populated first by cups_init_client_conf(), that reads the /etc/cups/client.conf and ~/.cups/client.conf if present.

It then runs cups_finalize_client_conf() that reads in the environment
variables in the _cups_client_conf_t structure.

A new check is added to verify if a value already exists in cg->server
before calling cupsSetServer() on the ENV variable collected value which
is stored in the structure.

The original patch is :
  if (!cg->server[0] || !cg->ipp_port)
    cupsSetServer(cc.server_name);

  if (!cg->ipp_port)
  {
    const char  *ipp_port;              /* IPP_PORT environment variable */

    if ((ipp_port = getenv("IPP_PORT")) != NULL)
    {
      if ((cg->ipp_port = atoi(ipp_port)) <= 0)
        cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
    }
    else
      cg->ipp_port = CUPS_DEFAULT_IPP_PORT;
  }

This portion of code is found in 1.7.2 in the cups_read_client_conf()
starting at line 1027.  The server name given to cupsSetServer() is
conditional to the value set in cups_server :

  if ((!cg->server[0] || !cg->ipp_port) && cups_server)
    cupsSetServer(cups_server);

So in order to correctly trigger the server name definition, the
following patch is needed :

Index: cups-1.7.5/cups/usersys.c
===================================================================
--- cups-1.7.5.orig/cups/usersys.c      2015-02-04 12:58:39.000000000 +0100
+++ cups-1.7.5/cups/usersys.c   2015-02-04 13:10:54.062431647 +0100
@@ -891,6 +891,12 @@
     }

    /*
+    * Check if values have been provided as CLI options
+    */
+    if (cg->server[0])
+      cups_server = cg->server;
+
+   /*
     * Read the configuration file and apply any environment variables; both
     * functions handle NULL cups_file_t pointers...
     */
~

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to cups in Ubuntu.
https://bugs.launchpad.net/bugs/1352809

Title:
  /usr/bin/lp on Trusty using -h option doesn't work as expected

Status in cups package in Ubuntu:
  In Progress
Status in cups source package in Trusty:
  Confirmed
Status in cups source package in Utopic:
  Confirmed

Bug description:
  1) The release of Ubuntu you are using, via 'lsb_release -rd' or
  System -> About Ubuntu

  Description:	Ubuntu 14.04 LTS
  Release:	14.04
  Codename:	trusty

  
  2) The version of the package you are using, via 'apt-cache policy pkgname' or by checking in Software Center

  cups-client:
    Installed: 1.7.2-0ubuntu1.1

  3) What you expected to happen

  When using lp -h to send a print job to a printer, I expected to the
  job to be sent to the printer and to override any env variables set or
  conf file setting

  4) What happened instead

  To summarise the behaviour I'm seeing

  1) with CUPS_SERVER env variable unset and no ServerName set in /etc/cups/client.conf, we see that using lp -h with hostnames gives us error "lp: Error - add '/version=1.1' to server name."
  Using IPs sends the job to the printer as expected.

  2) with CUPS_SERVER env variable set using hostname with/without port
  and no ServerName set in /etc/cups/client.conf, we see that the only
  time it sends a job is when an IP and port are used. Otherwise it
  seems to error. I believe it's using the env variable, even though -h
  is being used.

  3) with CUPS_SERVER env variable set using IP address with/without
  port and no ServerName set in /etc/cups/client.conf we see that the
  job is always sent using lp -h but it is always sent to the value in
  env variable, thus ignoring the command line.

  ===

  with CUPS_SERVER env variable unset and no ServerName option set in
  /etc/cups/client.conf

  $ lp test2.txt
  lp: Error - scheduler not responding. (expected as no server is set or specified)

  Using hostname
  $ lp -h server1:631 test2.txt
  lp: Error - add '/version=1.1' to server name.

  $ lp -h server1 test2.txt
  lp: Error - add '/version=1.1' to server name.

  Using IP address
  $ lp -h 192.168.254.8 test2.txt
  request id is PDF-54 (1 file(s))

  $ lp -h 192.168.254.8:631 test2.txt
  request id is PDF-55 (1 file(s))

  ===

  With CUPS_SERVER env variable *set CUPS_SERVER=server1

  $ lp test2.txt
  lp: Error - add '/version=1.1' to server name.

  Using hostname
  $ lp -h server1 test2.txt
  lp: Error - add '/version=1.1' to server name.

  $ lp -h server1:631 test2.txt
  lp: Error - add '/version=1.1' to server name.

  Using IP address
  $ lp -h 192.168.254.8 test2.txt
  lp: Error - add '/version=1.1' to server name.

  $ lp -h 192.168.254.8:631 test2.txt
  request id is PDF-56 (1 file(s))

  ===

  With CUPS_SERVER env variable *set CUPS_SERVER=server:631

  Same results as above

  ===

  With CUPS_SERVER env variable *set CUPS_SERVER=192.168.254.8:631

  $ lp -h 555.555.555.555 test2.txt
  request id is PDF-66 (1 file(s))

  ===

  With CUPS_SERVER env variable *set CUPS_SERVER=192.168.254.8

  Same results as above

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cups/+bug/1352809/+subscriptions


References