From 27041e9f05da0473d56866e54218414c480bbfb4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 23 Jun 2020 00:12:45 +0200 Subject: 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. --- src/nm-core-utils.c | 16 +++++----------- 1 file 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; -- cgit v1.2.1