mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
Call mac_selinux_close() from main func macros, convert user-sessions and test-udev
This commit is contained in:
parent
d1405af399
commit
8d38b8ad56
@ -4,6 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "pager.h"
|
#include "pager.h"
|
||||||
|
#include "selinux-util.h"
|
||||||
#include "spawn-ask-password-agent.h"
|
#include "spawn-ask-password-agent.h"
|
||||||
#include "spawn-polkit-agent.h"
|
#include "spawn-polkit-agent.h"
|
||||||
#include "static-destruct.h"
|
#include "static-destruct.h"
|
||||||
@ -15,6 +16,7 @@
|
|||||||
static_destruct(); \
|
static_destruct(); \
|
||||||
ask_password_agent_close(); \
|
ask_password_agent_close(); \
|
||||||
polkit_agent_close(); \
|
polkit_agent_close(); \
|
||||||
|
mac_selinux_finish(); \
|
||||||
pager_close(); \
|
pager_close(); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "device-private.h"
|
#include "device-private.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "main-func.h"
|
||||||
#include "missing.h"
|
#include "missing.h"
|
||||||
#include "mkdir.h"
|
#include "mkdir.h"
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
@ -53,7 +54,7 @@ static int fake_filesystems(void) {
|
|||||||
return 0;
|
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_rules_unrefp) struct udev_rules *rules = NULL;
|
||||||
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
|
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
|
||||||
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
||||||
@ -64,19 +65,20 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (!IN_SET(argc, 2, 3)) {
|
if (!IN_SET(argc, 2, 3)) {
|
||||||
log_error("This program needs one or two arguments, %d given", argc - 1);
|
log_error("This program needs one or two arguments, %d given", argc - 1);
|
||||||
return EXIT_FAILURE;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fake_filesystems() < 0)
|
r = fake_filesystems();
|
||||||
return EXIT_FAILURE;
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
if (!streq(argv[1], "check")) {
|
if (!streq(argv[1], "check")) {
|
||||||
log_error("Unknown argument: %s", argv[1]);
|
log_error("Unknown argument: %s", argv[1]);
|
||||||
return EXIT_FAILURE;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug("version %s", PACKAGE_VERSION);
|
log_debug("version %s", PACKAGE_VERSION);
|
||||||
@ -89,10 +91,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
const char *syspath = strjoina("/sys", devpath);
|
const char *syspath = strjoina("/sys", devpath);
|
||||||
r = device_new_from_synthetic_event(&dev, syspath, action);
|
r = device_new_from_synthetic_event(&dev, syspath, action);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
log_debug_errno(r, "Failed to open device '%s'", devpath);
|
return log_debug_errno(r, "Failed to open device '%s'", devpath);
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_se(event = udev_event_new(dev, 0, NULL));
|
assert_se(event = udev_event_new(dev, 0, NULL));
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
udev_event_execute_rules(event, 3 * USEC_PER_SEC, NULL, rules);
|
udev_event_execute_rules(event, 3 * USEC_PER_SEC, NULL, rules);
|
||||||
udev_event_execute_run(event, 3 * USEC_PER_SEC);
|
udev_event_execute_run(event, 3 * USEC_PER_SEC);
|
||||||
out:
|
|
||||||
mac_selinux_finish();
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_MAIN_FUNCTION(run);
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "fileio-label.h"
|
#include "fileio-label.h"
|
||||||
#include "fs-util.h"
|
#include "fs-util.h"
|
||||||
|
#include "main-func.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "selinux-util.h"
|
#include "selinux-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
int main(int argc, char*argv[]) {
|
static int run(int argc, char*argv[]) {
|
||||||
int r, k;
|
int r, k;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
log_error("This program requires one argument.");
|
log_error("This program requires one argument.");
|
||||||
return EXIT_FAILURE;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_setup_service();
|
log_setup_service();
|
||||||
@ -28,16 +29,15 @@ int main(int argc, char*argv[]) {
|
|||||||
if (streq(argv[1], "start")) {
|
if (streq(argv[1], "start")) {
|
||||||
r = unlink_or_warn("/run/nologin");
|
r = unlink_or_warn("/run/nologin");
|
||||||
k = unlink_or_warn("/etc/nologin");
|
k = unlink_or_warn("/etc/nologin");
|
||||||
if (k < 0 && r >= 0)
|
if (r < 0)
|
||||||
r = k;
|
return r;
|
||||||
|
return k;
|
||||||
|
|
||||||
} else if (streq(argv[1], "stop"))
|
} else if (streq(argv[1], "stop"))
|
||||||
r = create_shutdown_run_nologin_or_warn();
|
return create_shutdown_run_nologin_or_warn();
|
||||||
else {
|
|
||||||
log_error("Unknown verb '%s'.", argv[1]);
|
|
||||||
r = -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
mac_selinux_finish();
|
log_error("Unknown verb '%s'.", argv[1]);
|
||||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_MAIN_FUNCTION(run);
|
||||||
|
Loading…
Reference in New Issue
Block a user