summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/log.c2
-rw-r--r--src/basic/proc-cmdline.c11
-rw-r--r--src/basic/proc-cmdline.h4
-rw-r--r--src/core/main.c2
-rw-r--r--src/cryptsetup/cryptsetup-generator.c14
-rw-r--r--src/debug-generator/debug-generator.c2
-rw-r--r--src/fsck/fsck.c2
-rw-r--r--src/fstab-generator/fstab-generator.c2
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c2
-rw-r--r--src/hibernate-resume/hibernate-resume-generator.c2
-rw-r--r--src/journal/journald-server.c2
-rw-r--r--src/modules-load/modules-load.c4
-rw-r--r--src/quotacheck/quotacheck.c2
-rw-r--r--src/test/test-proc-cmdline.c2
-rw-r--r--src/udev/udevd.c5
15 files changed, 30 insertions, 28 deletions
diff --git a/src/basic/log.c b/src/basic/log.c
index 40f342ca72..2ff70be255 100644
--- a/src/basic/log.c
+++ b/src/basic/log.c
@@ -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, NULL);
+ (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)
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index 951db34d1a..8297a222b7 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -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, void *data), void *data) {
+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, voi
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, voi
/* 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, data);
+ r = parse_item(strip_prefix && unprefixed ? unprefixed : word, value, data);
if (r < 0)
return r;
}
diff --git a/src/basic/proc-cmdline.h b/src/basic/proc-cmdline.h
index a8832d8419..6d6ee95c11 100644
--- a/src/basic/proc-cmdline.h
+++ b/src/basic/proc-cmdline.h
@@ -20,7 +20,9 @@
***/
int proc_cmdline(char **ret);
-int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value, void *data), void *data);
+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);
diff --git a/src/core/main.c b/src/core/main.c
index bf9bba28d6..ffc7725f16 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1570,7 +1570,7 @@ int main(int argc, char *argv[]) {
}
if (arg_system) {
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
}
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index 7193d93070..e2dc4327fe 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -282,7 +282,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
crypto_device *d;
_cleanup_free_ char *uuid = NULL, *uuid_value = NULL;
- if (STR_IN_SET(key, "luks", "rd.luks") && value) {
+ if (streq(key, "luks") && value) {
r = parse_boolean(value);
if (r < 0)
@@ -290,7 +290,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
else
arg_enabled = r;
- } else if (STR_IN_SET(key, "luks.crypttab", "rd.luks.crypttab") && value) {
+ } else if (streq(key, "luks.crypttab") && value) {
r = parse_boolean(value);
if (r < 0)
@@ -298,7 +298,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
else
arg_read_crypttab = r;
- } else if (STR_IN_SET(key, "luks.uuid", "rd.luks.uuid") && value) {
+ } else if (streq(key, "luks.uuid") && value) {
d = get_crypto_device(startswith(value, "luks-") ? value+5 : value);
if (!d)
@@ -306,7 +306,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
d->create = arg_whitelist = true;
- } else if (STR_IN_SET(key, "luks.options", "rd.luks.options") && value) {
+ } else if (streq(key, "luks.options") && value) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
@@ -320,7 +320,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
} else if (free_and_strdup(&arg_default_options, value) < 0)
return log_oom();
- } else if (STR_IN_SET(key, "luks.key", "rd.luks.key") && value) {
+ } else if (streq(key, "luks.key") && value) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
@@ -334,7 +334,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
} else if (free_and_strdup(&arg_default_keyfile, value) < 0)
return log_oom();
- } else if (STR_IN_SET(key, "luks.name", "rd.luks.name") && value) {
+ } else if (streq(key, "luks.name") && value) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
@@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
if (!arg_disks)
goto cleanup;
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, true);
if (r < 0) {
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
r = EXIT_FAILURE;
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 0b0de1b461..7f11ec724d 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 957e0ccef8..be25c6a2b2 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -293,7 +293,7 @@ int main(int argc, char *argv[]) {
umask(0022);
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, true);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index b608eff630..e77bd71a52 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -674,7 +674,7 @@ int main(int argc, char *argv[]) {
umask(0022);
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index a25b3413ae..a098b27a8e 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -1018,7 +1018,7 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index 8be461aafa..17e670604e 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
if (!in_initrd())
return EXIT_SUCCESS;
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index e7dcbba04f..76c9baf6db 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1900,7 +1900,7 @@ int server_init(Server *s) {
journal_reset_metrics(&s->runtime_storage.metrics);
server_parse_config_file(s);
- parse_proc_cmdline(parse_proc_cmdline_item, s);
+ parse_proc_cmdline(parse_proc_cmdline_item, s, true);
if (!!s->rate_limit_interval ^ !!s->rate_limit_burst) {
log_debug("Setting both rate limit interval and burst from "USEC_FMT",%u to 0,0",
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index bd07bad446..0901fea8dc 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -62,7 +62,7 @@ static int add_modules(const char *p) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
- if (STR_IN_SET(key, "modules-load", "rd.modules-load") && value) {
+ if (streq(key, "modules-load") && value) {
r = add_modules(value);
if (r < 0)
return r;
@@ -226,7 +226,7 @@ int main(int argc, char *argv[]) {
umask(0022);
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, true);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/quotacheck/quotacheck.c b/src/quotacheck/quotacheck.c
index a87b0866cd..2714cde5c7 100644
--- a/src/quotacheck/quotacheck.c
+++ b/src/quotacheck/quotacheck.c
@@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
umask(0022);
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
diff --git a/src/test/test-proc-cmdline.c b/src/test/test-proc-cmdline.c
index e4207935c4..4101678f19 100644
--- a/src/test/test-proc-cmdline.c
+++ b/src/test/test-proc-cmdline.c
@@ -36,7 +36,7 @@ static int parse_item(const char *key, const char *value, void *data) {
}
static void test_parse_proc_cmdline(void) {
- assert_se(parse_proc_cmdline(parse_item, &obj) >= 0);
+ assert_se(parse_proc_cmdline(parse_item, &obj, true) >= 0);
}
static void test_runlevel_to_target(void) {
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 05cd5079c1..badbab6205 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1370,9 +1370,6 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (!value)
return 0;
- if (startswith(key, "rd."))
- key += strlen("rd.");
-
if (streq(key, "udev.log-priority") && value) {
r = util_log_priority(value);
if (r >= 0)
@@ -1652,7 +1649,7 @@ int main(int argc, char *argv[]) {
if (r <= 0)
goto exit;
- r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
+ r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, true);
if (r < 0)
log_warning_errno(r, "failed to parse kernel command line, ignoring: %m");