From 0fb8686ccc5bb5de7f9a0d7ea9823963c872ebe8 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 1 Sep 2017 15:03:02 -0400 Subject: [PATCH] bin/admin: Check for booted sysroot for root-required commands Drops a use of `ostree_sysroot_get_path()`, prep for `ostree_sysroot_new_at()`. Closes: #1123 Approved by: jlebon --- src/ostree/ot-main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index cd7f0f4c..011ae16c 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -403,10 +403,12 @@ ostree_admin_option_context_parse (GOptionContext *context, if (flags & OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER) { - GFile *path = ostree_sysroot_get_path (sysroot); + OstreeDeployment *booted = ostree_sysroot_get_booted_deployment (sysroot); - /* If sysroot path is "/" then user must be root. */ - if (!g_file_has_parent (path, NULL) && getuid () != 0) + /* Only require root if we're manipulating a booted sysroot. (Mostly + * useful for the test suite) + */ + if (booted && getuid () != 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, "You must be root to perform this command");