proc-cmdline: introduce proc_cmdline_strv()

When we are running in a container, we parse the command line of PID1 in
proc_cmdline_parse() or friends. Previously, first we merge the command
line nulstr as a single string, and then split by using
extract_first_word(). That's not only redundant, but also unsafe when
the command line argument contain a space.

This drops the redundant steps, hence we can safely parse arguments with
space.
This commit is contained in:
Yu Watanabe
2023-03-29 10:34:39 +09:00
parent 70806d4554
commit 94e0130ab0
3 changed files with 40 additions and 20 deletions
+1
View File
@@ -15,6 +15,7 @@ typedef enum ProcCmdlineFlags {
typedef int (*proc_cmdline_parse_t)(const char *key, const char *value, void *data);
int proc_cmdline(char **ret);
int proc_cmdline_strv(char ***ret);
int proc_cmdline_parse(const proc_cmdline_parse_t parse, void *userdata, ProcCmdlineFlags flags);