Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Bindmount the sysfs into our root_dir" #97

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions deps/userns_sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ static void bind_mount(const char *src, const char *dest, char read_only) {
}
}

static void bind_host_node(const char *root_dir, const char *name, char read_only) {
static void bind_host_node(const char *root_dir, const char *name) {
char path[PATH_MAX];
if (access(name, F_OK) == 0) {
snprintf(path, sizeof(path), "%s/%s", root_dir, name);
bind_mount(name, path, read_only);
bind_mount(name, path, FALSE);
}
}

Expand All @@ -388,15 +388,12 @@ static void mount_dev(const char * root_dir) {

// These are all things that should exist in the host environment, but may not
// We use `bind_host_node()` to bindmount them into our sandbox if they exist.
bind_host_node(root_dir, "/dev/null", FALSE);
bind_host_node(root_dir, "/dev/tty", FALSE);
bind_host_node(root_dir, "/dev/zero", FALSE);
bind_host_node(root_dir, "/dev/random", FALSE);
bind_host_node(root_dir, "/dev/urandom", FALSE);
bind_host_node(root_dir, "/dev/shm", FALSE);

// Bindmount the sysfs, but make it read-only
bind_host_node(root_dir, "/sys", TRUE);
bind_host_node(root_dir, "/dev/null");
bind_host_node(root_dir, "/dev/tty");
bind_host_node(root_dir, "/dev/zero");
bind_host_node(root_dir, "/dev/random");
bind_host_node(root_dir, "/dev/urandom");
bind_host_node(root_dir, "/dev/shm");

// /dev/pts and /dev/ptmx are more special; we actually mount a new filesystem
// on /dev/pts, and then bind-mount /dev/pts/ptmx to /dev/ptmx within the
Expand Down