chiark / gitweb /
udevtrigger: fix pattern match
[elogind.git] / udevd.c
diff --git a/udevd.c b/udevd.c
index 7c917fd56e64b2ac50812275a4b8963789bfd099..a21d2ab77d6cfe050bad776f66ca96be9948d80b 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -1,10 +1,7 @@
 /*
- * udevd.c - event listener and serializer
- *
  * Copyright (C) 2004-2006 Kay Sievers <kay.sievers@vrfy.org>
  * Copyright (C) 2004 Chris Friesen <chris_friesen@sympatico.ca>
  *
- *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
  *     Free Software Foundation version 2 of the License.
@@ -16,7 +13,7 @@
  *
  *     You should have received a copy of the GNU General Public License along
  *     with this program; if not, write to the Free Software Foundation, Inc.,
- *     675 Mass Ave, Cambridge, MA 02139, USA.
+ *     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  */
 
@@ -158,9 +155,9 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
 {
        char filename[PATH_SIZE];
        char filename_failed[PATH_SIZE];
-       char target[PATH_SIZE];
        size_t start, end, i;
        struct udevd_uevent_msg *loop_msg;
+       int fd;
 
        /* add location of queue files */
        strlcpy(filename, udev_root, sizeof(filename));
@@ -192,11 +189,10 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st
        case EVENT_QUEUED:
                unlink(filename_failed);
                delete_path(filename_failed);
-
-               strlcpy(target, sysfs_path, sizeof(target));
-               strlcat(target, msg->devpath, sizeof(target));
                create_path(filename);
-               symlink(target, filename);
+               fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644);
+               if (fd > 0)
+                       close(fd);
                return;
        case EVENT_FINISHED:
        case EVENT_FAILED:
@@ -929,12 +925,6 @@ int main(int argc, char *argv[], char *envp[])
        selinux_init();
        dbg("version %s", UDEV_VERSION);
 
-       if (getuid() != 0) {
-               fprintf(stderr, "root privileges required\n");
-               err("root privileges required");
-               goto exit;
-       }
-
        /* parse commandline options */
        for (i = 1 ; i < argc; i++) {
                char *arg = argv[i];
@@ -949,6 +939,12 @@ int main(int argc, char *argv[], char *envp[])
                }
        }
 
+       if (getuid() != 0) {
+               fprintf(stderr, "root privileges required\n");
+               err("root privileges required");
+               goto exit;
+       }
+
        /* init sockets to receive events */
        if (init_udevd_socket() < 0) {
                if (errno == EADDRINUSE) {