summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-07-13 17:39:36 +0200
committerThomas Haller <thaller@redhat.com>2022-07-18 14:58:00 +0200
commitd4b7934997035f8a793d4a7c624aefa86f05ba85 (patch)
treea6972d1d7472f81683d97b3e598a08b4721a7a99
parent4dd4d5b7591f96fdf1c8a2ae1c9caaffa11d9a33 (diff)
downloadNetworkManager-d4b7934997035f8a793d4a7c624aefa86f05ba85.tar.gz
core: support "/run/NetworkManager/proc-cmdline" to overwrite /proc/cmdline
We read /proc/cmdline for "match.kernel-command-line". But next we will also honor "nm.debug" on the kernel command line, to enable debug logging. For "nm.debug" it makes sense that it overwrites the debug options from the command line and from "NetworkManager.conf". That means, if you set "nm.debug", then verbose logging will be enabled. It can only be turned off again at runtime (via D-Bus), otherwise, it's hard to avoid. It still can make sense to overrule this setting once again. Support that, by honoring a file "/run/NetworkManager/proc-cmdline" to be used instead of "/proc/cmdline". This option is mainly for debugging and testing, but it might be useful in production too, if you had "nm.debug" enabled during boot, but later want to disable it until next reboot. Then you could do: sed 's/ *\<nm\.debug\> */ /g' /proc/cmdline > /run/NetworkManager/proc-cmdline nmcli general logging level DEFAULT domains DEFAULT
-rw-r--r--src/core/nm-core-utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c
index b2ebe30c25..66f8204502 100644
--- a/src/core/nm-core-utils.c
+++ b/src/core/nm-core-utils.c
@@ -3090,7 +3090,10 @@ again:
if (G_UNLIKELY(!proc_cmdline)) {
gs_free char *str = NULL;
- g_file_get_contents("/proc/cmdline", &str, NULL, NULL);
+ /* /run/NetworkManager/proc-cmdline can be used to overrule /proc/cmdline. */
+ if (!g_file_get_contents(NMRUNDIR "/proc-cmdline", &str, NULL, NULL))
+ g_file_get_contents("/proc/cmdline", &str, NULL, NULL);
+
str = nm_str_realloc(str);
proc_cmdline = str ?: "";