| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
|
| 5 |
#include "sd-daemon.h" |
| 6 |
|
| 7 |
#include "argv-util.h" |
| 8 |
#include "ask-password-agent.h" |
| 9 |
#include "main-func.h" |
| 10 |
#include "pager.h" |
| 11 |
#include "polkit-agent.h" |
| 12 |
#include "selinux-util.h" |
| 13 |
#include "string-util.h" |
| 14 |
|
| 15 |
void main_prepare(int argc, char *argv[]) { |
| 16 |
assert_se(argc > 0 && !isempty(argv[0])); |
| 17 |
save_argc_argv(argc, argv); |
| 18 |
} |
| 19 |
|
| 20 |
void main_finalize(int r, int exit_status) { |
| 21 |
if (r < 0) |
| 22 |
(void) sd_notifyf(0, "ERRNO=%i", -r); |
| 23 |
(void) sd_notifyf(0, "EXIT_STATUS=%i", exit_status); |
| 24 |
ask_password_agent_close(); |
| 25 |
polkit_agent_close(); |
| 26 |
pager_close(); |
| 27 |
mac_selinux_finish(); |
| 28 |
} |
| 29 |
|
| 30 |
int exit_failure_if_negative(int result) { |
| 31 |
return result < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |
| 32 |
} |
| 33 |
|
| 34 |
int exit_failure_if_nonzero(int result) { |
| 35 |
return result < 0 ? EXIT_FAILURE : result; |
| 36 |
} |