1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

quotacheck: configure logging before use and define main through macro

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-11-16 14:57:46 +01:00
parent 44c5d0442e
commit 2ab2a55bd6

View File

@ -52,18 +52,18 @@ static void test_files(void) {
#endif
}
int main(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;
if (argc > 1) {
log_error("This program takes no arguments.");
return EXIT_FAILURE;
}
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
if (argc > 1) {
log_error("This program takes no arguments.");
return -EINVAL;
}
umask(0022);
r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
@ -74,15 +74,15 @@ int main(int argc, char *argv[]) {
if (!arg_force) {
if (arg_skip)
return EXIT_SUCCESS;
return 0;
if (access("/run/systemd/quotacheck", F_OK) < 0)
return EXIT_SUCCESS;
return 0;
}
r = safe_fork("(quotacheck)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG|FORK_WAIT, NULL);
if (r < 0)
goto finish;
return r;
if (r == 0) {
static const char * const cmdline[] = {
QUOTACHECK,
@ -96,6 +96,7 @@ int main(int argc, char *argv[]) {
_exit(EXIT_FAILURE); /* Operational error */
}
finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
return 0;
}
DEFINE_MAIN_FUNCTION(run);