- Handle HTTP_FORBIDDEN.
This commit is contained in:
parent
ac60811170
commit
c35b1e7a33
85
system-config-printer-forbidden.patch
Normal file
85
system-config-printer-forbidden.patch
Normal file
@ -0,0 +1,85 @@
|
||||
diff -up system-config-printer-1.0.5/authconn.py.forbidden system-config-printer-1.0.5/authconn.py
|
||||
--- system-config-printer-1.0.5/authconn.py.forbidden 2008-08-11 14:33:09.000000000 +0100
|
||||
+++ system-config-printer-1.0.5/authconn.py 2008-08-13 22:21:03.000000000 +0100
|
||||
@@ -130,7 +130,13 @@ class Connection:
|
||||
|
||||
def _authloop (self, fname, fn, *args, **kwds):
|
||||
self._passes = 0
|
||||
+ c = self._connection
|
||||
while self._perform_authentication () != 0:
|
||||
+ if c != self._connection:
|
||||
+ # We have reconnected.
|
||||
+ fn = getattr (self._connection, fname)
|
||||
+ c = self._connection
|
||||
+
|
||||
try:
|
||||
result = fn.__call__ (*args, **kwds)
|
||||
|
||||
@@ -146,15 +152,17 @@ class Connection:
|
||||
else:
|
||||
raise
|
||||
except cups.HTTPError, (s,):
|
||||
- if not self._cancel and s == cups.HTTP_UNAUTHORIZED:
|
||||
- self._failed ()
|
||||
+ if not self._cancel and (s == cups.HTTP_UNAUTHORIZED or
|
||||
+ s == cups.HTTP_FORBIDDEN):
|
||||
+ self._failed (s == cups.HTTP_FORBIDDEN)
|
||||
else:
|
||||
raise
|
||||
|
||||
return result
|
||||
|
||||
- def _failed (self):
|
||||
+ def _failed (self, forbidden=False):
|
||||
self._has_failed = True
|
||||
+ self._forbidden = forbidden
|
||||
|
||||
def _password_callback (self, prompt):
|
||||
debugprint ("Got password callback")
|
||||
@@ -173,6 +181,7 @@ class Connection:
|
||||
# Haven't yet tried the operation. Set the password
|
||||
# callback and return > 0 so we try it for the first time.
|
||||
self._has_failed = False
|
||||
+ self._forbidden = False
|
||||
self._auth_called = False
|
||||
self._cancel = False
|
||||
cups.setPasswordCB (self._password_callback)
|
||||
@@ -192,16 +201,17 @@ class Connection:
|
||||
# Tried the operation without a password and it failed.
|
||||
if (self._try_as_root and
|
||||
self._user != 'root' and
|
||||
- self._server[0] == '/'):
|
||||
+ (self._server[0] == '/' or self._forbidden)):
|
||||
# This is a UNIX domain socket connection so we should
|
||||
- # not have needed a password, and so the operation must
|
||||
- # not be something that the current user is authorised to
|
||||
- # do. They need to try as root, and supply the password.
|
||||
- # However, to get the right prompt, we need to try as
|
||||
- # root but with no password first.
|
||||
+ # not have needed a password (or it is not a UDS but
|
||||
+ # we got an HTTP_FORBIDDEN response), and so the
|
||||
+ # operation must not be something that the current
|
||||
+ # user is authorised to do. They need to try as root,
|
||||
+ # and supply the password. However, to get the right
|
||||
+ # prompt, we need to try as root but with no password
|
||||
+ # first.
|
||||
debugprint ("Authentication: Try as root")
|
||||
self._use_user = 'root'
|
||||
- cups.setUser (self._use_user)
|
||||
self._auth_called = False
|
||||
self._connect ()
|
||||
return 1
|
||||
diff -U0 system-config-printer-1.0.5/ChangeLog.forbidden system-config-printer-1.0.5/ChangeLog
|
||||
--- system-config-printer-1.0.5/ChangeLog.forbidden 2008-08-11 14:51:07.000000000 +0100
|
||||
+++ system-config-printer-1.0.5/ChangeLog 2008-08-13 22:21:03.000000000 +0100
|
||||
@@ -0,0 +1,10 @@
|
||||
+2008-08-13 Tim Waugh <twaugh@redhat.com>
|
||||
+
|
||||
+ * authconn.py (Connection._authloop): Re-bind to the named method
|
||||
+ on reconnection. Handle HTTP_FORBIDDEN (trac #89).
|
||||
+ (Connection._failed): New optional parameter forbidden. Remember
|
||||
+ whether we saw HTTP_FORBIDDEN.
|
||||
+ (Connection._perform_authentication): Initialise self._forbidden.
|
||||
+ Use it to decide whether to try as root. Don't call setUser()
|
||||
+ here; _connect() will do that.
|
||||
+
|
@ -7,7 +7,7 @@
|
||||
Summary: A printer administration tool
|
||||
Name: system-config-printer
|
||||
Version: 1.0.5
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
License: GPLv2+
|
||||
URL: http://cyberelk.net/tim/software/system-config-printer/
|
||||
Group: System Environment/Base
|
||||
@ -15,6 +15,7 @@ Source0: http://cyberelk.net/tim/data/system-config-printer/1.0.x/system-config-
|
||||
Source1: http://cyberelk.net/tim/data/pycups/pycups-%{pycups_version}.tar.bz2
|
||||
Source2: http://cyberelk.net/tim/data/pysmbc/pysmbc-%{pysmbc_version}.tar.bz2
|
||||
|
||||
Patch0: system-config-printer-forbidden.patch
|
||||
Patch1: pysmbc-debug.patch
|
||||
|
||||
BuildRequires: cups-devel >= 1.2
|
||||
@ -63,6 +64,8 @@ the configuration tool.
|
||||
%prep
|
||||
%setup -q -a 1 -a 2
|
||||
|
||||
%patch0 -p1 -b .forbidden
|
||||
|
||||
pushd pysmbc-%{pysmbc_version}
|
||||
%patch1 -p1 -b .debug
|
||||
popd
|
||||
@ -154,6 +157,9 @@ rm -rf %buildroot
|
||||
exit 0
|
||||
|
||||
%changelog
|
||||
* Wed Aug 13 2008 Tim Waugh <twaugh@redhat.com> 1.0.5-2
|
||||
- Handle HTTP_FORBIDDEN.
|
||||
|
||||
* Mon Aug 11 2008 Tim Waugh <twaugh@redhat.com> 1.0.5-1
|
||||
- 1.0.5.
|
||||
- Updated pycups to 1.9.41.
|
||||
|
Loading…
Reference in New Issue
Block a user