Merge pull request #4459 from keszybz/commandline-parsing
Commandline parsing simplification and udev fix
This commit is contained in:
+2
-2
@@ -967,7 +967,7 @@ int log_set_max_level_from_string(const char *e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value) {
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
|
||||
/*
|
||||
* The systemd.log_xyz= settings are parsed by all tools, and
|
||||
@@ -1012,7 +1012,7 @@ void log_parse_environment(void) {
|
||||
/* Only try to read the command line in daemons.
|
||||
We assume that anything that has a controlling
|
||||
tty is user stuff. */
|
||||
(void) parse_proc_cmdline(parse_proc_cmdline_item);
|
||||
(void) parse_proc_cmdline(parse_proc_cmdline_item, NULL, true);
|
||||
|
||||
e = secure_getenv("SYSTEMD_LOG_TARGET");
|
||||
if (e && log_set_target_from_string(e) < 0)
|
||||
|
||||
@@ -42,7 +42,9 @@ int proc_cmdline(char **ret) {
|
||||
return read_one_line_file("/proc/cmdline", ret);
|
||||
}
|
||||
|
||||
int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
|
||||
int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value, void *data),
|
||||
void *data,
|
||||
bool strip_prefix) {
|
||||
_cleanup_free_ char *line = NULL;
|
||||
const char *p;
|
||||
int r;
|
||||
@@ -56,7 +58,7 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
|
||||
p = line;
|
||||
for (;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
char *value = NULL;
|
||||
char *value = NULL, *unprefixed;
|
||||
|
||||
r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
|
||||
if (r < 0)
|
||||
@@ -66,14 +68,15 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
|
||||
|
||||
/* Filter out arguments that are intended only for the
|
||||
* initrd */
|
||||
if (!in_initrd() && startswith(word, "rd."))
|
||||
unprefixed = startswith(word, "rd.");
|
||||
if (unprefixed && !in_initrd())
|
||||
continue;
|
||||
|
||||
value = strchr(word, '=');
|
||||
if (value)
|
||||
*(value++) = 0;
|
||||
|
||||
r = parse_item(word, value);
|
||||
r = parse_item(strip_prefix && unprefixed ? unprefixed : word, value, data);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
***/
|
||||
|
||||
int proc_cmdline(char **ret);
|
||||
int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value));
|
||||
int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value, void *data),
|
||||
void *data,
|
||||
bool strip_prefix);
|
||||
int get_proc_cmdline_key(const char *parameter, char **value);
|
||||
|
||||
int shall_restore_state(void);
|
||||
|
||||
Reference in New Issue
Block a user