diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2015-11-03 14:45:56 +0300 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2015-11-03 14:47:39 +0300 |
commit | 7dcc56715d150ff7e8b5459877879430cff790f7 (patch) | |
tree | 3c7a2f741d492b77d1c0b266875c901a15d3b70b /src/debug-generator | |
parent | e2c9a13136cdf71b97a4e26b285ca2c3ba96db66 (diff) |
debug-generator: respect kernel parameters for default unit setting
Diffstat (limited to 'src/debug-generator')
-rw-r--r-- | src/debug-generator/debug-generator.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index e16c3b9453..413cfd0388 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -23,11 +23,13 @@ #include "mkdir.h" #include "parse-util.h" #include "proc-cmdline.h" +#include "special.h" #include "string-util.h" #include "strv.h" #include "unit-name.h" #include "util.h" +static char *arg_default_unit = NULL; static const char *arg_dest = "/tmp"; static char **arg_mask = NULL; static char **arg_wants = NULL; @@ -80,6 +82,24 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { arg_debug_shell = r; } else arg_debug_shell = true; + } else if (streq(key, "systemd.unit")) { + + if (!value) + log_error("Missing argument for systemd.unit= kernel command line parameter."); + else { + r = free_and_strdup(&arg_default_unit, value); + if (r < 0) + return log_error_errno(r, "Failed to set default unit %s: %m", value); + } + } else if (!value) { + const char *target; + + target = runlevel_to_target(key); + if (target) { + r = free_and_strdup(&arg_default_unit, target); + if (r < 0) + return log_error_errno(r, "Failed to set default unit %s: %m", target); + } } return 0; @@ -118,7 +138,7 @@ static int generate_wants_symlinks(void) { STRV_FOREACH(u, arg_wants) { _cleanup_free_ char *p = NULL, *f = NULL; - p = strjoin(arg_dest, "/default.target.wants/", *u, NULL); + p = strjoin(arg_dest, "/", arg_default_unit, ".wants/", *u, NULL); if (!p) return log_oom(); @@ -154,6 +174,12 @@ int main(int argc, char *argv[]) { umask(0022); + r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET); + if (r < 0) { + log_error_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET); + goto finish; + } + r = parse_proc_cmdline(parse_proc_cmdline_item); if (r < 0) log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m"); |