From aef5a7331e112f4d8c3ce7ccc4abcc4b6c2a2c76 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 1 Sep 2017 14:43:33 -0400 Subject: [PATCH] bin/admin: Check for booted deployment to see if we should reboot Rather than calling `ostree_sysroot_get_path()`, which I'd like to deprecate for the same reason as `ostree_repo_get_path()`. Closes: #1123 Approved by: jlebon --- src/ostree/ot-admin-functions.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ostree/ot-admin-functions.c b/src/ostree/ot-admin-functions.c index a0a66b6a..6a99db04 100644 --- a/src/ostree/ot-admin-functions.c +++ b/src/ostree/ot-admin-functions.c @@ -151,13 +151,15 @@ ot_admin_sysroot_lock (OstreeSysroot *sysroot, gboolean ot_admin_execve_reboot (OstreeSysroot *sysroot, GError **error) { - g_autoptr(GFile) real_sysroot = g_file_new_for_path ("/"); + OstreeDeployment *booted = ostree_sysroot_get_booted_deployment (sysroot); - if (g_file_equal (ostree_sysroot_get_path (sysroot), real_sysroot)) - { - if (execlp ("systemctl", "systemctl", "reboot", NULL) < 0) - return glnx_throw_errno (error); - } + /* If the sysroot isn't booted, we shouldn't reboot, even if somehow the user + * asked for it; might accidentally be specified in a build script, etc. + */ + if (!booted) + return TRUE; + if (execlp ("systemctl", "systemctl", "reboot", NULL) < 0) + return glnx_throw_errno_prefix (error, "execve(systemctl reboot)"); return TRUE; }