summaryrefslogtreecommitdiff
path: root/src/test/test-udev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-udev.c')
-rw-r--r--src/test/test-udev.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index b57d275efa..d1fe953071 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -19,20 +19,16 @@
***/
#include <stdio.h>
-#include <stddef.h>
#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <ctype.h>
#include <errno.h>
#include <unistd.h>
-#include <grp.h>
#include <sched.h>
#include <sys/mount.h>
#include <sys/signalfd.h>
#include "missing.h"
#include "selinux-util.h"
+#include "signal-util.h"
#include "udev.h"
#include "udev-util.h"
@@ -84,7 +80,6 @@ int main(int argc, char *argv[]) {
char syspath[UTIL_PATH_SIZE];
const char *devpath;
const char *action;
- sigset_t mask, sigmask_orig;
int err;
err = fake_filesystems();
@@ -98,8 +93,6 @@ int main(int argc, char *argv[]) {
log_debug("version %s", VERSION);
mac_selinux_init("/dev");
- sigprocmask(SIG_SETMASK, NULL, &sigmask_orig);
-
action = argv[1];
if (action == NULL) {
log_error("action missing");
@@ -115,22 +108,15 @@ int main(int argc, char *argv[]) {
rules = udev_rules_new(udev, 1);
strscpyl(syspath, sizeof(syspath), "/sys", devpath, NULL);
- dev = udev_device_new_from_syspath(udev, syspath);
+ dev = udev_device_new_from_synthetic_event(udev, syspath, action);
if (dev == NULL) {
log_debug("unknown device '%s'", devpath);
goto out;
}
- udev_device_set_action(dev, action);
event = udev_event_new(dev);
- sigfillset(&mask);
- sigprocmask(SIG_SETMASK, &mask, &sigmask_orig);
- event->fd_signal = signalfd(-1, &mask, SFD_NONBLOCK|SFD_CLOEXEC);
- if (event->fd_signal < 0) {
- fprintf(stderr, "error creating signalfd\n");
- goto out;
- }
+ assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, SIGHUP, SIGCHLD, -1) == 0);
/* do what devtmpfs usually provides us */
if (udev_device_get_devnode(dev) != NULL) {
@@ -153,14 +139,10 @@ int main(int argc, char *argv[]) {
udev_event_execute_rules(event,
3 * USEC_PER_SEC, USEC_PER_SEC,
NULL,
- rules,
- &sigmask_orig);
+ rules);
udev_event_execute_run(event,
- 3 * USEC_PER_SEC, USEC_PER_SEC,
- NULL);
+ 3 * USEC_PER_SEC, USEC_PER_SEC);
out:
- if (event != NULL && event->fd_signal >= 0)
- close(event->fd_signal);
mac_selinux_finish();
return err ? EXIT_FAILURE : EXIT_SUCCESS;