]> err.no Git - systemd/commitdiff
udevd: create /dev/.udev/rules.d/ before watching it wit inotify
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 4 Nov 2009 16:06:52 +0000 (17:06 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 4 Nov 2009 16:06:52 +0000 (17:06 +0100)
This should also address:

On Tue, Nov 3, 2009 at 16:21, Marco d'Itri <md@linux.it> wrote:
> udev_rules_new() in udev/udev-rules.c unconditionally creates the
> directory.
> This is a problem because the function is called also by e.g. udevadm
> test, and creating /dev/.udev/ when it does not exist is an unacceptable
> side effect which will break everything else that checks for its
> existence to know if udev is running.

udev/udev-rules.c
udev/udevd.c

index 422e14ce234bfea9f8f792dfcc16bff5bdf6a30b..092ddcdc25360cf30f2d591715736748ebec3533 100644 (file)
@@ -1736,12 +1736,6 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names)
 
                /* read dynamic/temporary rules */
                util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/rules.d", NULL);
-               if (stat(filename, &statbuf) != 0) {
-                       util_create_path(udev, filename);
-                       udev_selinux_setfscreatecon(udev, filename, S_IFDIR|0755);
-                       mkdir(filename, 0755);
-                       udev_selinux_resetfscreatecon(udev);
-               }
                udev_list_init(&sort_list);
                add_matching_files(udev, &sort_list, filename, ".rules");
 
index 88e117f50a1f46807688aeafebaaa4e7295510e9..72f9b180d398d37294a8511ad6c9bd72ee045cd3 100644 (file)
@@ -919,6 +919,7 @@ int main(int argc, char *argv[])
                                  IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
        } else {
                char filename[UTIL_PATH_SIZE];
+               struct stat statbuf;
 
                inotify_add_watch(pfd[FD_INOTIFY].fd, LIBEXECDIR "/rules.d",
                                  IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
@@ -927,6 +928,12 @@ int main(int argc, char *argv[])
 
                /* watch dynamic rules directory */
                util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/rules.d", NULL);
+               if (stat(filename, &statbuf) != 0) {
+                       util_create_path(udev, filename);
+                       udev_selinux_setfscreatecon(udev, filename, S_IFDIR|0755);
+                       mkdir(filename, 0755);
+                       udev_selinux_resetfscreatecon(udev);
+               }
                inotify_add_watch(pfd[FD_INOTIFY].fd, filename,
                                  IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
        }