polkitAgent: Indicate which application initiated a request

Now that the ::initiate signal may contain the PID of the initiating
process, we can try to resolve it to an application and use that to
indicate where a request originated. This should work for well-behaved
applications that only ask for permissions in response to a user action,
but unfortunately not when it would be most useful, that is when the
dialog is triggered "out of nowhere" by a background service ...

https://bugzilla.gnome.org/show_bug.cgi?id=688351
This commit is contained in:
Florian Müllner 2017-06-28 21:55:50 +02:00
parent 087f290ff7
commit ac3b3533d5
2 changed files with 13 additions and 4 deletions

View File

@ -374,6 +374,7 @@ StScrollBar {
border: 3px solid $_bubble_borders_color;
.message-dialog-main-layout { spacing: 24px; padding: 10px; }
.message-dialog-icon { -st-icon-style: symbolic; }
.message-dialog-content { spacing: 16px; }
.message-dialog-title { color: darken($osd_fg_color,25%); }
}

View File

@ -32,7 +32,7 @@ var AuthenticationDialog = new Lang.Class({
Name: 'AuthenticationDialog',
Extends: ModalDialog.ModalDialog,
_init(actionId, body, cookie, userNames) {
_init(actionId, body, cookie, app, userNames) {
this.parent({ styleClass: 'prompt-dialog' });
this.actionId = actionId;
@ -44,8 +44,11 @@ var AuthenticationDialog = new Lang.Class({
this._group.visible = !Main.sessionMode.isLocked;
});
let icon = new Gio.ThemedIcon({ name: 'dialog-password-symbolic' });
let title = _("Authentication Required");
let appInfo = app ? app.app_info : null;
let icon = appInfo ? appInfo.get_icon()
: new Gio.ThemedIcon({ name: 'dialog-password' });
let title = appInfo ? _("%s Requires Authentication").format(appInfo.get_name())
: _("Authentication Required");
let content = new Dialog.MessageDialogContent({ icon, title, body });
this.contentLayout.add_actor(content);
@ -362,6 +365,8 @@ var AuthenticationAgent = new Lang.Class({
this._native.connect('initiate', this._onInitiate.bind(this));
this._native.connect('cancel', this._onCancel.bind(this));
this._sessionUpdatedId = 0;
this._windowTracker = Shell.WindowTracker.get_default();
},
enable() {
@ -392,7 +397,10 @@ var AuthenticationAgent = new Lang.Class({
return;
}
this._currentDialog = new AuthenticationDialog(actionId, message, cookie, userNames);
let pid = parseInt(subjectPid);
let app = pid != NaN ? this._windowTracker.get_app_from_pid(pid) : null;
this._currentDialog = new AuthenticationDialog(actionId, message, cookie, app, userNames);
// We actually don't want to open the dialog until we know for
// sure that we're going to interact with the user. For