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
This commit is contained in:
Thomas Haller 2022-07-13 17:39:36 +02:00
parent 4dd4d5b759
commit d4b7934997
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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 ?: "";