]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
util: use only /dev directory in open_dev()
authorKinga Stefaniuk <kinga.stefaniuk@intel.com>
Wed, 9 Oct 2024 06:48:20 +0000 (08:48 +0200)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Wed, 16 Oct 2024 10:47:24 +0000 (12:47 +0200)
Previously, open_dev() tried to open device in two ways - using /dev and
/tmp directory. This method could be used by users which have no access
to /tmp directory (e.g. udev) and dev_open() fails which may affect many
processes. Remove try to open in /tmp directory.

Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
util.c

diff --git a/util.c b/util.c
index 7c5c5c8f86f7e2754dc046918dacb0a2b693ccb7..f05392a2ddd243141956bd9329af99c7de5ac1db 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1111,17 +1111,6 @@ int dev_open(char *dev, int flags)
                        fd = open(devname, flags);
                        unlink(devname);
                }
-               if (fd < 0) {
-                       /* Try /tmp as /dev appear to be read-only */
-                       snprintf(devname, sizeof(devname),
-                                "/tmp/.tmp.md.%d:%d:%d",
-                                (int)getpid(), major, minor);
-                       if (mknod(devname, S_IFBLK|0600,
-                                 makedev(major, minor)) == 0) {
-                               fd = open(devname, flags);
-                               unlink(devname);
-                       }
-               }
        } else
                fd = open(dev, flags);
        return fd;