mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-27 14:03:43 +03:00
systemctl: make most operations NOPs in a chroot
This commit is contained in:
parent
67370238b5
commit
82e23dddeb
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user