diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-04-06 01:35:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-04-06 01:35:56 +0200 |
commit | 82e23dddebc79245ccd8333f229aa37975f81b6a (patch) | |
tree | 2cba8082de758952613c7e4bbb770f75bd8a6489 | |
parent | 67370238b55df4126e505007d46deaff8bb55a36 (diff) |
systemctl: make most operations NOPs in a chroot
-rw-r--r-- | src/systemctl.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/systemctl.c b/src/systemctl.c index 1507b52f92..eab4bf30c4 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -5336,11 +5336,17 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError /* Require a bus connection for all operations but * enable/disable */ - if (!streq(verbs[i].verb, "enable") && - !streq(verbs[i].verb, "disable") && - !bus) { - log_error("Failed to get D-Bus connection: %s", error->message); - return -EIO; + if (!streq(verbs[i].verb, "enable") && !streq(verbs[i].verb, "disable")) { + + if (running_in_chroot() > 0) { + log_info("Running in chroot, ignoring request."); + return 0; + } + + if (!bus) { + log_error("Failed to get D-Bus connection: %s", error->message); + return -EIO; + } } return verbs[i].dispatch(bus, argv + optind, left); @@ -5652,6 +5658,12 @@ int main(int argc, char*argv[]) { goto finish; } + if (running_in_chroot() > 0 && arg_action != ACTION_SYSTEMCTL) { + log_info("Running in chroot, ignoring request."); + retval = 0; + goto finish; + } + if (arg_transport == TRANSPORT_NORMAL) bus_connect(arg_user ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &bus, &private_bus, &error); else if (arg_transport == TRANSPORT_POLKIT) { |