]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
namespace: ensure to return a valid inaccessible nodes (#3778)
authorAlessandro Puccetti <alessandro@kinvolk.io>
Fri, 22 Jul 2016 13:59:14 +0000 (15:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 13:59:14 +0000 (15:59 +0200)
Because /run/systemd/inaccessible/{chr,blk} are devices with
major=0 and minor=0 it might be possible that these devices cannot be created
so we use /run/systemd/inaccessible/sock instead to map them.

src/basic/mount-util.c

index 63dff3dd5cb5262ca995b15cbed6956085d566a7..b91f0f9e0e087e35bfb5a91e052139c2351ad575 100644 (file)
@@ -534,15 +534,22 @@ int repeat_unmount(const char *path, int flags) {
 }
 
 const char* mode_to_inaccessible_node(mode_t mode) {
+        /* This function maps a node type to the correspondent inaccessible node type.
+         * Character and block inaccessible devices may not be created (because major=0 and minor=0),
+         * in such case we map character and block devices to the inaccessible node type socket. */
         switch(mode & S_IFMT) {
                 case S_IFREG:
                         return "/run/systemd/inaccessible/reg";
                 case S_IFDIR:
                         return "/run/systemd/inaccessible/dir";
                 case S_IFCHR:
-                        return "/run/systemd/inaccessible/chr";
+                        if (access("/run/systemd/inaccessible/chr", F_OK) == 0)
+                                return "/run/systemd/inaccessible/chr";
+                        return "/run/systemd/inaccessible/sock";
                 case S_IFBLK:
-                        return "/run/systemd/inaccessible/blk";
+                        if (access("/run/systemd/inaccessible/blk", F_OK) == 0)
+                                return "/run/systemd/inaccessible/blk";
+                        return "/run/systemd/inaccessible/sock";
                 case S_IFIFO:
                         return "/run/systemd/inaccessible/fifo";
                 case S_IFSOCK: