[gnome-shell] polkit: Find the best user to authenticate as



commit 55d6c5ea8f72df17b2928d015644dcd3f31f6b96
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 17 22:42:37 2011 -0500

    polkit: Find the best user to authenticate as
    
    We prefer to ask the user for his own password. If PolicyKit
    is not configured to accept that, try the root password. If
    PolicyKit does not accept that either, ask for password of
    the first user that PolicyKit _will_ accept. The last case
    is a bit broken, but should rarely occur in real-life
    configurations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=651547

 js/ui/polkitAuthenticationAgent.js |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/polkitAuthenticationAgent.js b/js/ui/polkitAuthenticationAgent.js
index 2d7063a..6f01039 100644
--- a/js/ui/polkitAuthenticationAgent.js
+++ b/js/ui/polkitAuthenticationAgent.js
@@ -27,6 +27,7 @@ const AccountsService = imports.gi.AccountsService;
 const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
 const Pango = imports.gi.Pango;
+const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const Mainloop = imports.mainloop;
 const Polkit = imports.gi.Polkit;
@@ -88,10 +89,14 @@ AuthenticationDialog.prototype = {
         if (userNames.length > 1) {
             log('polkitAuthenticationAgent: Received ' + userNames.length +
                 ' identities that can be used for authentication. Only ' +
-                'considering the first one.');
+                'considering one.');
         }
 
-        let userName = userNames[0];
+        let userName = GLib.get_user_name();
+        if (userNames.indexOf(userName) < 0)
+            userName = 'root';
+        if (userNames.indexOf(userName) < 0)
+            userName = userNames[0];
 
         this._user = AccountsService.UserManager.get_default().get_user(userName);
         let userRealName = this._user.get_real_name()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]