[gnome-shell] introspect: Add helper to check method call permission



commit 059fb5c7cbc84050bba654a3a8ace5d5d149e99e
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Sep 25 20:36:28 2019 +0200

    introspect: Add helper to check method call permission
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/757

 js/misc/introspect.js | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
index d12aac69de..67965f7d40 100644
--- a/js/misc/introspect.js
+++ b/js/misc/introspect.js
@@ -119,9 +119,18 @@ var IntrospectService = class {
                 type == Meta.WindowType.UTILITY;
     }
 
+    _isInvocationAllowed(invocation) {
+        if (this._isIntrospectEnabled())
+            return true;
+
+        if (this._isSenderWhitelisted(invocation.get_sender()))
+            return true;
+
+        return false;
+    }
+
     GetRunningApplicationsAsync(params, invocation) {
-        if (!this._isIntrospectEnabled() &&
-            !this._isSenderWhitelisted(invocation.get_sender())) {
+        if (!this._isInvocationAllowed(invocation)) {
             invocation.return_error_literal(Gio.DBusError,
                                             Gio.DBusError.ACCESS_DENIED,
                                             'App introspection not allowed');
@@ -136,8 +145,7 @@ var IntrospectService = class {
         let apps = this._appSystem.get_running();
         let windowsList = {};
 
-        if (!this._isIntrospectEnabled() &&
-            !this._isSenderWhitelisted(invocation.get_sender())) {
+        if (!this._isInvocationAllowed(invocation)) {
             invocation.return_error_literal(Gio.DBusError,
                                             Gio.DBusError.ACCESS_DENIED,
                                             'App introspection not allowed');


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