From d4b7934997035f8a793d4a7c624aefa86f05ba85 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 13 Jul 2022 17:39:36 +0200 Subject: [PATCH] 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/ *\ */ /g' /proc/cmdline > /run/NetworkManager/proc-cmdline nmcli general logging level DEFAULT domains DEFAULT --- src/core/nm-core-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ?: "";