150 lines
6.4 KiB
Diff
150 lines
6.4 KiB
Diff
diff -up system-config-printer-1.1.12/authconn.py.polkit-1 system-config-printer-1.1.12/authconn.py
|
|
--- system-config-printer-1.1.12/authconn.py.polkit-1 2009-08-25 15:01:40.000000000 +0100
|
|
+++ system-config-printer-1.1.12/authconn.py 2009-08-27 14:01:24.553275754 +0100
|
|
@@ -24,6 +24,7 @@ import gobject
|
|
import gtk
|
|
import os
|
|
from errordialogs import *
|
|
+import config
|
|
from debug import *
|
|
|
|
_ = lambda x: x
|
|
@@ -156,8 +157,11 @@ class Connection:
|
|
cups.setUser (self._use_user)
|
|
|
|
self._use_pk = ((self._server[0] == '/' or self._server == 'localhost')
|
|
- and not self._lock
|
|
and os.getuid () != 0)
|
|
+
|
|
+ if not config.WITH_POLKIT_1 and self._lock:
|
|
+ self._use_pk = False
|
|
+
|
|
if self._use_pk:
|
|
create_object = cupspk.Connection
|
|
else:
|
|
@@ -208,10 +212,6 @@ class Connection:
|
|
break
|
|
except cups.IPPError, (e, m):
|
|
if self._use_pk and m == 'pkcancel':
|
|
- title = _('Unauthorized request (%s)') % fname
|
|
- text = _("You are not authorized to carry out the "
|
|
- "requested action.")
|
|
- show_error_dialog (title, text, None)
|
|
raise cups.IPPError (0, _("Operation canceled"))
|
|
if not self._cancel and (e == cups.IPP_NOT_AUTHORIZED or
|
|
e == cups.IPP_FORBIDDEN):
|
|
diff -up system-config-printer-1.1.12/config.py.in.polkit-1 system-config-printer-1.1.12/config.py.in
|
|
--- system-config-printer-1.1.12/config.py.in.polkit-1 2009-08-25 15:01:40.000000000 +0100
|
|
+++ system-config-printer-1.1.12/config.py.in 2009-08-27 14:01:24.555275419 +0100
|
|
@@ -24,3 +24,4 @@ localedir="@localedir@"
|
|
pkgdatadir="@datadir@/@PACKAGE@"
|
|
VERSION="@VERSION@"
|
|
PACKAGE="@PACKAGE@"
|
|
+WITH_POLKIT_1=@WITH_POLKIT_1@
|
|
diff -up system-config-printer-1.1.12/configure.in.polkit-1 system-config-printer-1.1.12/configure.in
|
|
--- system-config-printer-1.1.12/configure.in.polkit-1 2009-08-25 17:01:27.000000000 +0100
|
|
+++ system-config-printer-1.1.12/configure.in 2009-08-27 14:01:24.556275177 +0100
|
|
@@ -43,6 +43,17 @@ if test x$with_udev_rules != xno; then
|
|
AM_PROG_CC_C_O
|
|
fi
|
|
|
|
+AC_ARG_WITH(polkit-1,
|
|
+ [AC_HELP_STRING([--with-polkit-1],
|
|
+ [Enable support for polkit-1 @<:@default=no@:>@])],
|
|
+ [],
|
|
+ [with_polkit_1=no])
|
|
+WITH_POLKIT_1=False
|
|
+if test x$with_polkit_1 != xno; then
|
|
+ WITH_POLKIT_1=True
|
|
+fi
|
|
+AC_SUBST(WITH_POLKIT_1)
|
|
+
|
|
ALL_LINGUAS="ar as bg bn_IN bn bs ca cs cy da de el en_GB es et fa fi fr gu he hi hr hu hy id is it ja ka kn ko lo lv mai mk ml mr ms my nb nl nn or pa pl pt_BR pt ro ru si sk sl sr@latin sr sv ta te th tr uk vi zh_CN zh_TW"
|
|
AC_CONFIG_FILES([
|
|
Makefile
|
|
diff -up system-config-printer-1.1.12/cupspk.py.polkit-1 system-config-printer-1.1.12/cupspk.py
|
|
--- system-config-printer-1.1.12/cupspk.py.polkit-1 2009-08-25 15:01:40.000000000 +0100
|
|
+++ system-config-printer-1.1.12/cupspk.py 2009-08-27 14:01:24.558275639 +0100
|
|
@@ -34,6 +34,7 @@ import tempfile
|
|
import cups
|
|
import dbus
|
|
import gtk
|
|
+import config
|
|
from debug import debugprint
|
|
|
|
from dbus.mainloop.glib import DBusGMainLoop
|
|
@@ -221,8 +222,14 @@ class Connection:
|
|
return retval
|
|
break
|
|
except dbus.exceptions.DBusException, e:
|
|
- if not self._handle_exception_with_auth(e):
|
|
+ if config.WITH_POLKIT_1:
|
|
+ if e.get_dbus_name() == CUPS_PK_NEED_AUTH:
|
|
+ raise cups.IPPError(cups.IPP_NOT_AUTHORIZED, 'pkcancel')
|
|
+
|
|
break
|
|
+ else:
|
|
+ if not self._handle_exception_with_auth(e):
|
|
+ break
|
|
|
|
# The PolicyKit call did not work (either a PK-error and we got a dbus
|
|
# exception that wasn't handled, or an error in the mechanism itself)
|
|
diff -up system-config-printer-1.1.12/Makefile.am.polkit-1 system-config-printer-1.1.12/Makefile.am
|
|
--- system-config-printer-1.1.12/Makefile.am.polkit-1 2009-08-25 17:01:27.000000000 +0100
|
|
+++ system-config-printer-1.1.12/Makefile.am 2009-08-27 14:01:24.551276420 +0100
|
|
@@ -39,6 +39,7 @@ config.py: config.py.in Makefile
|
|
-e "s|\@localedir\@|$(localedir)|" \
|
|
-e "s|\@VERSION\@|$(VERSION)|" \
|
|
-e "s|\@PACKAGE\@|$(PACKAGE)|" \
|
|
+ -e "s|\@WITH_POLKIT_1\@|$(WITH_POLKIT_1)|" \
|
|
$< > $@
|
|
|
|
# Use distutils to build the module.
|
|
diff -up system-config-printer-1.1.12/system-config-printer.py.polkit-1 system-config-printer-1.1.12/system-config-printer.py
|
|
--- system-config-printer-1.1.12/system-config-printer.py.polkit-1 2009-08-27 14:01:17.554275306 +0100
|
|
+++ system-config-printer-1.1.12/system-config-printer.py 2009-08-27 14:01:24.564275576 +0100
|
|
@@ -4620,19 +4620,32 @@ class NewPrinterGUI(GtkGUI):
|
|
self.WaitWindow.set_transient_for (parent)
|
|
self.WaitWindow.show_now ()
|
|
self.busy (self.WaitWindow)
|
|
- while gtk.events_pending ():
|
|
- gtk.main_iteration ()
|
|
|
|
- debugprint ("Fetching devices")
|
|
- self.mainapp.cups._begin_operation (_("fetching device list"))
|
|
- try:
|
|
- devices = cupshelpers.getDevices(self.mainapp.cups)
|
|
- except:
|
|
- self.mainapp.cups._end_operation ()
|
|
- self.WaitWindow.hide ()
|
|
- raise
|
|
+ if self.mainapp.cups._use_pk and config.WITH_POLKIT_1:
|
|
+ def get_devices():
|
|
+ c = authconn.Connection (host=self.mainapp.connect_server,
|
|
+ parent=parent, lock=True)
|
|
+ c._begin_operation (_("fetching device list"))
|
|
+ ret = cupshelpers.getDevices (c)
|
|
+ c._end_operation ()
|
|
+ return ret
|
|
+
|
|
+ op = TimedOperation (get_devices)
|
|
+ try:
|
|
+ devices = op.run ()
|
|
+ except (OperationCanceled, RuntimeError, cups.IPPError):
|
|
+ self.WaitWindow.hide ()
|
|
+ raise
|
|
+ else:
|
|
+ self.mainapp.cups._begin_operation (_("fetching device list"))
|
|
+ try:
|
|
+ devices = cupshelpers.getDevices (self.mainapp.cups)
|
|
+ self.mainapp.cups._end_operation ()
|
|
+ except cups.IPPError:
|
|
+ self.mainapp.cups._end_operation ()
|
|
+ self.WaitWindow.hide ()
|
|
+ raise
|
|
|
|
- self.mainapp.cups._end_operation ()
|
|
self.WaitWindow.hide ()
|
|
debugprint ("Got devices")
|
|
return devices
|