Bug 2247186 - CUPS Web UI fails to update the default printer in /etc/cups/lpoptions
Summary: CUPS Web UI fails to update the default printer in /etc/cups/lpoptions
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: cups
Version: 38
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Zdenek Dohnal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-10-31 07:21 UTC by Todd
Modified: 2023-11-06 08:54 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-02 11:49:20 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Todd 2023-10-31 07:21:49 UTC
Fedora 38
cups-2.4.7-1.fc38.x86_64

/etc/cups/lpoptions

After my Oki B4350 died, I replaced it with a Brother HL-L2300D.  I remove the old printer and install the new printer in http://127.0.0.1:631 (CUPS).  Everything went well, except my default print kept coming up as Cups-PDF in all my programs.  

Troubleshooting it, I found that CUPS had failed to upgrade to the new default printer in /etc/cups/lpoptions.  (My system has been through several reboots.)

vi /etc/cups/lpoptions
Default HLL2300D

changed from Default B4350

All is well now.


And now if you look at my /etc/cups/printers.conf, you will see that the default is set correctly there.  It also show the HLL2300D as teh default in 631.

<Printer Cups-PDF>
PrinterId 4
UUID urn:uuid:8d86be01-61b0-3452-6e91-ee3dcc9adb2b
Info Cups-PDF
Location Office
MakeModel Generic CUPS-PDF Printer (no options)
DeviceURI cups-pdf:/
State Idle
StateTime 1698651517
ConfigTime 1698531817
Type 8450124
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

<DefaultPrinter HLL2300D>
PrinterId 15
UUID urn:uuid:19a617e6-961d-36e7-6618-e6d37a74bd43
Info HLL2300D
Location Office
MakeModel Brother HL-L2300D for CUPS
DeviceURI usb://Brother/HL-L2300D%20series?serial=U63878H3N412319
State Idle
StateTime 1698652889
ConfigTime 1698485181
Type 8425492
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</DefaultPrinter> 


Reproducible: Always

Comment 1 Zdenek Dohnal 2023-11-01 09:52:57 UTC
Hi,

thank you for reporting the issue!

I suppose you used the option 'Set as Server Default' under the menu 'Administration' on the specific printer's page in CUPS Web UI, right? There is a note when you click on it:

"Note: Any user default that has been set via the "lpoptions" command will override this default setting."

CUPS CGI script sends request directly to cupsd where it changes its internal global variable, however lpoptions changes contents of lpoptions file (which one depends on user who calls the command - /etc/cups/lpoptions for root, ~/.cups/lpoptions for other users) - it behaves like this because Web UI is for daemon configuration (cupsd), and lpoptions files are for user configurations.

You could say we can assume that root user configuration can be the same as for the daemon, but I guess there can be situations where admin would want to have it different, so it makes sense to keep their configurations separate.

Or did you only remove the old print queue, didn't set a new default printer and expected lpoptions files will be updated automatically? Unfortunately it does not this way, because lpoptions files are user configuration and you only installed a new print queue, which changes daemon configuration.

If neither of those scenarios happened, it would be great if you described step by step how you set the new default printer and which application showed you a different default printer.

Either way I recommend to don't mix up tools for user and daemon settings.

Comment 2 Todd 2023-11-01 09:58:11 UTC
In 631 I remove the old printer.  Then I set up the new printer and set it to the default.  631 updated /etc/cups/printers.conf and properly set the default.   631 left the old printer as the default in /etc/cups/lpoptions.

Comment 3 Zdenek Dohnal 2023-11-02 06:10:44 UTC
IIUC you added the new printer and made it default via web UI, so you set up the server settings - it does not influence user settings in lpoptions and user settings have priority over server settings in applications, as it is mentioned in the note when you set the printer default.

Closing as NOTABUG - the recommendation is to use CUPS web UI/lpadmin for daemon settings or lpoptions for user settings, but don't mix those two ways (unless you know user settings have priority). In case you will stay up with daemon settings, you can remove the default printer entry from /etc/cups/lpoptions and the default printer will get properly updated if you set it via CUPS Web UI or by lpadmin.

Comment 4 Todd 2023-11-02 09:35:27 UTC
So what you are basically saying is buyer beware.  You figure out why things won't work right on your own.

Since the UI/lpadmin and lpoptions are ALL part of the CUPS project, that they should interact properly with each other and not leave the uses pulling their hair out trying to figure out why the default printer in not working.  It personally took me two years to figure this problem out (my hair eventually grew back).  It was not until the new printer was installed that "lpr" was not my default printer.  This is dirty pool on CUPS' part.

Guys, this is indeed a bug.  All parts of CUPS need to be aware of each other and interact properly.  Please fix it.

Comment 5 Zdenek Dohnal 2023-11-02 11:49:20 UTC
They are part of the project, but their hierarchy is different, so change in underlying part can be overridden by settings in more important part. Synchronizing the settings and ignore overrides would cause behavior regressions for users.

Feel free to report this upstream at OpenPrinting CUPS ( https://github.com/OpenPrinting/cups ) to get more OpenPrinting members than myself to answer, but it is not a bug at the moment from my POV, so I'll close the issue for now - I can add some more explanations into man pages or mention checking /etc/cups/lpoptions and ~/.cups/lpoptions when you set default printer via web UI, but IMO changing behavior to synchronize daemon and user settings and ignoring overrides in user configuration is not desired.

I'll reopen the ticket if upstream acknowledges this as a bug.

Comment 6 Todd 2023-11-05 01:27:43 UTC
Will do.

Companion bug on upstream:

CUPS UI (631) fails to update the default printer in /etc/cups/lpoptions
https://github.com/OpenPrinting/cups/issues/818

Comment 7 Todd 2023-11-06 08:54:12 UTC
The results back from 818 is that the WebUI's default is the "server default", not the client (local) default.

A great article on all this is:  
https://en.opensuse.org/SDB:Print_Settings_with_CUPS

The local computer's defaults are found in:
   user:  
       ~/.cups/lpoptions

   global (if not user default):
       /etc/cups/lpoptions

I have no idea what the "server default's" purpose is.  But anyway.  Even lpr will fill in the printer's name from the default for you if you do not list one in the command.  

Over on 818, I asked if they would update the wording on the default so it is obvious to a non developer.

Thank you for your patience with this matter,

-T


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