Skip to content

Commit

Permalink
Fix sysfs mount in rootless.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Moe-hacker committed May 19, 2024
1 parent 2e4808c commit 400c9f4
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/rootless.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,7 @@ static void init_rootless_container(struct CONTAINER *container)
{
chdir(container->container_dir);
mkdir("./sys", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
// Note: sys/block will not be mounted.
mkdir("./sys/block", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mkdir("./sys/bus", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("/sys/bus", "./sys/bus", NULL, MS_BIND, NULL);
mkdir("./sys/class", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("/sys/class", "./sys/class", NULL, MS_BIND, NULL);
// Note: sys/dev will not be mounted.
mkdir("./sys/dev", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mkdir("./sys/devices", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("/sys/devices", "./sys/devices", NULL, MS_BIND, NULL);
mkdir("./sys/firmware", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("/sys/firmware", "./sys/firmware", NULL, MS_BIND, NULL);
// Note: sys/fs will not be mounted.
mkdir("./sys/fs", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mkdir("./sys/kernel", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
// TODO: This will be failed.
mount("/sys/kernel", "./sys/kernel", NULL, MS_BIND, NULL);
mkdir("./sys/module", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("/sys/module", "./sys/module", NULL, MS_BIND, NULL);
mount("/sys", "./sys", NULL, MS_BIND | MS_REC, NULL);
mkdir("./proc", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
mount("proc", "./proc", "proc", MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL);
mkdir("./dev", S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH | S_IRGRP | S_IWGRP);
Expand Down

0 comments on commit 400c9f4

Please sign in to comment.