1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 02:21:44 +03:00

tty-ask-password-agent: define main through macro

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-11-16 15:24:07 +01:00
parent 47031c9276
commit 0420d20dd2

View File

@ -836,7 +836,7 @@ static int ask_on_consoles(int argc, char *argv[]) {
return 0; return 0;
} }
int main(int argc, char *argv[]) { static int run(int argc, char *argv[]) {
int r; int r;
log_set_target(LOG_TARGET_AUTO); log_set_target(LOG_TARGET_AUTO);
@ -847,31 +847,28 @@ int main(int argc, char *argv[]) {
r = parse_argv(argc, argv); r = parse_argv(argc, argv);
if (r <= 0) if (r <= 0)
goto finish; return r;
if (arg_console && !arg_device) 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); return ask_on_consoles(argc, argv);
else {
if (arg_device) { if (arg_device) {
/* /*
* Later on, a controlling terminal will be acquired, * Later on, a controlling terminal will be acquired,
* therefore the current process has to become a session * therefore the current process has to become a session
* leader and should not have a controlling terminal already. * leader and should not have a controlling terminal already.
*/ */
(void) setsid(); (void) setsid();
(void) release_terminal(); (void) release_terminal();
}
if (IN_SET(arg_action, ACTION_WATCH, ACTION_WALL))
r = watch_passwords();
else
r = show_passwords();
} }
finish: if (IN_SET(arg_action, ACTION_WATCH, ACTION_WALL))
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; return watch_passwords();
else
return show_passwords();
} }
DEFINE_MAIN_FUNCTION(run);