Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 830534 Details for
Bug 999297
Username/Password not stored with smbspool backend
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
0001-Factor-out-username-password-lookup-for-reuse
0001-Factor-out-username-password-lookup-for-reuse.patch (text/plain), 11.07 KB, created by
Andre Heinecke
on 2013-11-29 09:03:29 UTC
(
hide
)
Description:
0001-Factor-out-username-password-lookup-for-reuse
Filename:
MIME Type:
Creator:
Andre Heinecke
Created:
2013-11-29 09:03:29 UTC
Size:
11.07 KB
patch
obsolete
>From 2a6e0d4ed50c6dc9d7fb195970f5a5bcb62c83b5 Mon Sep 17 00:00:00 2001 >From: Andre Heinecke <aheinecke@intevation.de> >Date: Tue, 26 Nov 2013 12:20:26 +0100 >Subject: [PATCH 1/3] Factor out username/password lookup for reuse > > Update Job is now reduced to checking the state of the > job and calling the new function get_authentication if > authentication is required. get_authentication handles > the keyring integration and takes care of presenting the > authentication dialog to the user if necessary. >--- > jobviewer.py | 197 +++++++++++++++++++++++++++++----------------------------- > 1 files changed, 99 insertions(+), 98 deletions(-) > >diff --git a/jobviewer.py b/jobviewer.py >index 931e4a8..83fe8a9 100644 >--- a/jobviewer.py >+++ b/jobviewer.py >@@ -906,112 +906,113 @@ class JobViewer (GtkGUI): > self.treeview.queue_draw () > > # Check whether authentication is required. >- if self.applet: >- job_requires_auth = (s == cups.IPP_JOB_HELD and >- data.get ('job-hold-until', 'none') == >- 'auth-info-required') >- >- if (job_requires_auth and >- not self.auth_info_dialogs.has_key (job)): >- try: >- cups.require ("1.9.37") >- except: >- debugprint ("Authentication required but " >- "authenticateJob() not available") >- return >+ job_requires_auth = (s == cups.IPP_JOB_HELD and >+ data.get ('job-hold-until', 'none') == >+ 'auth-info-required') >+ if self.applet and job_requires_auth: >+ self.get_authentication (job, data.get ('device-uri'), >+ data.get ('auth-info-required', [])) >+ self.update_sensitivity () > >- # Find out which auth-info is required. >- try_keyring = USE_KEYRING >- keyring_attrs = dict() >- auth_info = None >- if try_keyring and 'password' in auth_info_required: >- auth_info_required = data.get ('auth-info-required', []) >- device_uri = data.get ("device-uri") >- (scheme, rest) = urllib.splittype (device_uri) >- if scheme == 'smb': >- uri = smburi.SMBURI (uri=device_uri) >- (group, server, share, >- user, password) = uri.separate () >- keyring_attrs["domain"] = str (group) >- else: >- (serverport, rest) = urllib.splithost (rest) >- if serverport == None: >- server = None >- else: >- (server, port) = urllib.splitnport (serverport) >+ def get_authentication (self, job, device_uri, auth_info_required): >+ # Check if we have requested authentication for this job already >+ if not self.auth_info_dialogs.has_key (job): >+ try: >+ cups.require ("1.9.37") >+ except: >+ debugprint ("Authentication required but " >+ "authenticateJob() not available") >+ return > >- if scheme == None or server == None: >- try_keyring = False >+ # Find out which auth-info is required. >+ try_keyring = USE_KEYRING >+ keyring_attrs = dict() >+ auth_info = None >+ if try_keyring and 'password' in auth_info_required: >+ (scheme, rest) = urllib.splittype (device_uri) >+ if scheme == 'smb': >+ uri = smburi.SMBURI (uri=device_uri) >+ (group, server, share, >+ user, password) = uri.separate () >+ keyring_attrs["domain"] = str (group) >+ else: >+ (serverport, rest) = urllib.splithost (rest) >+ if serverport == None: >+ server = None > else: >- keyring_attrs.update ({ "server": str (server.lower ()), >- "protocol": str (scheme)}) >+ (server, port) = urllib.splitnport (serverport) > >- if job in self.authenticated_jobs: >- # We've already tried to authenticate this job before. >+ if scheme == None or server == None: > try_keyring = False >+ else: >+ keyring_attrs.update ({ "server": str (server.lower ()), >+ "protocol": str (scheme)}) > >- if try_keyring and 'password' in auth_info_required: >- type = GnomeKeyring.ItemType.NETWORK_PASSWORD >- attrs = GnomeKeyring.Attribute.list_new () >- for key, val in keyring_attrs.iteritems (): >- GnomeKeyring.Attribute.list_append_string (attrs, >- key, >- val) >- (result, items) = GnomeKeyring.find_items_sync (type, >- attrs) >- if result == GnomeKeyring.Result.OK: >- auth_info = map (lambda x: '', auth_info_required) >- ind = auth_info_required.index ('username') >- >- for attr in GnomeKeyring.attribute_list_to_glist ( >- items[0].attributes): >- # It might be safe to assume here that the >- # user element is always the second item in a >- # NETWORK_PASSWORD element but lets make sure. >- if attr.name == 'user': >- auth_info[ind] = attr.get_string() >- break >- else: >- debugprint ("Did not find username keyring " >- "attributes.") >+ if job in self.authenticated_jobs: >+ # We've already tried to authenticate this job before. >+ try_keyring = False > >- ind = auth_info_required.index ('password') >- auth_info[ind] = items[0].secret >+ if try_keyring and 'password' in auth_info_required: >+ type = GnomeKeyring.ItemType.NETWORK_PASSWORD >+ attrs = GnomeKeyring.Attribute.list_new () >+ for key, val in keyring_attrs.iteritems (): >+ GnomeKeyring.Attribute.list_append_string (attrs, >+ key, >+ val) >+ (result, items) = GnomeKeyring.find_items_sync (type, >+ attrs) >+ if result == GnomeKeyring.Result.OK: >+ auth_info = map (lambda x: '', auth_info_required) >+ ind = auth_info_required.index ('username') >+ >+ for attr in GnomeKeyring.attribute_list_to_glist ( >+ items[0].attributes): >+ # It might be safe to assume here that the >+ # user element is always the second item in a >+ # NETWORK_PASSWORD element but lets make sure. >+ if attr.name == 'user': >+ auth_info[ind] = attr.get_string() >+ break > else: >- debugprint ("gnomekeyring: look-up result %s" % >- repr (result)) >+ debugprint ("Did not find username keyring " >+ "attributes.") > >- if try_keyring and c == None: >- try: >- c = authconn.Connection (self.JobsWindow, >- host=self.host, >- port=self.port, >- encryption=self.encryption) >- except RuntimeError: >- try_keyring = False >- >- if try_keyring and auth_info != None: >- try: >- c._begin_operation (_("authenticating job")) >- c.authenticateJob (job, auth_info) >- c._end_operation () >- self.update_monitor () >- debugprint ("Automatically authenticated job %d" % job) >- self.authenticated_jobs.add (job) >- return >- except cups.IPPError: >- c._end_operation () >- nonfatalException () >- return >- except: >- c._end_operation () >- nonfatalException () >- >- if data.has_key ('auth-info-required'): >- username = pwd.getpwuid (os.getuid ())[0] >- keyring_attrs["user"] = str (username) >- self.display_auth_info_dialog (job, keyring_attrs) >- self.update_sensitivity () >+ ind = auth_info_required.index ('password') >+ auth_info[ind] = items[0].secret >+ else: >+ debugprint ("gnomekeyring: look-up result %s" % >+ repr (result)) >+ >+ if try_keyring: >+ try: >+ c = authconn.Connection (self.JobsWindow, >+ host=self.host, >+ port=self.port, >+ encryption=self.encryption) >+ except RuntimeError: >+ try_keyring = False >+ >+ if try_keyring and auth_info != None: >+ try: >+ c._begin_operation (_("authenticating job")) >+ c.authenticateJob (job, auth_info) >+ c._end_operation () >+ self.update_monitor () >+ debugprint ("Automatically authenticated job %d" % job) >+ self.authenticated_jobs.add (job) >+ return >+ except cups.IPPError: >+ c._end_operation () >+ nonfatalException () >+ return >+ except: >+ c._end_operation () >+ nonfatalException () >+ >+ if auth_info_required: >+ username = pwd.getpwuid (os.getuid ())[0] >+ keyring_attrs["user"] = str (username) >+ self.display_auth_info_dialog (job, keyring_attrs) > > def display_auth_info_dialog (self, job, keyring_attrs=None): > data = self.jobs[job] >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 999297
:
814931
|
814932
|
814934
| 830534 |
830535
|
830537