summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2019-04-30 10:48:06 +0200
committerOndrej Holy <oholy@redhat.com>2019-04-30 11:03:16 +0200
commit4bbe3372e0d04a5e0229d1fa9f7063ea1e2623eb (patch)
tree228ef3e38575174e27044b76823383040bdd1d4d
parenta9362fa81bc96d7cf2b8730b4f62da829f050946 (diff)
downloadgvfs-4bbe3372e0d04a5e0229d1fa9f7063ea1e2623eb.tar.gz
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.
-rw-r--r--daemon/gvfsbackendadmin.c24
1 files 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);
}