diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-27 15:23:35 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-27 15:23:35 +0100 |
commit | 1332ecb8ad3565aec22c0c863f0c1576aa40645e (patch) | |
tree | 301ac12b96d895a61dc9d964129162743aedcb4a /src/rc-local-generator/rc-local-generator.c | |
parent | Merge pull request #10944 from poettering/redirect-file-fix (diff) | |
download | systemd-1332ecb8ad3565aec22c0c863f0c1576aa40645e.tar.xz systemd-1332ecb8ad3565aec22c0c863f0c1576aa40645e.zip |
rc-local-generator: use macro to define main()
Diffstat (limited to 'src/rc-local-generator/rc-local-generator.c')
-rw-r--r-- | src/rc-local-generator/rc-local-generator.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index a8dc68bccc..b7cb04fc6f 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -6,6 +6,7 @@ #include "generator.h" #include "log.h" +#include "main-func.h" #include "mkdir.h" #include "string-util.h" #include "util.h" @@ -41,32 +42,30 @@ static int add_symlink(const char *service, const char *where) { return 1; } -int main(int argc, char *argv[]) { - int ret = EXIT_SUCCESS; +static int run(int argc, char *argv[]) { + int r = 0, k = 0; - if (argc > 1 && argc != 4) { - log_error("This program takes three or no arguments."); - return EXIT_FAILURE; - } + 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]; - log_setup_generator(); - if (access(RC_LOCAL_SCRIPT_PATH_START, X_OK) >= 0) { log_debug("Automatically adding rc-local.service."); - if (add_symlink("rc-local.service", "multi-user.target") < 0) - ret = EXIT_FAILURE; + r = add_symlink("rc-local.service", "multi-user.target"); } if (access(RC_LOCAL_SCRIPT_PATH_STOP, X_OK) >= 0) { log_debug("Automatically adding halt-local.service."); - if (add_symlink("halt-local.service", "final.target") < 0) - ret = EXIT_FAILURE; + k = add_symlink("halt-local.service", "final.target"); } - return ret; + return r < 0 ? r : k; } + +DEFINE_MAIN_FUNCTION(run); |