How to fix cups.IPPError: (4096, 'Unauthorized') ? Using cups with pycups
How to fix cups.IPPError: (4096, 'Unauthorized') ? Using cups with pycups
我正在设置一个 python 应用程序来监控 cups 服务器。
我正在使用 cups wrapper pycups
。 python 应用程序与 cups 在同一台服务器上。
创建打印作业并获取打印机信息和作业状态的调用工作正常,但是当我尝试 reject/disable 打印机或取消作业时,我收到以下错误:cups.IPPError: (4096, 'Unauthorized')
我已经尝试在 cupsd.conf
文件中使用多个配置(当然还重新启动了 cups 服务),但是 none 似乎可以正常工作(甚至尝试删除所有策略块)。
这是我的 cupsd.conf
(删除了 <Policy authenticated>
块)
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>
每次我尝试禁用打印机或取消作业时,杯子 error_log 都会显示此信息:
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"
每次我尝试禁用打印机或取消作业时,杯子 access_log 都会记录此信息:localhost - - [29/Oct/2019:17:15:16 +0000] "POST /admin/ HTTP/1.1" 401 0 - -
解决了,我还必须配置位置/admin。
<Location /admin>
AuthType Default
Require user @SYSTEM
Satisfy any
Order allow,deny
Allow localhost
</Location>
我正在设置一个 python 应用程序来监控 cups 服务器。
我正在使用 cups wrapper pycups
。 python 应用程序与 cups 在同一台服务器上。
创建打印作业并获取打印机信息和作业状态的调用工作正常,但是当我尝试 reject/disable 打印机或取消作业时,我收到以下错误:cups.IPPError: (4096, 'Unauthorized')
我已经尝试在 cupsd.conf
文件中使用多个配置(当然还重新启动了 cups 服务),但是 none 似乎可以正常工作(甚至尝试删除所有策略块)。
这是我的 cupsd.conf
(删除了 <Policy authenticated>
块)
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>
每次我尝试禁用打印机或取消作业时,杯子 error_log 都会显示此信息:
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"
每次我尝试禁用打印机或取消作业时,杯子 access_log 都会记录此信息:localhost - - [29/Oct/2019:17:15:16 +0000] "POST /admin/ HTTP/1.1" 401 0 - -
解决了,我还必须配置位置/admin。
<Location /admin>
AuthType Default
Require user @SYSTEM
Satisfy any
Order allow,deny
Allow localhost
</Location>