jail: always mount /dev as additional tmpfs
authorDaniel Golle <daniel@makrotopia.org>
Tue, 14 Apr 2020 14:46:03 +0000 (15:46 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 14 Apr 2020 14:47:10 +0000 (15:47 +0100)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index 87b671befb4b9a4a2b869647516b33f15a528aff..ca8b832ea219880f40f8076c8286cc103727e896 100644 (file)
@@ -187,6 +187,7 @@ static int build_jail_fs(void)
 {
        char jail_root[] = "/tmp/ujail-XXXXXX";
        char tmpovdir[] = "/tmp/ujail-overlay-XXXXXX";
+       char tmpdevdir[] = "/tmp/ujail-XXXXXX/dev";
        char *overlaydir = NULL;
 
        if (mkdtemp(jail_root) == NULL) {
@@ -240,6 +241,11 @@ static int build_jail_fs(void)
                return -1;
        }
 
+       snprintf(tmpdevdir, sizeof(tmpdevdir), "%s/dev", jail_root);
+       mkdir_p(tmpdevdir, 0755);
+       if (mount(NULL, tmpdevdir, "tmpfs", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "size=1M"))
+               return -1;
+
        if (mount_all(jail_root)) {
                ERROR("mount_all() failed\n");
                return -1;