This stripping is contolled by a new boolean parameter. When the parameter
is true, it means that the caller does not care about the distinction between
initrd and real root, and wants to act on both rd-dot-prefixed and unprefixed
parameters in the initramfs, and only on the unprefixed parameters in real
root. If the parameter is false, behaviour is the same as before.
Changes by caller:
log.c (systemd.log_*): changed to accept rd-dot-prefix params
pid1: no change, custom logic
cryptsetup-generator: no change, still accepts rd-dot-prefix params
debug-generator: no change, does not accept rd-dot-prefix params
fsck: changed to accept rd-dot-prefix params
fstab-generator: no change, custom logic
gpt-auto-generator: no change, custom logic
hibernate-resume-generator: no change, does not accept rd-dot-prefix params
journald: changed to accept rd-dot-prefix params
modules-load: no change, still accepts rd-dot-prefix params
quote-check: no change, does not accept rd-dot-prefix params
udevd: no change, still accepts rd-dot-prefix params
I added support for "rd." params in the three cases where I think it's
useful: logging, fsck options, journald forwarding options.
15 files changed:
/* Only try to read the command line in daemons.
We assume that anything that has a controlling
tty is user stuff. */
/* 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)
e = secure_getenv("SYSTEMD_LOG_TARGET");
if (e && log_set_target_from_string(e) < 0)
return read_one_line_file("/proc/cmdline", 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;
_cleanup_free_ char *line = NULL;
const char *p;
int r;
p = line;
for (;;) {
_cleanup_free_ char *word = NULL;
p = line;
for (;;) {
_cleanup_free_ char *word = NULL;
+ char *value = NULL, *unprefixed;
r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
if (r < 0)
r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
if (r < 0)
/* Filter out arguments that are intended only for the
* initrd */
/* 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;
continue;
value = strchr(word, '=');
if (value)
*(value++) = 0;
- r = parse_item(word, value, data);
+ r = parse_item(strip_prefix && unprefixed ? unprefixed : word, value, data);
***/
int proc_cmdline(char **ret);
***/
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);
int get_proc_cmdline_key(const char *parameter, char **value);
int shall_restore_state(void);
- 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");
}
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
}
crypto_device *d;
_cleanup_free_ char *uuid = NULL, *uuid_value = NULL;
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)
r = parse_boolean(value);
if (r < 0)
- } 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)
r = parse_boolean(value);
if (r < 0)
else
arg_read_crypttab = r;
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)
d = get_crypto_device(startswith(value, "luks-") ? value+5 : value);
if (!d)
d->create = arg_whitelist = true;
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) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
} else if (free_and_strdup(&arg_default_options, value) < 0)
return log_oom();
} 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) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
} else if (free_and_strdup(&arg_default_keyfile, value) < 0)
return log_oom();
} 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) {
r = sscanf(value, "%m[0-9a-fA-F-]=%ms", &uuid, &uuid_value);
if (r == 2) {
if (!arg_disks)
goto cleanup;
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;
if (r < 0) {
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
r = EXIT_FAILURE;
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
if (!in_initrd())
return EXIT_SUCCESS;
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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
journal_reset_metrics(&s->runtime_storage.metrics);
server_parse_config_file(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",
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",
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
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;
r = add_modules(value);
if (r < 0)
return r;
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- 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");
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
}
static void test_parse_proc_cmdline(void) {
}
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) {
}
static void test_runlevel_to_target(void) {
- if (startswith(key, "rd."))
- key += strlen("rd.");
-
if (streq(key, "udev.log-priority") && value) {
r = util_log_priority(value);
if (r >= 0)
if (streq(key, "udev.log-priority") && value) {
r = util_log_priority(value);
if (r >= 0)
- 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");
if (r < 0)
log_warning_errno(r, "failed to parse kernel command line, ignoring: %m");