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

Bug #1352809 reported by Michael Cunningham on 2014-08-05
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cups (Ubuntu)
Medium
Louis Bouchard
Trusty
Medium
Louis Bouchard
Utopic
Medium
Louis Bouchard

Bug Description

[SRU justification]
The -h option should override the value stored in the CUPS_SERVER environment variable

[Impact]
Without this fix, user is unable to define the printserver to use with the -h option

[Fix]
Verify if the -h option has defined the printserver before using CUPS_SERVER to define it.

[Test Case]
$ export CUPS_SERVER="blah"
$ lp -h {valid printserver} -d {printqueue} /etc/hosts

Without the fix :
lp: No such file or directory

With the fix :
request id is {printqueue}-37 (1 file(s))

[Regression]
None expected. New code path (from upstream patch) is only triggered if
-h option is used.

[Original description of the problem]

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

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cups (Ubuntu):
status: New → Confirmed
Louis Bouchard (louis) on 2014-12-18
Changed in cups (Ubuntu):
importance: Undecided → Medium
assignee: nobody → Louis Bouchard (louis-bouchard)
tags: added: cts
Louis Bouchard (louis) wrote :
Louis Bouchard (louis) wrote :

Hello,

I have proposed a patch upstream and am waiting for their answer. I will let you know as soon as I hear from them.

Changed in cups (Ubuntu):
status: Confirmed → In Progress
Changed in cups (Ubuntu Trusty):
importance: Undecided → Medium
Changed in cups (Ubuntu Utopic):
importance: Undecided → Medium
Changed in cups (Ubuntu Trusty):
status: New → Confirmed
Changed in cups (Ubuntu Utopic):
status: New → Confirmed
Louis Bouchard (louis) wrote :

The upstream bug (L4561) has been identified as a duplicate of the following bug :

 https://www.cups.org/str.php?L4528+P-1+S-2+C0+I0+E0+Q

This one provides a fix for CUPS v2.1 which encompass much more than our current issue. I'm working on backporting the fix for the CUPS_SERVER issue.

I should be able to propose a fix for Vivid soon.

Louis Bouchard (louis) wrote :

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...
     */
~

Louis Bouchard (louis) wrote :

debdiff for vivid

tags: added: patch
Till Kamppeter (till-kamppeter) wrote :

Patch pushed into Debian GIT repository for CUPS. Thank you very much for the patch.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 1.7.5-10ubuntu2

---------------
cups (1.7.5-10ubuntu2) vivid; urgency=medium

    * Fix -h option not honoured when CUPS_SERVER variable
      is defined. (LP: #1352809)
 -- Louis Bouchard <email address hidden> Wed, 04 Feb 2015 13:07:11 +0100

Changed in cups (Ubuntu):
status: In Progress → Fix Released
Louis Bouchard (louis) on 2015-02-09
Changed in cups (Ubuntu Trusty):
status: Confirmed → In Progress
Changed in cups (Ubuntu Utopic):
status: Confirmed → In Progress
Changed in cups (Ubuntu Trusty):
assignee: nobody → Louis Bouchard (louis-bouchard)
Changed in cups (Ubuntu Utopic):
assignee: nobody → Louis Bouchard (louis-bouchard)
Louis Bouchard (louis) wrote :

debdiff for trusty's SRU

Louis Bouchard (louis) wrote :

debdiff for Utopic

Louis Bouchard (louis) on 2015-02-09
description: updated

Hello Michael, or anyone else affected,

Accepted cups into utopic-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/cups/1.7.5-3ubuntu3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in cups (Ubuntu Utopic):
status: In Progress → Fix Committed
tags: added: verification-needed
Chris J Arges (arges) wrote :

Hello Michael, or anyone else affected,

Accepted cups into trusty-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/cups/1.7.2-0ubuntu1.4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in cups (Ubuntu Trusty):
status: In Progress → Fix Committed
Louis Bouchard (louis) wrote :

Verified for both Utopic & Trusty. Thanks

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 1.7.5-3ubuntu3

---------------
cups (1.7.5-3ubuntu3) utopic-proposed; urgency=medium

  * Fix -h option not honoured when CUPS_SERVER variable
    is defined. (LP: #1352809)
 -- Louis Bouchard <email address hidden> Mon, 09 Feb 2015 11:36:08 +0100

Changed in cups (Ubuntu Utopic):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for cups has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 1.7.2-0ubuntu1.4

---------------
cups (1.7.2-0ubuntu1.4) trusty-proposed; urgency=medium

  * Fix -h option not honoured when CUPS_SERVER variable
    is defined. (LP: #1352809)
 -- Louis Bouchard <email address hidden> Mon, 09 Feb 2015 11:22:42 +0100

Changed in cups (Ubuntu Trusty):
status: Fix Committed → Fix Released

The bug is back in cups-client 1.7.2-0ubuntu1.7!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers