X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udevstart.c;h=d0a1ded2be069cf16d0f8931a840f272875702d2;hb=8bb39322f092fde89bf1082f51715a2f2da1c187;hp=8c414f1acb345374b0b98f7153960d7a683fc0d4;hpb=1aa1e24848903d11780db1ade355be73ad61a937;p=elogind.git diff --git a/udevstart.c b/udevstart.c index 8c414f1ac..d0a1ded2b 100644 --- a/udevstart.c +++ b/udevstart.c @@ -40,6 +40,7 @@ #include "udev.h" #include "udev_rules.h" +#include "udev_selinux.h" static const char *udev_run_str; static const char *udev_log_str; @@ -108,6 +109,7 @@ static int add_device(const char *devpath) { struct sysfs_device *dev; struct udevice *udev; + int retval = 0; /* clear and set environment for next event */ clearenv(); @@ -129,7 +131,6 @@ static int add_device(const char *devpath) /* override built-in sysfs device */ udev->dev = dev; strcpy(udev->action, "add"); - udev->devt = udev_device_get_devt(udev); if (strcmp(udev->dev->subsystem, "net") != 0) { udev->devt = udev_device_get_devt(udev); @@ -146,27 +147,30 @@ static int add_device(const char *devpath) dbg("device event will be ignored"); goto exit; } - if (udev->name[0] == '\0') { - dbg("device node creation supressed"); - goto run; - } + if (udev->name[0] != '\0') + retval = udev_device_event(&rules, udev); + else + info("device node creation supressed"); - udev_add_device(udev); -run: - if (udev_run && !list_empty(&udev->run_list)) { + if (retval == 0 && udev_run) { struct name_entry *name_loop; dbg("executing run list"); list_for_each_entry(name_loop, &udev->run_list, node) { if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0) pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, "add"); - else - run_program(name_loop->name, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO)); + else { + char program[PATH_SIZE]; + + strlcpy(program, name_loop->name, sizeof(program)); + udev_rules_apply_format(udev, program, sizeof(program)); + run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO)); + } } } + exit: udev_device_cleanup(udev); - return 0; } @@ -336,6 +340,7 @@ int main(int argc, char *argv[], char *envp[]) logging_init("udevstart"); udev_config_init(); + selinux_init(); dbg("version %s", UDEV_VERSION); udev_run_str = getenv("UDEV_RUN");