bin/admin: Don't load sysroot for root commands
authorJonathan Lebon <jlebon@redhat.com>
Fri, 8 Sep 2017 19:40:59 +0000 (15:40 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 13 Sep 2017 14:32:20 +0000 (14:32 +0000)
There's no need to load the sysroot for root commands which have
subcommands, like `ostree admin` and `ostree admin instutil`. Otherwise,
even just calling them without arguments will cause a failure. The
subcommands will have the appropriate flags set as needed.

Closes: #1126
Approved by: cgwalters

src/ostree/ot-admin-builtin-instutil.c
src/ostree/ot-builtin-admin.c
src/ostree/ot-main.c

index 7b446e939ef3fd70d0ff08e2a401edea108e4995..0770b1b205f7c05929e33f8f5d46b6a8a3e33187 100644 (file)
@@ -106,7 +106,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
 
       /* This will not return for some options (e.g. --version). */
       if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
-                                             OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+                                             OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
                                              NULL, cancellable, error))
         {
           if (subcommand_name == NULL)
index 16aaec03c4d7d74efa32d6ad9cfa02a8aa0243c2..ce0b2ffadb09cddb0649b07997a6dbe2c232f14b 100644 (file)
@@ -126,7 +126,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
 
       /* This will not return for some options (e.g. --version). */
       if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
-                                             OSTREE_ADMIN_BUILTIN_FLAG_NONE | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
+                                             OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
                                              NULL, cancellable, error))
         {
           if (subcommand_name == NULL)
index eda787b46cfa1afc1420d8d8867abe9f3b73bc7b..a6ddfe748389a4c41f164c6ef6f21015548073ae 100644 (file)
@@ -374,10 +374,11 @@ ostree_admin_option_context_parse (GOptionContext *context,
 
   g_option_context_add_main_entries (context, global_admin_entries, NULL);
 
-  if (!ostree_option_context_parse (context, main_entries, argc, argv, OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
+  if (!ostree_option_context_parse (context, main_entries, argc, argv,
+                                    OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
     return FALSE;
 
-  if (flags & OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT)
+  if (!opt_print_current_dir && (flags & OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT))
     {
       g_assert_null (out_sysroot);
       /* Early return if no sysroot is requested */