chiark / gitweb /
fixes udev build with -fpie
[elogind.git] / udev_utils_run.c
index 20aaa4ab05e386951a8d445d592553c5786f725e..c6af90658de14794bfb91acdee74a010422e8ca0 100644 (file)
 #include <sys/un.h>
 #include <sys/wait.h>
 #include <sys/select.h>
+#include <unistd.h>
 
-#include "udev_libc_wrapper.h"
 #include "udev.h"
-#include "logging.h"
-#include "udev_utils.h"
-#include "list.h"
 
+extern char **environ;
 
 int pass_env_to_socket(const char *sockname, const char *devpath, const char *action)
 {
@@ -82,6 +80,7 @@ int run_program(const char *command, const char *subsystem,
        int errpipe[2] = {-1, -1};
        pid_t pid;
        char arg[PATH_SIZE];
+       char program[PATH_SIZE];
        char *argv[(sizeof(arg) / 2) + 1];
        int devnull;
        int i;
@@ -126,6 +125,13 @@ int run_program(const char *command, const char *subsystem,
                }
        }
 
+       /* allow programs in /lib/udev called without the path */
+       if (strchr(argv[0], '/') == NULL) {
+               strlcpy(program, "/lib/udev/", sizeof(program));
+               strlcat(program, argv[0], sizeof(program));
+               argv[0] = program;
+       }
+
        pid = fork();
        switch(pid) {
        case 0: