ac3a84
From 02fbe7d4c9bd34134c12978726b036ec1ceea839 Mon Sep 17 00:00:00 2001
ac3a84
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ac3a84
Date: Wed, 7 Dec 2022 13:59:01 +0900
ac3a84
Subject: [PATCH] systemctl: suppress warning about missing /proc/ when
ac3a84
 --no-warn
ac3a84
ac3a84
Follow-up for 0f958c8d4fc13ed1c1af928b2a7d91d31c7576eb.
ac3a84
ac3a84
systemctl is called many times by dnf or so, and missing /proc/ is not
ac3a84
a user's fault, but package manager's issue.
ac3a84
With this commit, we can suppress the warning by updating rpm macros if
ac3a84
necessary.
ac3a84
ac3a84
(cherry picked from commit 91dfb74ef5e38625dada2c2a6ae30152e64c3f5b)
ac3a84
ac3a84
Related: #2141979
ac3a84
---
ac3a84
 man/systemctl.xml         | 16 ++++++++++++----
ac3a84
 src/systemctl/systemctl.c | 14 +++++++-------
ac3a84
 2 files changed, 19 insertions(+), 11 deletions(-)
ac3a84
ac3a84
diff --git a/man/systemctl.xml b/man/systemctl.xml
ac3a84
index d909dc4db4..b73d4ac048 100644
ac3a84
--- a/man/systemctl.xml
ac3a84
+++ b/man/systemctl.xml
ac3a84
@@ -2004,10 +2004,18 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
ac3a84
         <term><option>--no-warn</option></term>
ac3a84
 
ac3a84
         <listitem>
ac3a84
-          <para>Don't generate the warning shown by default when using
ac3a84
-          <command>enable</command> or <command>disable</command> on units
ac3a84
-          without install information (i.e. don't have or have an empty
ac3a84
-          [Install] section).</para>
ac3a84
+          <para>Don't generate the warnings shown by default in the following cases:
ac3a84
+          <itemizedlist>
ac3a84
+            <listitem>
ac3a84
+              <para>when <command>systemctl</command> is invoked without procfs mounted on
ac3a84
+              <filename>/proc/</filename>,</para>
ac3a84
+            </listitem>
ac3a84
+            <listitem>
ac3a84
+              <para>when using <command>enable</command> or <command>disable</command> on units without
ac3a84
+              install information (i.e. don't have or have an empty [Install] section).</para>
ac3a84
+            </listitem>
ac3a84
+          </itemizedlist>
ac3a84
+          </para>
ac3a84
         </listitem>
ac3a84
       </varlistentry>
ac3a84
 
ac3a84
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
ac3a84
index 57e9966d3c..3f2b0029ca 100644
ac3a84
--- a/src/systemctl/systemctl.c
ac3a84
+++ b/src/systemctl/systemctl.c
ac3a84
@@ -277,8 +277,7 @@ static int systemctl_help(void) {
ac3a84
                "                             kexec, suspend, hibernate, suspend-then-hibernate,\n"
ac3a84
                "                             hybrid-sleep, default, rescue, emergency, and exit.\n"
ac3a84
                "  -q --quiet             Suppress output\n"
ac3a84
-               "     --no-warn           Don't generate warning when trying to enable/disable\n"
ac3a84
-               "                         units without install information\n"
ac3a84
+               "     --no-warn           Suppress several warnings shown by default\n"
ac3a84
                "     --wait              For (re)start, wait until service stopped again\n"
ac3a84
                "                         For is-system-running, wait until startup is completed\n"
ac3a84
                "     --no-block          Do not wait until operation finished\n"
ac3a84
@@ -1157,11 +1156,12 @@ static int run(int argc, char *argv[]) {
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
+                log_full(arg_no_warn ? LOG_DEBUG : LOG_WARNING,
ac3a84
+                         "%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)