summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/systemctl.c22
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) {