diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-04 11:49:42 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-12 21:58:00 +0100 |
commit | 7a44c7e31fdeebce82189b134221297919104e7d (patch) | |
tree | 2b12fa18720523a3cace0a238ea78b719c1f7356 /src/run-generator | |
parent | generators: configure logging before the first use (diff) | |
download | systemd-7a44c7e31fdeebce82189b134221297919104e7d.tar.xz systemd-7a44c7e31fdeebce82189b134221297919104e7d.zip |
generators: define custom main func definer and use it where applicable
There should be no functional difference, except that the error message
is changd from "three or no arguments" to "zero or three arguments". Somehow
the inverted form always seemed strange.
umask() call is also dropped from run-generator. I think it wasn't dropped in
053254e3cb215df3b8c905bc39b920f8817e1c7d because the run generator was merged
around the same time.
Diffstat (limited to 'src/run-generator')
-rw-r--r-- | src/run-generator/run-generator.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/run-generator/run-generator.c b/src/run-generator/run-generator.c index 243a426cda..a5dfac01d4 100644 --- a/src/run-generator/run-generator.c +++ b/src/run-generator/run-generator.c @@ -5,13 +5,12 @@ #include "fd-util.h" #include "fileio.h" #include "generator.h" -#include "main-func.h" #include "mkdir.h" #include "proc-cmdline.h" #include "specifier.h" #include "strv.h" -static const char *arg_dest = "/tmp"; +static const char *arg_dest = NULL; static char **arg_commands = NULL; static char *arg_success_action = NULL; static char *arg_failure_action = NULL; @@ -122,20 +121,10 @@ static int generate(void) { return 0; } -static int run(int argc, char *argv[]) { +static int run(const char *dest, const char *dest_early, const char *dest_late) { int r; - log_setup_generator(); - - if (argc > 1 && argc != 4) { - log_error("This program takes three or no arguments."); - return -EINVAL; - } - - if (argc > 1) - arg_dest = argv[1]; - - umask(0022); + assert_se(arg_dest = dest); r = proc_cmdline_parse(parse, NULL, PROC_CMDLINE_RD_STRICT|PROC_CMDLINE_STRIP_RD_PREFIX); if (r < 0) @@ -144,4 +133,4 @@ static int run(int argc, char *argv[]) { return generate(); } -DEFINE_MAIN_FUNCTION(run); +DEFINE_MAIN_GENERATOR_FUNCTION(run); |