]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl-is-system-running: display "offline" with --image
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Mon, 15 Jan 2024 09:55:31 +0000 (10:55 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 15 Jan 2024 11:58:38 +0000 (11:58 +0000)
With the `--image` option, the `running_in_chroot` check is not enough. E.g.:

```
> build/systemctl --image /tmp/20240108-openSUSE.raw is-system-running
running
```

src/systemctl/systemctl-is-system-running.c

index 6b521c93476bfe80aad169d922f65f0d0ec76c07..59be6a7a7ecfef7a78520d9ff1958888afa4c88c 100644 (file)
@@ -29,7 +29,7 @@ int verb_is_system_running(int argc, char *argv[], void *userdata) {
         sd_bus *bus;
         int r;
 
-        if (running_in_chroot() > 0 || (arg_transport == BUS_TRANSPORT_LOCAL && !sd_booted())) {
+        if (!isempty(arg_root) || running_in_chroot() > 0 || (arg_transport == BUS_TRANSPORT_LOCAL && !sd_booted())) {
                 if (!arg_quiet)
                         puts("offline");
                 return EXIT_FAILURE;