]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: print a clear warning if people invoke systemctl without /proc/ 25616/head
authorLennart Poettering <lennart@poettering.net>
Fri, 2 Dec 2022 22:52:12 +0000 (23:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 2 Dec 2022 22:56:20 +0000 (23:56 +0100)
src/systemctl/systemctl.c

index 4f2637f0f1e44015ce3f78ce1f3be05707692383..29f96681df1facea52c03fbc9f0ba0d00a2ff339 100644 (file)
@@ -22,6 +22,7 @@
 #include "rlimit-util.h"
 #include "sigbus.h"
 #include "signal-util.h"
+#include "stat-util.h"
 #include "string-table.h"
 #include "systemctl-add-dependency.h"
 #include "systemctl-cancel-job.h"
@@ -1148,6 +1149,13 @@ static int run(int argc, char *argv[]) {
         if (r <= 0)
                 goto finish;
 
+        if (proc_mounted() == 0)
+                log_warning("%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n"
+                            "your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway.\n"
+                            "Your mileage may vary.",
+                            emoji_enabled() ? special_glyph(SPECIAL_GLYPH_WARNING_SIGN) : "",
+                            emoji_enabled() ? " " : "");
+
         if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
                 if (!arg_quiet)
                         log_info("Running in chroot, ignoring request.");