mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 08:00:37 +01:00
core: use nm_utils_strsplit_quoted() for splitting the kernel command line
The kernel command line supports escaping and quoting (at least,
according to systemd's parser, which is our example to follow).
Use nm_utils_strsplit_quoted() which supports that.
(cherry picked from commit 27041e9f05)
This commit is contained in:
parent
5d2b609e7e
commit
254528acb6
1 changed files with 4 additions and 10 deletions
|
|
@ -2778,19 +2778,13 @@ nm_utils_proc_cmdline_split (void)
|
|||
again:
|
||||
proc_cmdline = g_atomic_pointer_get (&proc_cmdline_cached);
|
||||
if (G_UNLIKELY (!proc_cmdline)) {
|
||||
gs_free const char **split = NULL;
|
||||
gs_strfreev char **split = NULL;
|
||||
|
||||
/* FIXME(release-blocker): support quotation, like systemd's proc_cmdline_extract_first().
|
||||
* For that, add a new NMUtilsStrsplitSetFlags flag. */
|
||||
split = nm_utils_strsplit_set_full (nm_utils_proc_cmdline (),
|
||||
NM_ASCII_WHITESPACES,
|
||||
NM_UTILS_STRSPLIT_SET_FLAGS_NONE);
|
||||
proc_cmdline = split
|
||||
?: NM_PTRARRAY_EMPTY (const char *);
|
||||
if (!g_atomic_pointer_compare_and_exchange (&proc_cmdline_cached, NULL, proc_cmdline))
|
||||
split = nm_utils_strsplit_quoted (nm_utils_proc_cmdline ());
|
||||
if (!g_atomic_pointer_compare_and_exchange (&proc_cmdline_cached, NULL, (gpointer) split))
|
||||
goto again;
|
||||
|
||||
g_steal_pointer (&split);
|
||||
proc_cmdline = (const char *const*) g_steal_pointer (&split);
|
||||
}
|
||||
|
||||
return proc_cmdline;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue