[gvfs] admin: Handle --help even if not under pkexec



commit 4bbe3372e0d04a5e0229d1fa9f7063ea1e2623eb
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Apr 30 10:48:06 2019 +0200

    admin: Handle --help even if not under pkexec
    
    Error is shown if `gvfsd-admin --help` is started without pkexec. Change
    order of the input checks and print help in this case as well.

 daemon/gvfsbackendadmin.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
index 7b14e7a0..65a979e7 100644
--- a/daemon/gvfsbackendadmin.c
+++ b/daemon/gvfsbackendadmin.c
@@ -955,18 +955,6 @@ g_vfs_backend_admin_pre_setup (int *argc,
   GError *error = NULL;
   GOptionContext *context;
 
-  pkexec_uid = g_getenv ("PKEXEC_UID");
-  if (pkexec_uid == NULL)
-    {
-      g_printerr ("gvfsd-admin must be executed under pkexec\n");
-      exit (1);
-    }
-
-  errno = 0;
-  uid = strtol (pkexec_uid, NULL, 10);
-  if (errno != 0)
-    g_error ("Unable to convert PKEXEC_UID string to uid_t");
-
   context = g_option_context_new (NULL);
   g_option_context_set_ignore_unknown_options (context, TRUE);
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
@@ -979,6 +967,18 @@ g_vfs_backend_admin_pre_setup (int *argc,
       exit (1);
     }
 
+  pkexec_uid = g_getenv ("PKEXEC_UID");
+  if (pkexec_uid == NULL)
+    {
+      g_printerr ("gvfsd-admin must be executed under pkexec\n");
+      exit (1);
+    }
+
+  errno = 0;
+  uid = strtol (pkexec_uid, NULL, 10);
+  if (errno != 0)
+    g_error ("Unable to convert PKEXEC_UID string to uid_t");
+
   acquire_caps (uid);
   g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_address, TRUE);
 }


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