Bug 324700

Summary: print-manager is too greedy for permissions, unusable for non cups admin
Product: [Frameworks and Libraries] print-manager Reporter: Pierre <pierre.sauter>
Component: generalAssignee: Daniel Nicoletti <dantti12>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 4.11.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Patch to get a sane behaviour for my setup.
How about that?
Sorry, should be std::string(cupsServer()) == "localhost"

Description Pierre 2013-09-09 14:25:56 UTC
Our setup: > 200 clients, > 100 printers, 1 cups server.
The cupsd.conf on the server is restrictive, and normal users do not have admin rights, as it should be.
With print-manager it is not possible to get the printer list without the annoying dialog, look at a printer queue and cancel your own jobs. Instead everytime there is a root password dialog popping up. If you click on cancel in the password dialog the print-queue is greyed out.
system-config-printer-gnome and system-config-printer-kde work as expected.

Reproducible: Always

Steps to Reproduce:
1. Open print queue of a printer
2. Click cancel in password dialog
Actual Results:  
Queue is greyed out, no print jobs shown.

Expected Results:  
Show printer queue.
Comment 1 Pierre 2013-09-09 14:46:12 UTC
Created attachment 82239 [details]
Patch to get a sane behaviour for my setup.

Works for me, however I doubt it will work for other use cases.
Comment 2 Daniel Nicoletti 2013-09-09 16:29:01 UTC
hmm most of the patch should be fine, only the last part that can't be simply commented.
I was to investigate why some s-c-p requests didn't need root password, but it seems you find out, thanks. Still the last line works on s-c-p and I even looked at it's sources and don't know why...
I'll test and probably apply most of it, if you can bitsec the last line that would be great.
Comment 3 Pierre 2013-09-09 17:27:33 UTC
Thanks for looking at my proposal. Let me explain the last change:
In PrintKCM::getServerSettings you call cupsAdminGetServerSettings from cups/adminutil. This requires admin privileges on the cups server. Right now it is called already in the constructor,
which causes the root password dialog to popup as soon as I enter the printer panel in systemsettings. When its commented out in the constructor, the dialog only appears when I click
on the settings button in the printer panel, which is more acceptable in my opinion.

I am not sure if the first change is good for everyone. Our cups server (1.4.4) just does not return
'printer-name' in the job attributes, which causes print-manager to always have an empty job list.
Comment 4 Daniel Nicoletti 2013-09-09 17:38:32 UTC
Right, but understand that the settings page needs to know if the Server is allowing printers to be shared to enable the Share button, and that can only happens if I call cupsAdminGetServerSettings.

Ah yes, the first one was recently removed since I increased the CUPS requirement as we needed a feature present only in CUPS 1.5, can't you upgrade?
Comment 5 Pierre 2013-09-10 12:39:22 UTC
Created attachment 82254 [details]
How about that?

If the cups Server is not localhost, you can not assume to get cups admin privileges.
Comment 6 Daniel Nicoletti 2013-09-10 14:17:00 UTC
Comment on attachment 82254 [details]
How about that?

hmm that needs testing (I believe that doesn't tell you it is localhost), also you can't compare char * strings like that.
Comment 7 Pierre 2013-09-10 16:04:16 UTC
Created attachment 82255 [details]
Sorry, should be std::string(cupsServer()) == "localhost"

Tested on my system.
If I move away the /etc/cups/client.conf with the line "ServerName XXX" in it then I get either "localhost" or "/var/run/cups/cups.sock". However this is not generic as the cups admin can configure it arbitrarily in /etc/cups/cupsd.conf. I wonder if there is a method in the cups api to get what I want.
Comment 8 Daniel Nicoletti 2013-10-22 18:47:19 UTC
Git commit 013721bbc64433921c77b6f650f706e86bf22ccd by Daniel Nicoletti.
Committed on 22/10/2013 at 18:46.
Pushed by dantti into branch 'KDE/4.11'.

Avoid talking to /admin with CUPS server to avoid unneded password dialogs

M  +2    -2    libkcups/KCupsRequest.cpp

http://commits.kde.org/print-manager/013721bbc64433921c77b6f650f706e86bf22ccd