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:
Thomas Haller 2020-06-23 00:12:45 +02:00
parent 5d2b609e7e
commit 254528acb6
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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;