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