diff options
-rw-r--r-- | libudev/libudev-private.h | 4 | ||||
-rw-r--r-- | libudev/libudev-util-private.c | 7 | ||||
-rw-r--r-- | udev/test-udev.c | 2 | ||||
-rw-r--r-- | udev/udev-event.c | 4 | ||||
-rw-r--r-- | udev/udev-rules.c | 4 | ||||
-rw-r--r-- | udev/udev.h | 3 | ||||
-rw-r--r-- | udev/udevd.c | 6 |
7 files changed, 20 insertions, 10 deletions
diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h index b735298c67..e90c79cb3e 100644 --- a/libudev/libudev-private.h +++ b/libudev/libudev-private.h @@ -13,6 +13,7 @@ #define _LIBUDEV_PRIVATE_H_ #include <syslog.h> +#include <signal.h> #include "libudev.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -214,7 +215,8 @@ int util_unlink_secure(struct udev *udev, const char *filename); uid_t util_lookup_user(struct udev *udev, const char *user); gid_t util_lookup_group(struct udev *udev, const char *group); int util_run_program(struct udev *udev, const char *command, char **envp, - char *result, size_t ressize, size_t *reslen); + char *result, size_t ressize, size_t *reslen, + const sigset_t *sigmask); int util_resolve_subsys_kernel(struct udev *udev, const char *string, char *result, size_t maxsize, int read_value); diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index fe8f29b3a8..dfde5a998d 100644 --- a/libudev/libudev-util-private.c +++ b/libudev/libudev-util-private.c @@ -242,7 +242,8 @@ int util_resolve_subsys_kernel(struct udev *udev, const char *string, } int util_run_program(struct udev *udev, const char *command, char **envp, - char *result, size_t ressize, size_t *reslen) + char *result, size_t ressize, size_t *reslen, + const sigset_t *sigmask) { int status; int outpipe[2] = {-1, -1}; @@ -330,6 +331,10 @@ int util_run_program(struct udev *udev, const char *command, char **envp, dup2(errpipe[WRITE_END], STDERR_FILENO); close(errpipe[WRITE_END]); } + + if (sigmask) + sigprocmask(SIG_BLOCK, sigmask, NULL); + execve(argv[0], argv, envp); if (errno == ENOENT || errno == ENOTDIR) { /* may be on a filesystem which is not mounted right now */ diff --git a/udev/test-udev.c b/udev/test-udev.c index c6b8bf573b..0806fbf9ce 100644 --- a/udev/test-udev.c +++ b/udev/test-udev.c @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) alarm(udev_device_get_event_timeout(dev)); if (err == 0 && !event->ignore_device && udev_get_run(udev)) - udev_event_execute_run(event); + udev_event_execute_run(event, NULL); udev_event_unref(event); udev_device_unref(dev); diff --git a/udev/udev-event.c b/udev/udev-event.c index 8183793e5f..7b4e4ac5c3 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -722,7 +722,7 @@ exit: return err; } -int udev_event_execute_run(struct udev_event *event) +int udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask) { struct udev_list_entry *list_entry; int err = 0; @@ -745,7 +745,7 @@ int udev_event_execute_run(struct udev_event *event) udev_event_apply_format(event, cmd, program, sizeof(program)); envp = udev_device_get_properties_envp(event->dev); - if (util_run_program(event->udev, program, envp, NULL, 0, NULL) != 0) { + if (util_run_program(event->udev, program, envp, NULL, 0, NULL, sigmask) != 0) { if (udev_list_entry_get_flag(list_entry)) err = -1; } diff --git a/udev/udev-rules.c b/udev/udev-rules.c index a92446403f..20ec2706bd 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -749,7 +749,7 @@ static int import_program_into_properties(struct udev_device *dev, const char *p char *line; envp = udev_device_get_properties_envp(dev); - if (util_run_program(udev, program, envp, result, sizeof(result), &reslen) != 0) + if (util_run_program(udev, program, envp, result, sizeof(result), &reslen, NULL) != 0) return -1; line = result; @@ -2206,7 +2206,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event program, &rules->buf[rule->rule.filename_off], rule->rule.filename_line); - if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) { + if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL, NULL) != 0) { if (cur->key.op != OP_NOMATCH) goto nomatch; } else { diff --git a/udev/udev.h b/udev/udev.h index 391276f6e4..8f0a3014b6 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -21,6 +21,7 @@ #include <sys/types.h> #include <sys/param.h> +#include <signal.h> #include "libudev.h" #include "libudev-private.h" @@ -67,7 +68,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event struct udev_event *udev_event_new(struct udev_device *dev); void udev_event_unref(struct udev_event *event); int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules); -int udev_event_execute_run(struct udev_event *event); +int udev_event_execute_run(struct udev_event *event, const sigset_t *sigset); size_t udev_event_apply_format(struct udev_event *event, const char *src, char *dest, size_t size); int udev_event_apply_subsys_kernel(struct udev_event *event, const char *string, char *result, size_t maxsize, int read_value); diff --git a/udev/udevd.c b/udev/udevd.c index 54064cbfcf..2eb914a3f3 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -79,6 +79,7 @@ static bool stop_exec_queue; static bool reload_config; static int max_childs; static int childs; +static sigset_t orig_sigmask; static struct udev_list_node event_list; static struct udev_list_node worker_list; static bool udev_exit; @@ -292,7 +293,8 @@ static void worker_new(struct event *event) /* execute RUN= */ if (err == 0 && !udev_event->ignore_device && udev_get_run(udev_event->udev)) - failed = udev_event_execute_run(udev_event); + failed = udev_event_execute_run(udev_event, + &orig_sigmask); /* reset alarm */ alarm(0); @@ -926,7 +928,7 @@ int main(int argc, char *argv[]) /* block and listen to all signals on signalfd */ sigfillset(&mask); - sigprocmask(SIG_SETMASK, &mask, NULL); + sigprocmask(SIG_SETMASK, &mask, &orig_sigmask); pfd[FD_SIGNAL].fd = signalfd(-1, &mask, 0); if (pfd[FD_SIGNAL].fd < 0) { fprintf(stderr, "error getting signalfd\n"); |