Repository navigation
OpenBSD, web interface: authentication works, but not authorizationΒ #5166
Description
Hi.
I am running CUPS 2.2.6 on OpenBSD/amd64.
As a member or the wheel group (which is included in SystemGroup), I cannot manage printers over the web interface. External clients (like using the GNOME print dialog) works fine.
Here's an hopefully relevant extract from the cups error_log in debug mode.
Authentication works fine but I am puzzled by this entry: cupsdIsAuthorized: username="" which may be the reason for Returning HTTP Unauthorized for CUPS-Get-Devices (no URI) from localhost.
D [08/Nov/2017:18:01:54 +0100] [Client 116] Read: status=200, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 116] Authorized as "ajacoutot" using Basic.
D [08/Nov/2017:18:01:54 +0100] [CGI] argv[0] = "/usr/local/libexec/cups/cgi-bin/admin.cgi"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[0] = "CUPS_CACHEDIR=/var/cache/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[1] = "CUPS_DATADIR=/usr/local/share/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[2] = "CUPS_DOCROOT=/usr/local/share/doc/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[3] = "CUPS_FONTPATH=/usr/local/share/cups/fonts"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[4] = "CUPS_REQUESTROOT=/var/spool/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[5] = "CUPS_SERVERBIN=/usr/local/libexec/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[6] = "CUPS_SERVERROOT=/etc/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[7] = "CUPS_STATEDIR=/var/run/cups"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[8] = "HOME=/var/spool/cups/tmp"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[9] = "PATH=/usr/local/libexec/cups/filter:/usr/local/bin:/usr/local/sbin:/bin:/usr/bin"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[10] = "SERVER_ADMIN=root@peck.home.bsdfrog.org"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[11] = "SOFTWARE=CUPS/2.2.6"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[12] = "TMPDIR=/var/spool/cups/tmp"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[13] = "USER=root"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[14] = "CUPS_MAX_MESSAGE=2047"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[15] = "CUPS_SERVER=/var/run/cups/cups.sock"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[16] = "CUPS_ENCRYPTION=IfRequested"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[17] = "IPP_PORT=631"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[18] = "AUTH_TYPE=Basic"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[19] = "LANG=en_US.UTF8"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[20] = "REDIRECT_STATUS=1"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[21] = "GATEWAY_INTERFACE=CGI/1.1"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[22] = "SERVER_NAME=localhost"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[23] = "SERVER_PORT=631"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[24] = "REMOTE_ADDR=127.0.0.1"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[25] = "REMOTE_HOST=localhost"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[26] = "SCRIPT_NAME=/admin/"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[27] = "SCRIPT_FILENAME=/usr/local/share/doc/cups/admin/"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[28] = "REMOTE_USER=ajacoutot"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[29] = "SERVER_PROTOCOL=HTTP/1.1"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[30] = "HTTP_COOKIE=_ga=GA1.1.129303679.1495441594; org.cups.sid=f5d732a2ec61b2eaed7720c4d12c5b3f; cookieconsent_status=dismiss; _ga=GA1.1.129303679.1495441594"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[31] = "HTTP_USER_AGENT=Mozilla/5.0 (X11; OpenBSD amd64; rv:56.0) Gecko/20100101 Firefox/56.0"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[32] = "HTTP_REFERER=http://localhost:631/admin"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[33] = "REQUEST_METHOD=POST"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[34] = "CONTENT_LENGTH=60"
D [08/Nov/2017:18:01:54 +0100] [CGI] envp[35] = "CONTENT_TYPE=application/x-www-form-urlencoded"
D [08/Nov/2017:18:01:54 +0100] cupsdAddCert: Adding certificate for PID 89333
D [08/Nov/2017:18:01:54 +0100] [CGI] Started /usr/local/libexec/cups/cgi-bin/admin.cgi (PID 89333)
I [08/Nov/2017:18:01:54 +0100] [Client 116] Started "/usr/local/libexec/cups/cgi-bin/admin.cgi" (pid=89333, file=15)
D [08/Nov/2017:18:01:54 +0100] [Client 116] Waiting for CGI data.
D [08/Nov/2017:18:01:54 +0100] [CGI] admin.cgi started...
D [08/Nov/2017:18:01:54 +0100] cupsdSetBusyState: newbusy="Active clients and dirty files", busy="Active clients and dirty files"
D [08/Nov/2017:18:01:54 +0100] [Client 117] Server address is "/var/run/cups/cups.sock".
D [08/Nov/2017:18:01:54 +0100] [Client 117] Accepted from localhost (Domain)
D [08/Nov/2017:18:01:54 +0100] [Client 117] Waiting for request.
D [08/Nov/2017:18:01:54 +0100] [CGI] http=0x146728c9000
D [08/Nov/2017:18:01:54 +0100] [CGI] cgiSetVariable: SECTION="admin"
D [08/Nov/2017:18:01:54 +0100] [CGI] cgiSetVariable: REFRESH_PAGE=""
D [08/Nov/2017:18:01:54 +0100] [CGI] org.cups.sid cookie is "f5d732a2ec61b2eaed7720c4d12c5b3f"
D [08/Nov/2017:18:01:54 +0100] [CGI] cgiSetVariable: org.cups.sid="f5d732a2ec61b2eaed7720c4d12c5b3f"
D [08/Nov/2017:18:01:54 +0100] [CGI] cgiSetVariable: OP="add-printer"
D [08/Nov/2017:18:01:54 +0100] [CGI] op="add-printer"...
D [08/Nov/2017:18:01:54 +0100] [CGI] do_am_printer: DEVICE_URI="(null)"
D [08/Nov/2017:18:01:54 +0100] [CGI] Getting list of devices...
D [08/Nov/2017:18:01:54 +0100] [Client 117] POST / HTTP/1.1
D [08/Nov/2017:18:01:54 +0100] cupsdSetBusyState: newbusy="Active clients and dirty files", busy="Active clients and dirty files"
D [08/Nov/2017:18:01:54 +0100] [Client 117] Read: status=200, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 117] No authentication data provided.
D [08/Nov/2017:18:01:54 +0100] [Client 117] Read: status=100, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 117] Read: status=100, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 117] Read: status=100, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 117] Read: status=100, state=6
D [08/Nov/2017:18:01:54 +0100] [Client 117] 2.0 CUPS-Get-Devices 1
D [08/Nov/2017:18:01:54 +0100] CUPS-Get-Devices
D [08/Nov/2017:18:01:54 +0100] cupsdIsAuthorized: username=""
D [08/Nov/2017:18:01:54 +0100] [Client 117] Returning HTTP Unauthorized for CUPS-Get-Devices (no URI) from localhost
D [08/Nov/2017:18:01:54 +0100] [Client 117] cupsdSendHeader: code=401, type="text/html", auth_type=0
D [08/Nov/2017:18:01:54 +0100] [Client 117] WWW-Authenticate: Basic realm="CUPS", trc="y"
D [08/Nov/2017:18:01:54 +0100] [Client 117] HTTP_STATE_WAITING Closing for error 32 (Broken pipe)
D [08/Nov/2017:18:01:54 +0100] [Client 117] Closing connection.
Activity
ajacoutot commentedon Nov 8, 2017
I forgot to mention that it works fine as the root user.
michaelrsweet commentedon Nov 8, 2017
Hmm, it should be getting the local authentication certificate from the certs directory - can you attach your /etc/cups/cups-files.conf file? I'm wondering if something is messed up with the directory used for passing credentials to the CGI programs?
ajacoutot commentedon Nov 9, 2017
Sure, here you go.
cups-files.conf.txt
michaelrsweet commentedon Nov 9, 2017
OK, that looks pretty standard, so can you send me the output of:
The certs directory is the one the CGI programs will need to be able to access...
ajacoutot commentedon Nov 9, 2017
Here you go:
michaelrsweet commentedon Nov 9, 2017
OK, that should be enough for the CGIs to get the local certs... Alright, try enabling debug2 logging ("cupsctl LogLevel=debug2") and see what is coming from the CGI Get-Devices request...
ajacoutot commentedon Nov 9, 2017
Here's the error log. I really don't understand what is going on :-/ ...
cups-debug2-log.txt
michaelrsweet commentedon Nov 9, 2017
So the new log shows admin.cgi getting run and then the CUPS-Get-Devices operation being done over a domain socket which (correctly) gets the logged-in credentials from the cert cache, but then it thinks that ajacoutot is not a member of group wheel...
Can you verify that your user account is, in fact, listed in /etc/groups for the wheel account?
ajacoutot commentedon Nov 9, 2017
It is :-)
At least I have a better hint of where to look at in the code..
michaelrsweet commentedon Nov 9, 2017
Well, the CUPS group lookup code is not seeing it - are you using LDAP or other network account stuff on this system? Something that might prevent /etc/group from being the first to get looked up?
ajacoutot commentedon Nov 9, 2017
Nope, only using flat files. No external authentication.
I'll start digging in the code in a few...
ajacoutot commentedon Nov 9, 2017
group->gr_gid looks corrupted somehow. If I print "group->gr_gid groups[i]", I have the following in the logs:
ajacoutot commentedon Nov 10, 2017
Ok I found the cullprit. Our getgrouplist(3) implementation has a documented bug:
So the solution would be to either:
I just tested this patch and it works:
I'd rather not open a pull request until you advise me what you prefered solution would be.
Thank you @michaelrsweet
Workaround getgrouplist group data overwrite bug on OpenBSD (Issue #5166
michaelrsweet commentedon Nov 10, 2017
OK, just pushed some changes to auth.c that copy the gr_gid value so that we don't care that the group structure has been overwritten. Try this:
[master 3637469] Workaround getgrouplist group data overwrite bug on OpenBSD (Issue #5166)
ajacoutot commentedon Nov 10, 2017
Works like a charm \o/
Thanks again.
Backport CUPS 2.3.x changes to 2.2.x (Issue #5255)