ac3a84
From d98adab06485b0da23294f8a5db4f94b40988e2a Mon Sep 17 00:00:00 2001
ac3a84
From: Lennart Poettering <lennart@poettering.net>
ac3a84
Date: Fri, 2 Dec 2022 23:52:12 +0100
ac3a84
Subject: [PATCH] systemctl: print a clear warning if people invoke systemctl
ac3a84
 without /proc/
ac3a84
ac3a84
(cherry picked from commit 0f958c8d4fc13ed1c1af928b2a7d91d31c7576eb)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 src/systemctl/systemctl.c | 8 ++++++++
ac3a84
 1 file changed, 8 insertions(+)
ac3a84
ac3a84
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
ac3a84
index 5858c3f6d3..91954d91e6 100644
ac3a84
--- a/src/systemctl/systemctl.c
ac3a84
+++ b/src/systemctl/systemctl.c
ac3a84
@@ -20,6 +20,7 @@
ac3a84
 #include "rlimit-util.h"
ac3a84
 #include "sigbus.h"
ac3a84
 #include "signal-util.h"
ac3a84
+#include "stat-util.h"
ac3a84
 #include "string-table.h"
ac3a84
 #include "systemctl-add-dependency.h"
ac3a84
 #include "systemctl-cancel-job.h"
ac3a84
@@ -1146,6 +1147,13 @@ static int run(int argc, char *argv[]) {
ac3a84
         if (r <= 0)
ac3a84
                 goto finish;
ac3a84
 
ac3a84
+        if (proc_mounted() == 0)
ac3a84
+                log_warning("%s%s/proc/ is not mounted. This is not a supported mode of operation. Please fix\n"
ac3a84
+                            "your invocation environment to mount /proc/ and /sys/ properly. Proceeding anyway.\n"
ac3a84
+                            "Your mileage may vary.",
ac3a84
+                            emoji_enabled() ? special_glyph(SPECIAL_GLYPH_WARNING_SIGN) : "",
ac3a84
+                            emoji_enabled() ? " " : "");
ac3a84
+
ac3a84
         if (arg_action != ACTION_SYSTEMCTL && running_in_chroot() > 0) {
ac3a84
                 if (!arg_quiet)
ac3a84
                         log_info("Running in chroot, ignoring request.");