lpoptions -d as root

Bug #2052925 reported by Rudra Trivedi
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cups (Ubuntu)
Fix Released
Low
Unassigned
Jammy
Fix Released
High
Unassigned

Bug Description

Copied from https://github.com/OpenPrinting/cups/issues/454

Yair Yarom submitted Debian bug 1008053 and observed that running lpoptions as root does not update /etc/cups/lpoptions but /root/.cups/lpoptions.

Running lpoptions as root (e.g. "lpoptions -d HP-OfficeJet") should update /etc/cups/lpoptions to be the defaults for all users. But instead it tries to update /root/.cups/lpoptions.

This has been fixed upstream in cups, in debian sid, and mantic. Proposing to add this change in jammy and older (still supported) series as well.

The fix is a one line change in https://github.com/OpenPrinting/cups/pull/456

Thanks.

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

ubuntu@jammy-vm:~$ lsb_release -rd
Description: Ubuntu 22.04.3 LTS
Release: 22.04

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

ubuntu@jammy-vm:~$ apt-cache policy cups
cups:
  Installed: 2.4.1op1-1ubuntu4.7
  Candidate: 2.4.1op1-1ubuntu4.7
  Version table:
 *** 2.4.1op1-1ubuntu4.7 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.4.1op1-1ubuntu4 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages

3) What you expected to happen:

root@jammy-vm:~# lpstat -p
printer HP-Officejet-Pro-8710 is idle. enabled since Thu 01 Feb 2024 03:17:49 PM UTC
root@jammy-vm:~#
root@jammy-vm:~# lpoptions -d HP-Officejet-Pro-8710
copies=1 device-uri=lpd://10.20.135.153:515/PASSTHRU finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 print-color-mode=color printer-commands=none printer-info=HP-Officejet-Pro-8710 printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='HP Officejet Pro 8710, hpcups 3.21.12' printer-state=3 printer-state-change-time=1706800669 printer-state-reasons=none printer-type=4124 printer-uri-supported=ipp://localhost/printers/HP-Officejet-Pro-8710
root@jammy-vm:~#
root@jammy-vm:~# cat /etc/cups/lpoptions
Default HP-Officejet-Pro-8710
root@jammy-vm:~#
root@jammy-vm:~# cat /root/.cups/lpoptions
cat: /etc/cups/lpoptions: No such file or directory
root@jammy-vm:~#

4) What happened instead:

root@jammy-vm:~# lpstat -p
printer HP-Officejet-Pro-8710 is idle. enabled since Thu 01 Feb 2024 03:17:49 PM UTC
root@jammy-vm:~#
root@jammy-vm:~# lpoptions -d HP-Officejet-Pro-8710
copies=1 device-uri=lpd://10.20.135.153:515/PASSTHRU finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 print-color-mode=color printer-commands=none printer-info=HP-Officejet-Pro-8710 printer-is-accepting-jobs=true printer-is-shared=true printer-is-temporary=false printer-location printer-make-and-model='HP Officejet Pro 8710, hpcups 3.21.12' printer-state=3 printer-state-change-time=1706800669 printer-state-reasons=none printer-type=4124 printer-uri-supported=ipp://localhost/printers/HP-Officejet-Pro-8710
root@jammy-vm:~#
root@jammy-vm:~# cat /etc/cups/lpoptions
cat: /etc/cups/lpoptions: No such file or directory
root@jammy-vm:~#
root@jammy-vm:~# cat /root/.cups/lpoptions
Default HP-Officejet-Pro-8710
root@jammy-vm:~#

Revision history for this message
Rudra Trivedi (rudratrivedi) wrote :
description: updated
Revision history for this message
Rudra Trivedi (rudratrivedi) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, I'm closing for the current serie since it's fixed in Noble but we added it to the team backlog to SRU to Jammy

tags: added: udeng-2281
Changed in cups (Ubuntu):
status: New → Fix Released
importance: Undecided → Low
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Uploaded cups 2.4.1op1-1ubuntu4.8 with the patch from upstream (same as also used in Debian) applied.

Changed in cups (Ubuntu Jammy):
status: New → Fix Committed
importance: Undecided → High
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Rudra, or anyone else affected,

Accepted cups into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cups/2.4.1op1-1ubuntu4.8 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 on 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, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

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

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

tags: added: verification-needed verification-needed-jammy
Revision history for this message
Rudra Trivedi (rudratrivedi) wrote :

I will test this once I'm back from PTO on 1Mar.

Revision history for this message
Rudra Trivedi (rudratrivedi) wrote :

I've successfully tested this package on jammy using -proposed:

ubuntu@jammy-vm:~$ lsb_release -rd
Description: Ubuntu 22.04.3 LTS
Release: 22.04
ubuntu@jammy-vm:~$
ubuntu@jammy-vm:~$ apt-cache policy cups
cups:
  Installed: 2.4.1op1-1ubuntu4.8
  Candidate: 2.4.1op1-1ubuntu4.8
  Version table:
 *** 2.4.1op1-1ubuntu4.8 500
        500 http://archive.ubuntu.com/ubuntu jammy-proposed/main amd64 Packages
...

root@jammy-vm:~# cat /root/.cups/lpoptions
cat: /root/.cups/lpoptions: No such file or directory
root@jammy-vm:~#
root@jammy-vm:~# cat /etc/cups/lpoptions
cat: /etc/cups/lpoptions: No such file or directory
root@jammy-vm:~#
root@jammy-vm:~# lpstat -p
printer HP-Officejet-Pro-8710 is idle. enabled since Thu 01 Feb 2024 03:17:49 PM UTC
root@jammy-vm:~#
root@jammy-vm:~#
root@jammy-vm:~# lpoptions -d HP-Officejet-Pro-8710
copies=1 device-uri=lpd://10.20.135.153:515/PASSTHRU finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 print-color-mode=color
[...]
root@jammy-vm:~#
root@jammy-vm:~# cat /root/.cups/lpoptions
cat: /root/.cups/lpoptions: No such file or directory
root@jammy-vm:~#
root@jammy-vm:~# cat /etc/cups/lpoptions
Default HP-Officejet-Pro-8710

tags: added: verification-done-jammy
removed: verification-needed-jammy
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I noticed this SRU was prepared without the SRU Template[1] filled in. While most of the data we want is in the bug description as is (what's wrong, test plan), it's lacking an analysis of what could go wrong.

That boat has sailed now, and doing an analysis of the patch right now, basically what could go wrong is if someone was relying on the old behavior, of the command only changing the local user's (root in this case) config, instead of system-wide.

The lpoptions[1] manpage doesn't really special case root when the -d option is used:

       -d destination[/instance]
            Sets the user default printer to destination. If instance is supplied then that
            particular instance is used. This option overrides the system default printer for
            the current user.

But later down, in "FILES", we see:

       ~/.cups/lpoptions - user defaults and instances created by non-root users.
       /etc/cups/lpoptions - system-wide defaults and instances created by the root user.

So it does seem the intention of that option when used by the root user was to update the system-wide /etc/cups/lpoptions file instead.

So even if someone was relying on the previous behavior, it was incorrect, and the documentation (which could be clearer, but isn't) seems to agree that the previous behavior was incorrect.

That's the kind of analysis we would like to see in "what could go wrong", and "other info" sections of the SRU template.

1. https://manpages.ubuntu.com/manpages/jammy/en/man1/lpoptions.1.html

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cups - 2.4.1op1-1ubuntu4.8

---------------
cups (2.4.1op1-1ubuntu4.8) jammy; urgency=medium

  * The "lpoptions" utility, when run as root was writing into the file
    /root/.cups/lpoptions instread of /etc/cups/lpoptions. System software
    should never write into /root/ (LP: #2052925).

 -- Till Kamppeter <email address hidden> Wed, 14 Feb 2023 14:10:00 +0100

Changed in cups (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Andreas Hasenack (ahasenack) wrote : Update Released

The verification of the Stable Release Update for cups has completed successfully and the package is now being 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.

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.