Skip to content

Commit

Permalink
fix /proc/self/fd + permisions to '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
prekucki committed Aug 20, 2024
1 parent a20fa7f commit 01f5e2f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions runtime/init-container/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2188,10 +2188,14 @@ int main(int argc, char **argv) {
MS_NOSUID | MS_NODEV,
"mode=0700,size=128M"));

CHECK(mkdir("/mnt/overlay/upper", S_IRWXU));
CHECK(mkdir("/mnt/overlay/work", S_IRWXU));

CHECK(mount("/dev/vda", "/mnt/image", "squashfs", MS_RDONLY | MS_NODEV, ""));
{
struct stat statbuf;
CHECK(stat("/mnt/image", &statbuf));
CHECK(mkdir("/mnt/overlay/upper", statbuf.st_mode));
CHECK(mkdir("/mnt/overlay/work", statbuf.st_mode));
}

if (access("/dev/vdb", R_OK) == 0) {
CHECK(mkdir("/mnt/gpu-files", S_IRWXU));
CHECK(mount("/dev/vdb", "/mnt/gpu-files", "squashfs", MS_RDONLY | MS_NODEV, ""));
Expand Down Expand Up @@ -2220,6 +2224,9 @@ int main(int argc, char **argv) {
CHECK(mount("devtmpfs", SYSROOT "/dev", "devtmpfs",
MS_NOSUID,
"mode=0755,size=2M"));

CHECK(symlinkat("/proc/self/fd", AT_FDCWD, SYSROOT "/dev/fd"));

CHECK(mount("tmpfs", SYSROOT "/tmp", "tmpfs",
MS_NOSUID,
"mode=0777"));
Expand Down

0 comments on commit 01f5e2f

Please sign in to comment.