rpms/system-config-printer/F-9 system-config-printer-authconn.patch, NONE, 1.1 system-config-printer.spec, 1.178, 1.179 system-config-printer.console, 1.2, NONE system-config-printer.pam, 1.1, NONE

Tim Waugh (twaugh) fedora-extras-commits at redhat.com
Fri May 2 16:06:56 UTC 2008


Author: twaugh

Update of /cvs/pkgs/rpms/system-config-printer/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26992

Modified Files:
	system-config-printer.spec 
Added Files:
	system-config-printer-authconn.patch 
Removed Files:
	system-config-printer.console system-config-printer.pam 
Log Message:
* Fri May  2 2008 Tim Waugh <twaugh at redhat.com> 0.7.82.2-3
- Back-ported authconn dialog for better authentication when running as
  a non-root user (bug #444306).
- Don't install consolehelper bits any more as they are no longer needed.


system-config-printer-authconn.patch:

--- NEW FILE system-config-printer-authconn.patch ---
diff -up system-config-printer-0.7.82.2/po/POTFILES.in.authconn system-config-printer-0.7.82.2/po/POTFILES.in
--- system-config-printer-0.7.82.2/po/POTFILES.in.authconn	2008-04-03 13:22:02.000000000 +0100
+++ system-config-printer-0.7.82.2/po/POTFILES.in	2008-05-02 17:02:15.000000000 +0100
@@ -1,6 +1,7 @@
 # List of source files which contain translatable strings.
 [encoding: UTF-8]
 
+authconn.py
 cupshelpers.py
 gtk_label_autowrap.py
 my-default-printer.py
diff -up system-config-printer-0.7.82.2/Makefile.am.authconn system-config-printer-0.7.82.2/Makefile.am
--- system-config-printer-0.7.82.2/Makefile.am.authconn	2008-04-03 13:22:04.000000000 +0100
+++ system-config-printer-0.7.82.2/Makefile.am	2008-05-02 17:02:15.000000000 +0100
@@ -8,8 +8,10 @@ nobase_pkgdata_SCRIPTS=				\
 	applet.py
 
 nobase_pkgdata_DATA=					\
+	authconn.py					\
 	config.py					\
 	cupshelpers.py					\
+	debug.py					\
 	openprinting.py					\
 	options.py					\
 	optionwidgets.py				\
@@ -42,10 +44,8 @@ nobase_pkgdata_DATA=					\
 	troubleshoot/Welcome.py				\
 	applet.glade
 
-nobase_sbin_SCRIPTS=\
-	system-config-printer
-
 bin_SCRIPTS=\
+	system-config-printer			\
 	system-config-printer-applet		\
 	my-default-printer
 
diff -up /dev/null system-config-printer-0.7.82.2/debug.py
--- /dev/null	2008-05-02 07:47:34.688000841 +0100
+++ system-config-printer-0.7.82.2/debug.py	2008-05-02 17:02:15.000000000 +0100
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2008 Red Hat, Inc.
+## Copyright (C) 2008 Tim Waugh <twaugh at redhat.com>
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import sys
+import traceback
+
+_debug=False
+def debugprint (x):
+    if _debug:
+        try:
+            print x
+        except:
+            pass
+
+def get_debugging ():
+    return _debug
+
+def set_debugging (d):
+    global _debug
+    _debug = d
+
+def fatalException (exitcode=1):
+    nonfatalException (type="fatal", end="Exiting")
+    sys.exit (exitcode)
+
+def nonfatalException (type="non-fatal", end="Continuing anyway.."):
+    d = get_debugging ()
+    set_debugging (True)
+    debugprint ("Caught %s exception.  Traceback:" % type)
+    (type, value, tb) = sys.exc_info ()
+    tblast = traceback.extract_tb (tb, limit=None)
+    if len (tblast):
+        tblast = tblast[:len (tblast) - 1]
+    extxt = traceback.format_exception_only (type, value)
+    for line in traceback.format_tb(tb):
+        debugprint (line.strip ())
+    debugprint (extxt[0].strip ())
+    debugprint (end)
+    set_debugging (d)
diff -up system-config-printer-0.7.82.2/Makefile.in.authconn system-config-printer-0.7.82.2/Makefile.in
--- system-config-printer-0.7.82.2/Makefile.in.authconn	2008-04-03 13:22:18.000000000 +0100
+++ system-config-printer-0.7.82.2/Makefile.in	2008-05-02 17:02:15.000000000 +0100
@@ -48,9 +48,8 @@ am__CONFIG_DISTCLEAN_FILES = config.stat
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_CLEAN_FILES = config.py
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)" \
-	"$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" \
-	"$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(desktopdir)" \
-	"$(DESTDIR)$(pkgdatadir)"
+	"$(DESTDIR)$(man1dir)" "$(DESTDIR)$(dbusdir)" \
+	"$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(pkgdatadir)"
 binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
@@ -59,9 +58,7 @@ am__vpath_adj = case $$p in \
   esac;
 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 nobase_pkgdataSCRIPT_INSTALL = $(install_sh_SCRIPT)
-nobase_sbinSCRIPT_INSTALL = $(install_sh_SCRIPT)
-SCRIPTS = $(bin_SCRIPTS) $(nobase_pkgdata_SCRIPTS) \
-	$(nobase_sbin_SCRIPTS)
+SCRIPTS = $(bin_SCRIPTS) $(nobase_pkgdata_SCRIPTS)
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -235,8 +232,10 @@ nobase_pkgdata_SCRIPTS = \
 	applet.py
 
 nobase_pkgdata_DATA = \
+	authconn.py					\
 	config.py					\
 	cupshelpers.py					\
+	debug.py					\
 	openprinting.py					\
 	options.py					\
 	optionwidgets.py				\
@@ -269,10 +268,8 @@ nobase_pkgdata_DATA = \
 	troubleshoot/Welcome.py				\
 	applet.glade
 
-nobase_sbin_SCRIPTS = \
-	system-config-printer
-
 bin_SCRIPTS = \
+	system-config-printer			\
 	system-config-printer-applet		\
 	my-default-printer
 
@@ -398,31 +395,6 @@ uninstall-nobase_pkgdataSCRIPTS:
 	  echo " rm -f '$(DESTDIR)$(pkgdatadir)/$$f'"; \
 	  rm -f "$(DESTDIR)$(pkgdatadir)/$$f"; \
 	done
-install-nobase_sbinSCRIPTS: $(nobase_sbin_SCRIPTS)
-	@$(NORMAL_INSTALL)
-	test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
-	@$(am__vpath_adj_setup) \
-	list='$(nobase_sbin_SCRIPTS)'; for p in $$list; do \
-	  $(am__vpath_adj) p=$$f; \
-	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  if test -f $$d$$p; then \
-	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
-	    f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
-	    echo " $(nobase_sbinSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(sbindir)/$$f'"; \
-	    $(nobase_sbinSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(sbindir)/$$f"; \
-	  else :; fi; \
-	done
-
-uninstall-nobase_sbinSCRIPTS:
-	@$(NORMAL_UNINSTALL)
-	@$(am__vpath_adj_setup) \
-	list='$(nobase_sbin_SCRIPTS)'; for p in $$list; do \
-	  $(am__vpath_adj) p=$$f; \
-	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
-	  f=`echo "$$p" | sed 's|[^/]*$$||'`"$$f"; \
-	  echo " rm -f '$(DESTDIR)$(sbindir)/$$f'"; \
-	  rm -f "$(DESTDIR)$(sbindir)/$$f"; \
-	done
 install-man1: $(man1_MANS) $(man_MANS)
 	@$(NORMAL_INSTALL)
 	test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
@@ -784,7 +756,7 @@ check: check-recursive
 all-am: Makefile $(SCRIPTS) $(MANS) $(DATA)
 installdirs: installdirs-recursive
 installdirs-am:
-	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(pkgdatadir)"; do \
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(dbusdir)" "$(DESTDIR)$(desktopdir)" "$(DESTDIR)$(pkgdatadir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: install-recursive
@@ -836,7 +808,7 @@ install-data-am: install-dbusDATA instal
 
 install-dvi: install-dvi-recursive
 
-install-exec-am: install-binSCRIPTS install-nobase_sbinSCRIPTS
+install-exec-am: install-binSCRIPTS
 
 install-html: install-html-recursive
 
@@ -870,8 +842,7 @@ ps-am:
 
 uninstall-am: uninstall-binSCRIPTS uninstall-dbusDATA \
 	uninstall-desktopDATA uninstall-man \
-	uninstall-nobase_pkgdataDATA uninstall-nobase_pkgdataSCRIPTS \
-	uninstall-nobase_sbinSCRIPTS
+	uninstall-nobase_pkgdataDATA uninstall-nobase_pkgdataSCRIPTS
 
 uninstall-man: uninstall-man1
 
@@ -889,15 +860,14 @@ uninstall-man: uninstall-man1
 	install-dvi install-dvi-am install-exec install-exec-am \
 	install-html install-html-am install-info install-info-am \
 	install-man install-man1 install-nobase_pkgdataDATA \
-	install-nobase_pkgdataSCRIPTS install-nobase_sbinSCRIPTS \
-	install-pdf install-pdf-am install-ps install-ps-am \
-	install-strip installcheck installcheck-am installdirs \
-	installdirs-am maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
-	tags-recursive uninstall uninstall-am uninstall-binSCRIPTS \
-	uninstall-dbusDATA uninstall-desktopDATA uninstall-man \
-	uninstall-man1 uninstall-nobase_pkgdataDATA \
-	uninstall-nobase_pkgdataSCRIPTS uninstall-nobase_sbinSCRIPTS
+	install-nobase_pkgdataSCRIPTS install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
+	pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+	uninstall-binSCRIPTS uninstall-dbusDATA uninstall-desktopDATA \
+	uninstall-man uninstall-man1 uninstall-nobase_pkgdataDATA \
+	uninstall-nobase_pkgdataSCRIPTS
 
 
 install-desktopDATA: $(desktop_DATA)
diff -U0 system-config-printer-0.7.82.2/ChangeLog.authconn system-config-printer-0.7.82.2/ChangeLog
--- system-config-printer-0.7.82.2/ChangeLog.authconn	2008-05-02 17:02:15.000000000 +0100
+++ system-config-printer-0.7.82.2/ChangeLog	2008-05-02 17:03:58.000000000 +0100
@@ -0,0 +1,19 @@
+2008-05-02  Tim Waugh  <twaugh at redhat.com>
+
+	* system-config-printer.py (GUI.on_btnPrintTestPage_clicked):
+	Connect as the current user to print the test page (bug #444306).
+
+	* Makefile.am: Install main script in bindir, not sbindir.
+
+	* debug.py: New file.
+	* Makefile.am (nobase_pkgdata_DATA): Ship it and install it.
+
+	* authconn.py: New file.
+	* Makefile.am (nobase_pkgdata_DATA): Ship it and install it.
+	* po/POTFILES.in: Translate it.
+	* system-config-printer.py (GUI.__init__): Use
+	authconn.Connection (bug #444306).
+	(GUI.connect): Likewise.
+	(GUI.on_btnRefresh_clicked): Likewise.
+	(GUI.reconnect): Use _connect to reconnect.
+
diff -up /dev/null system-config-printer-0.7.82.2/authconn.py
--- /dev/null	2008-05-02 07:47:34.688000841 +0100
+++ system-config-printer-0.7.82.2/authconn.py	2008-05-02 17:02:15.000000000 +0100
@@ -0,0 +1,228 @@
+#!/usr/bin/env python
+
+## Copyright (C) 2007, 2008 Tim Waugh <twaugh at redhat.com>
+## Copyright (C) 2007, 2008 Red Hat, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import cups
+import gtk
+from debug import *
+
+_ = lambda x: x
+def set_gettext_function (fn):
+    global _
+    _ = fn
+
+class AuthDialog(gtk.Dialog):
+    AUTH_FIELD={'username': _("Username:"),
+                'password': _("Password:"),
+                'domain': _("Domain:")}
+
+    def __init__ (self, title=_("Authentication"), parent=None,
+                  flags=gtk.DIALOG_MODAL | gtk.DIALOG_NO_SEPARATOR,
+                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                           gtk.STOCK_OK, gtk.RESPONSE_OK),
+                  auth_info_required=['username', 'password']):
+        gtk.Dialog.__init__ (self, title, parent, flags, buttons)
+        self.auth_info_required = auth_info_required
+        self.set_default_response (gtk.RESPONSE_OK)
+        self.set_border_width (6)
+        self.set_resizable (False)
+        hbox = gtk.HBox (False, 12)
+        hbox.set_border_width (6)
+        image = gtk.Image ()
+        image.set_from_stock ('gtk-dialog-authentication',
+                              gtk.ICON_SIZE_DIALOG)
+        hbox.pack_start (image, False, False, 0)
+        vbox = gtk.VBox (False, 12)
+        self.prompt_label = gtk.Label ()
+        vbox.pack_start (self.prompt_label, False, False, 0)
+
+        num_fields = len (auth_info_required)
+        table = gtk.Table (num_fields, 2)
+        table.set_row_spacings (6)
+        table.set_col_spacings (6)
+
+        self.field_entry = []
+        for i in range (num_fields):
+            field = auth_info_required[i]
+            label = gtk.Label (self.AUTH_FIELD.get (field, field))
+            label.set_alignment (0, 0.5)
+            table.attach (label, 0, 1, i, i + 1)
+            entry = gtk.Entry ()
+            entry.set_visibility (field != 'password')
+            table.attach (entry, 1, 2, i, i + 1, 0, 0)
+            self.field_entry.append (entry)
+
+        self.field_entry[num_fields - 1].set_activates_default (True)
+        vbox.pack_start (table, False, False, 0)
+        hbox.pack_start (vbox, False, False, 0)
+        self.vbox.pack_start (hbox)
+        self.vbox.show_all ()
+
+    def set_prompt (self, prompt):
+        self.prompt_label.set_markup ('<span weight="bold" size="larger">' +
+                                      prompt + '</span>')
+        self.prompt_label.set_use_markup (True)
+        self.prompt_label.set_alignment (0, 0)
+        self.prompt_label.set_line_wrap (True)
+
+    def set_auth_info (self, auth_info):
+        for i in range (len (self.field_entry)):
+            self.field_entry[i].set_text (auth_info[i])
+
+    def get_auth_info (self):
+        return map (lambda x: x.get_text (), self.field_entry)
+
+    def field_grab_focus (self, field):
+        i = self.auth_info_required.index (field)
+        self.field_entry[i].grab_focus ()
+
+class Connection:
+    def __init__ (self, parent=None):
+        self._use_password = ''
+        self._parent = parent
+        self._connect ()
+        self._prompt_allowed = True
+
+    def _get_prompt_allowed (self, ):
+        return self._prompt_allowed
+
+    def _set_prompt_allowed (self, allowed):
+        self._prompt_allowed = allowed
+
+    def _connect (self):
+        self._connection = cups.Connection ()
+        self._use_user = cups.getUser ()
+        self._server = cups.getServer ()
+        self._user = self._use_user
+        debugprint ("Connected as user %s" % self._user)
+        methodtype = type (self._connection.getPrinters)
+        for fname in dir (self._connection):
+            if fname[0] == '_':
+                continue
+            fn = getattr (self._connection, fname)
+            if type (fn) != methodtype:
+                continue
+            setattr (self, fname, self._make_binding (fname, fn))
+
+    def _make_binding (self, fname, fn):
+        return lambda *args, **kwds: self._authloop (fname, fn, *args, **kwds)
+
+    def _authloop (self, fname, fn, *args, **kwds):
+        self._has_failed = False
+        self._auth_called = False
+        self._passes = 0
+        self._cancel = False
+        while self._perform_authentication () != 0:
+            try:
+                result = fn.__call__ (*args, **kwds)
+
+                if fname == 'adminGetServerSettings':
+                    # Special case for a rubbish bit of API.
+                    if result == {}:
+                        # Authentication failed, but we aren't told that.
+                        raise cups.IPPError (cups.IPP_NOT_AUTHORIZED, '')
+                break
+            except cups.IPPError, (e, m):
+                if not self._cancel and e == cups.IPP_NOT_AUTHORIZED:
+                    self._failed ()
+                else:
+                    raise
+            except cups.HTTPError, (s,):
+                if not self._cancel and s == cups.HTTP_UNAUTHORIZED:
+                    self._failed ()
+                else:
+                    raise
+
+        return result
+
+    def _failed (self):
+        self._has_failed = True
+
+    def _password_callback (self, prompt):
+        debugprint ("Got password callback")
+        if self._cancel or self._auth_called:
+            return ''
+
+        self._auth_called = True
+        self._prompt = prompt
+        return self._use_password
+
+    def _perform_authentication (self):
+        self._passes += 1
+
+        debugprint ("Authentication pass: %d" % self._passes)
+        self._auth_called = False
+        if self._passes == 1:
+            # Haven't yet tried the operation.  Set the password
+            # callback and return > 0 so we try it for the first time.
+            cups.setPasswordCB (self._password_callback)
+            debugprint ("Authentication: password callback set")
+            return 1
+
+        if not self._has_failed:
+            # Tried the operation and it worked.  Return 0 to signal to
+            # break out of the loop.
+            debugprint ("Authentication: Operation successful")
+            return 0
+
+        self._has_failed = False
+        if self._passes == 2:
+            # Tried the operation without a password and it failed.
+            if self._user != 'root' and self._server[0] == '/':
+                # 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.
+                debugprint ("Authentication: Try as root")
+                self._use_user = 'root'
+                cups.setUser (self._use_user)
+                self._connect ()
+                return 1
+
+        if not self._prompt_allowed:
+            return -1
+
+        # Prompt.
+        d = AuthDialog (parent=self._parent)
+        d.set_prompt (self._prompt)
+        d.set_auth_info ([self._use_user, ''])
+        d.field_grab_focus ('password')
+        response = d.run ()
+        d.hide ()
+
+        if response == gtk.RESPONSE_CANCEL:
+            self._cancel = True
+            return -1
+
+        (self._use_user,
+         self._use_password) = d.get_auth_info ()
+
+        if self._user != self._use_user:
+            cups.setUser (self._use_user)
+            debugprint ("Authentication: Reconnect")
+            self._connect ()
+
+        return 1
+
+if __name__ == '__main__':
+    # Test it out.
+    set_debugging (True)
+    c = Connection (None)
+    print c.getFile ('/admin/conf/cupsd.conf', '/dev/stdout')
diff -up system-config-printer-0.7.82.2/system-config-printer.py.authconn system-config-printer-0.7.82.2/system-config-printer.py
--- system-config-printer-0.7.82.2/system-config-printer.py.authconn	2008-05-02 17:02:15.000000000 +0100
+++ system-config-printer-0.7.82.2/system-config-printer.py	2008-05-02 17:03:39.000000000 +0100
@@ -64,6 +64,7 @@ from gtk_treeviewtooltips import TreeVie
 import openprinting
 import urllib
 import troubleshoot
+import authconn
 
 domain='system-config-printer'
 import locale
@@ -233,11 +234,6 @@ class GUI(GtkGUI):
 
         self.servers = set((self.connect_server,))
 
-        try:
-            self.cups = cups.Connection()
-        except RuntimeError:
-            self.cups = None
-
         # WIDGETS
         # =======
         xml = os.environ.get ("SYSTEM_CONFIG_PRINTER_GLADE", glade_file)
@@ -337,6 +333,11 @@ class GUI(GtkGUI):
 
         gtk_label_autowrap.set_autowrap(self.MainWindow)
 
+        try:
+            self.cups = authconn.Connection(self.MainWindow)
+        except RuntimeError:
+            self.cups = None
+
         self.status_context_id = self.statusbarMain.get_context_id(
             "Connection")
         self.setConnected()
@@ -799,9 +800,11 @@ class GUI(GtkGUI):
         cups.setServer(self.connect_server)
         cups.setUser(self.connect_user)
         # Now start a new thread for connection.
-        args = ()
+        args = []
         if self.printer:
-            args = (self.printer.name,)
+            args = [self.printer.name]
+        args.append (self.MainWindow)
+        args = tuple (args)
         self.connect_thread = thread.start_new_thread(self.connect, args)
 
     def on_cancel_connect_clicked(self, widget):
@@ -813,7 +816,7 @@ class GUI(GtkGUI):
         self.connect_thread = None
         self.ConnectingDialog.hide()
 
-    def connect(self, start_printer=None):
+    def connect(self, start_printer=None, parent=None):
         """
         Open a connection to a new server. Is executed in a separate thread!
         """
@@ -841,7 +844,7 @@ class GUI(GtkGUI):
                 cups.setServer ("localhost")
 
         try:
-            connection = cups.Connection()
+            connection = authconn.Connection(parent)
             self.newPrinterGUI.dropPPDs ()
         except RuntimeError, s:
             if self.connect_thread != thread.get_ident(): return
@@ -891,7 +894,7 @@ class GUI(GtkGUI):
         attempt = 1
         while attempt <= 5:
             try:
-                self.cups = cups.Connection ()
+                self.cups._connect ()
                 break
             except RuntimeError:
                 # Connection failed.
@@ -943,7 +946,7 @@ class GUI(GtkGUI):
     def on_btnRefresh_clicked(self, button):
         if self.cups == None:
             try:
-                self.cups = cups.Connection()
+                self.cups = authconn.Connection(self.MainWindow)
             except RuntimeError:
                 pass
 
@@ -1514,14 +1517,21 @@ class GUI(GtkGUI):
             if opt:
                 custom_testpage = os.path.join(pkgdata, 'testpage-%s.ps' % opt.defchoice.lower())
 
+
+            # Connect as the current user so that the test page can be managed
+            # as a normal job.
+            user = cups.getUser ()
+            cups.setUser ('')
+            c = authconn.Connection (self.MainWindow)
             if custom_testpage and os.path.exists(custom_testpage):
                 debugprint ('Printing custom test page ' + custom_testpage)
-                job_id = self.cups.printTestPage(self.printer.name,
-                    file=custom_testpage)
+                job_id = c.printTestPage(self.printer.name,
+                                         file=custom_testpage)
             else:
                 debugprint ('Printing default test page')
-                job_id = self.cups.printTestPage(self.printer.name)
+                job_id = c.printTestPage(self.printer.name)
 
+            cups.setUser (user)
             self.lblInfo.set_markup ('<span weight="bold" size="larger">' +
                                      _("Submitted") + '</span>\n\n' +
                                      _("Test page submitted as "


Index: system-config-printer.spec
===================================================================
RCS file: /cvs/pkgs/rpms/system-config-printer/F-9/system-config-printer.spec,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -r1.178 -r1.179
--- system-config-printer.spec	15 Apr 2008 11:09:05 -0000	1.178
+++ system-config-printer.spec	2 May 2008 16:06:17 -0000	1.179
@@ -5,15 +5,14 @@
 Summary: A printer administration tool
 Name: system-config-printer
 Version: 0.7.82.2
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2+
 URL: http://cyberelk.net/tim/software/system-config-printer/
 Group: System Environment/Base
 Source0: system-config-printer-%{version}.tar.bz2
 Source1: pycups-%{pycups_version}.tar.bz2
-Source2: system-config-printer.pam
-Source3: system-config-printer.console
 Patch1: system-config-printer-0.7.82.x.patch
+Patch2: system-config-printer-authconn.patch
 
 BuildRequires: cups-devel >= 1.2
 BuildRequires: python-devel >= 2.4
@@ -59,6 +58,7 @@
 %prep
 %setup -q -a 1
 %patch1 -p1 -b .0.7.82.x
+%patch2 -p1 -b .authconn
 
 %build
 %configure
@@ -77,13 +77,6 @@
 make DESTDIR=%buildroot install
 popd
 
-mkdir -p %buildroot%{_bindir}
-mkdir -p %buildroot%{_sysconfdir}/pam.d
-mkdir -p %buildroot%{_sysconfdir}/security/console.apps
-install -p -m0644 %{SOURCE2} %buildroot%{_sysconfdir}/pam.d/%{name}
-install -p -m0644 %{SOURCE3} %buildroot%{_sysconfdir}/security/console.apps/%{name}
-ln -s consolehelper %buildroot%{_bindir}/%{name}
-
 %find_lang system-config-printer
 
 %clean
@@ -97,6 +90,7 @@
 %{python_sitearch}/cups-1.0-py%{pyver}.egg-info
 %dir %{_datadir}/%{name}
 %{_datadir}/%{name}/cupshelpers.py*
+%{_datadir}/%{name}/debug.py*
 %{_datadir}/%{name}/ppds.py*
 
 %files
@@ -105,7 +99,7 @@
 %{_bindir}/%{name}
 %{_bindir}/%{name}-applet
 %{_bindir}/my-default-printer
-%{_sbindir}/%{name}
+%{_datadir}/%{name}/authconn.py*
 %{_datadir}/%{name}/config.py*
 %{_datadir}/%{name}/my-default-printer.py*
 %{_datadir}/%{name}/openprinting.py*
@@ -123,8 +117,6 @@
 %{_datadir}/applications/redhat-system-config-printer.desktop
 %{_datadir}/applications/redhat-manage-print-jobs.desktop
 %{_datadir}/applications/redhat-my-default-printer.desktop
-%config(noreplace) %{_sysconfdir}/pam.d/%{name}
-%config(noreplace) %{_sysconfdir}/security/console.apps/%{name}
 %{_sysconfdir}/xdg/autostart/redhat-print-applet.desktop
 %{_mandir}/man1/*
 
@@ -133,6 +125,11 @@
 exit 0
 
 %changelog
+* Fri May  2 2008 Tim Waugh <twaugh at redhat.com> 0.7.82.2-3
+- Back-ported authconn dialog for better authentication when running as
+  a non-root user (bug #444306).
+- Don't install consolehelper bits any more as they are no longer needed.
+
 * Thu Apr 15 2008 Tim Waugh <twaugh at redhat.com> 0.7.82.2-2
 - Some fixes from upstream:
   - Mark bad pt translation fuzzy.


--- system-config-printer.console DELETED ---


--- system-config-printer.pam DELETED ---




More information about the fedora-extras-commits mailing list