diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-16 15:24:07 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-17 09:13:35 +0100 |
commit | 0420d20dd259278d6df3e06140870713c248a0dd (patch) | |
tree | e735340a8853484e98c19b9b5409cbd73f0f803c /src | |
parent | sysv-generator: configure logging before use and define main through macro (diff) | |
download | systemd-0420d20dd259278d6df3e06140870713c248a0dd.tar.xz systemd-0420d20dd259278d6df3e06140870713c248a0dd.zip |
tty-ask-password-agent: define main through macro
Diffstat (limited to 'src')
-rw-r--r-- | src/tty-ask-password-agent/tty-ask-password-agent.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 1aa90b6040..1c965217d9 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -836,7 +836,7 @@ static int ask_on_consoles(int argc, char *argv[]) { return 0; } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; log_set_target(LOG_TARGET_AUTO); @@ -847,31 +847,28 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; if (arg_console && !arg_device) /* - * Spawn for each console device a separate process. + * Spawn a separate process for each console device. */ - r = ask_on_consoles(argc, argv); - else { - - if (arg_device) { - /* - * Later on, a controlling terminal will be acquired, - * therefore the current process has to become a session - * leader and should not have a controlling terminal already. - */ - (void) setsid(); - (void) release_terminal(); - } + return ask_on_consoles(argc, argv); - if (IN_SET(arg_action, ACTION_WATCH, ACTION_WALL)) - r = watch_passwords(); - else - r = show_passwords(); + if (arg_device) { + /* + * Later on, a controlling terminal will be acquired, + * therefore the current process has to become a session + * leader and should not have a controlling terminal already. + */ + (void) setsid(); + (void) release_terminal(); } -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + if (IN_SET(arg_action, ACTION_WATCH, ACTION_WALL)) + return watch_passwords(); + else + return show_passwords(); } + +DEFINE_MAIN_FUNCTION(run); |