[gnome-shell-extensions] apps-menu: Mark copied .desktop files as trusted
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell-extensions] apps-menu: Mark copied .desktop files as trusted
- Date: Mon, 24 Apr 2017 15:22:55 +0000 (UTC)
commit 5cb2657df78a3d848a4854aa1be82a1e278cc6e9
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Apr 21 23:54:41 2017 +0200
apps-menu: Mark copied .desktop files as trusted
The application can already be launched from the menu without further
confirmation from the user, so there is no security gain in asking the
user to trust it when launched from the desktop - just set the appropriate
attributes of the newly copied file to mark it as trusted to nautilus.
https://bugzilla.gnome.org/show_bug.cgi?id=781596
extensions/apps-menu/extension.js | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index a606652..23d12fc 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -331,6 +331,30 @@ const DesktopTarget = new Lang.Class({
return source._app.app_info;
},
+ _markTrusted: function(file) {
+ let modeAttr = Gio.FILE_ATTRIBUTE_UNIX_MODE;
+ let trustedAttr = 'metadata::trusted';
+ let queryFlags = Gio.FileQueryInfoFlags.NONE;
+ let ioPriority = GLib.PRIORITY_DEFAULT;
+
+ file.query_info_async(modeAttr, queryFlags, ioPriority, null,
+ (o, res) => {
+ try {
+ let info = o.query_info_finish(res);
+ let mode = info.get_attribute_uint32(modeAttr) | 0100;
+
+ info.set_attribute_uint32(modeAttr, mode);
+ info.set_attribute_string(trustedAttr, 'yes');
+ file.set_attributes_async (info, queryFlags, ioPriority, null,
+ (o, res) => {
+ o.set_attributes_finish(res);
+ });
+ } catch(e) {
+ log('Failed to mark file as trusted: ' + e.message);
+ }
+ });
+ },
+
destroy: function() {
if (this._windowAddedId)
global.window_group.disconnect(this._windowAddedId);
@@ -362,6 +386,7 @@ const DesktopTarget = new Lang.Class({
try {
// copy_async() isn't introspectable :-(
src.copy(dst, Gio.FileCopyFlags.OVERWRITE, null, null);
+ this._markTrusted(dst);
} catch(e) {
log('Failed to copy to desktop: ' + e.message);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]