#include <stdlib.h>
#include "pager.h"
+#include "selinux-util.h"
#include "spawn-ask-password-agent.h"
#include "spawn-polkit-agent.h"
#include "static-destruct.h"
static_destruct(); \
ask_password_agent_close(); \
polkit_agent_close(); \
+ mac_selinux_finish(); \
pager_close(); \
return ret; \
}
#include "device-private.h"
#include "fs-util.h"
#include "log.h"
+#include "main-func.h"
#include "missing.h"
#include "mkdir.h"
#include "selinux-util.h"
return 0;
}
-int main(int argc, char *argv[]) {
+static int run(int argc, char *argv[]) {
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
if (!IN_SET(argc, 2, 3)) {
log_error("This program needs one or two arguments, %d given", argc - 1);
- return EXIT_FAILURE;
+ return -EINVAL;
}
- if (fake_filesystems() < 0)
- return EXIT_FAILURE;
+ r = fake_filesystems();
+ if (r < 0)
+ return r;
if (argc == 2) {
if (!streq(argv[1], "check")) {
log_error("Unknown argument: %s", argv[1]);
- return EXIT_FAILURE;
+ return -EINVAL;
}
- return EXIT_SUCCESS;
+ return 0;
}
log_debug("version %s", PACKAGE_VERSION);
const char *syspath = strjoina("/sys", devpath);
r = device_new_from_synthetic_event(&dev, syspath, action);
- if (r < 0) {
- log_debug_errno(r, "Failed to open device '%s'", devpath);
- goto out;
- }
+ if (r < 0)
+ return log_debug_errno(r, "Failed to open device '%s'", devpath);
assert_se(event = udev_event_new(dev, 0, NULL));
udev_event_execute_rules(event, 3 * USEC_PER_SEC, NULL, rules);
udev_event_execute_run(event, 3 * USEC_PER_SEC);
-out:
- mac_selinux_finish();
- return EXIT_SUCCESS;
+ return 0;
}
+
+DEFINE_MAIN_FUNCTION(run);
#include "fileio.h"
#include "fileio-label.h"
#include "fs-util.h"
+#include "main-func.h"
#include "log.h"
#include "selinux-util.h"
#include "string-util.h"
#include "util.h"
-int main(int argc, char*argv[]) {
+static int run(int argc, char*argv[]) {
int r, k;
if (argc != 2) {
log_error("This program requires one argument.");
- return EXIT_FAILURE;
+ return -EINVAL;
}
log_setup_service();
if (streq(argv[1], "start")) {
r = unlink_or_warn("/run/nologin");
k = unlink_or_warn("/etc/nologin");
- if (k < 0 && r >= 0)
- r = k;
+ if (r < 0)
+ return r;
+ return k;
} else if (streq(argv[1], "stop"))
- r = create_shutdown_run_nologin_or_warn();
- else {
- log_error("Unknown verb '%s'.", argv[1]);
- r = -EINVAL;
- }
+ return create_shutdown_run_nologin_or_warn();
- mac_selinux_finish();
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ log_error("Unknown verb '%s'.", argv[1]);
+ return -EINVAL;
}
+
+DEFINE_MAIN_FUNCTION(run);