systemd/0163-systemctl-print-a-clear-warning-if-people-invoke-sys.patch
Jan Macku eceb26ad96 systemd-252-3
Resolves: #2138081,#2141979,#2151993,#2155517,#2160477
2023-01-16 09:56:47 +01:00

40 lines
1.5 KiB
Diff

From d98adab06485b0da23294f8a5db4f94b40988e2a Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Fri, 2 Dec 2022 23:52:12 +0100
Subject: [PATCH] systemctl: print a clear warning if people invoke systemctl
without /proc/
(cherry picked from commit 0f958c8d4fc13ed1c1af928b2a7d91d31c7576eb)
Related: #2138081
---
src/systemctl/systemctl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 5858c3f6d3..91954d91e6 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -20,6 +20,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"
@@ -1146,6 +1147,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.");