I'm setting up a python app to monitor a cups server.
I'm using the cups wrapper pycups
. The python application is in the same server as cups.
The calls to create print jobs and get the printers information and job status are working fine but when I try to reject/disable a printer or cancel jobs I'm getting the following eror: cups.IPPError: (4096, 'Unauthorized')
I've tried with multiple configs in the cupsd.conf
file (and restarting the cups service of course), but none seem to be working (even tried deleting all the policies blocks).
Here's my cupsd.conf
(deleted the <Policy authenticated>
block)
LogLevel debug
ErrorPolicy retry-job
PageLogFormat
MaxLogSize 0
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
Browsing On
BrowseLocalProtocols none
DefaultAuthType Basic
WebInterface Yes
DefaultEncryption Never
<Location />
Require user @SYSTEM
Satisfy any
# Allow remote administration...
Order allow,deny
Allow 127.0.0.1
Allow localhost
</Location>
<Location /admin>
AuthType Default
Require user @SYSTEM
# Allow remote administration...
Order allow,deny
Allow all
</Location>
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
# Allow remote access to the configuration files...
Order allow,deny
Allow all
</Location>
<Location /admin/log>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow all
# Allow remote access to the log files...
Order allow,deny
Allow all
</Location>
<Policy default>
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default
<Limit Create-Job Print-Job Print-URI Validate-Job>
AuthType None
Satisfy any
Order allow,deny
Allow 127.0.0.1
</Limit>
<Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
Order allow,deny
Require user @SYSTEM
Satisfy any
AuthType None
Allow localhost
Allow 127.0.0.1
</Limit>
<Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
AuthType None
Order allow,deny
Require user @SYSTEM
Satisfy any
Allow 127.0.0.1
</Limit>
<Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After Cancel-Jobs CUPS-Accept-Jobs CUPS-Reject-Jobs>
Order allow,deny
Satisfy any
Allow 127.0.0.1
Allow localhost
</Limit>
<Limit CUPS-Authenticate-Job>
Require user @OWNER @SYSTEM
Order allow,deny
Satisfy any
AuthType None
Allow 127.0.0.1
</Limit>
<Limit All>
Order allow,deny
</Limit>
</Policy>
The cups error_log shows this every time I try to disable a printer or cancel jobs:
D [29/Oct/2019:18:52:47 +0000] [Client 21] Accepted from localhost:55986 (IPv6)
D [29/Oct/2019:18:52:47 +0000] [Client 21] Waiting for request.
D [29/Oct/2019:18:52:47 +0000] [Client 21] POST /admin/ HTTP/1.1
D [29/Oct/2019:18:52:47 +0000] cupsdSetBusyState: newbusy="Active clients", busy="Not busy"
D [29/Oct/2019:18:52:47 +0000] [Client 21] Read: status=200
D [29/Oct/2019:18:52:47 +0000] [Client 21] No authentication data provided.
D [29/Oct/2019:18:52:47 +0000] cupsdIsAuthorized: username=""
D [29/Oct/2019:18:52:47 +0000] [Client 21] cupsdSendHeader: code=401, type="text/html", auth_type=0
D [29/Oct/2019:18:52:47 +0000] [Client 21] WWW-Authenticate: , trc=\"y\"
D [29/Oct/2019:18:52:47 +0000] [Client 21] Closing connection.
D [29/Oct/2019:18:52:47 +0000] cupsdSetBusyState: newbusy="Not busy", busy="Active clients"
The cups access_log logs this every time I try to disable a printer or cancel jobs: localhost - - [29/Oct/2019:17:15:16 +0000] "POST /admin/ HTTP/1.1" 401 0 - -
Solved it, I had to configure the Location /admin also.
<Location /admin>
AuthType Default
Require user @SYSTEM
Satisfy any
Order allow,deny
Allow localhost
</Location>