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/rc-local-generator | |
parent | aba311f7ffb1370156f48061a5fdc2da9551e57f (diff) | |
download | systemd-7a44c7e31fdeebce82189b134221297919104e7d.tar.gz |
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/rc-local-generator')
-rw-r--r-- | src/rc-local-generator/rc-local-generator.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index cd5510bf12..7a3948e92d 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -6,12 +6,11 @@ #include "generator.h" #include "log.h" -#include "main-func.h" #include "mkdir.h" #include "string-util.h" #include "util.h" -static const char *arg_dest = "/tmp"; +static const char *arg_dest = NULL; /* So you are reading this, and might wonder: why is this implemented as a generator rather than as a plain, statically * enabled service that carries appropriate ConditionFileIsExecutable= lines? The answer is this: conditions bypass @@ -55,16 +54,10 @@ static int check_executable(const char *path) { 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 = 0, k = 0; - log_setup_generator(); - - if (argc > 1 && argc != 4) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes three or no arguments."); - - if (argc > 1) - arg_dest = argv[1]; + assert_se(arg_dest = dest); if (check_executable(RC_LOCAL_SCRIPT_PATH_START) >= 0) { log_debug("Automatically adding rc-local.service."); @@ -81,4 +74,4 @@ static int run(int argc, char *argv[]) { return r < 0 ? r : k; } -DEFINE_MAIN_FUNCTION(run); +DEFINE_MAIN_GENERATOR_FUNCTION(run); |