From 7a44c7e31fdeebce82189b134221297919104e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Dec 2018 11:49:42 +0100 Subject: 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. --- src/rc-local-generator/rc-local-generator.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/rc-local-generator') 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); -- cgit v1.2.1