diff options
author | Thomas Haller <thaller@redhat.com> | 2020-06-23 00:12:45 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-06-23 00:42:37 +0200 |
commit | 27041e9f05da0473d56866e54218414c480bbfb4 (patch) | |
tree | e246c04182ecdd732daaa89e16694c31c42ae5e7 | |
parent | 10779d545a6fe0af8f29e065d251882ff25411fc (diff) | |
download | NetworkManager-th/strsplit-quoted-kernel-cmdline.tar.gz |
core: use nm_utils_strsplit_quoted() for splitting the kernel command lineth/strsplit-quoted-kernel-cmdline
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.
-rw-r--r-- | src/nm-core-utils.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index bc80dabf35..dc76d1fd9d 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -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; - - /* 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)) + gs_strfreev char **split = NULL; + + 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; |