Skip to content

Commit 4491a2b

Browse files
Merge branch 'master' of https://github.com/google/nsjail
2 parents e2355a7 + 5b75653 commit 4491a2b

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

cmdline.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static const struct custom_option custom_opts[] = {
140140
{ { "disable_proc", no_argument, nullptr, 0x0603 }, "Disable mounting procfs in the jail" },
141141
{ { "proc_path", required_argument, nullptr, 0x0605 }, "Path used to mount procfs (default: '/proc')" },
142142
{ { "proc_rw", no_argument, nullptr, 0x0606 }, "Is procfs mounted as R/W (default: R/O)" },
143-
{ { "experimental_mnt", required_argument, nullptr, 0x0609 }, "Mount API to use: 'new' (fsopen/fsmount), 'old' (mount syscall), or 'default' (auto-detect based on kernel version)" },
143+
{ { "experimental_mnt", required_argument, nullptr, 0x0609 }, "Mount API to use: 'new' (fsopen/fsmount), 'old' (mount syscall), or 'default' (auto-detect based on kernel version). Default: 'old'" },
144144
{ { "seccomp_policy", required_argument, nullptr, 'P' }, "Path to file containing seccomp-bpf policy (see kafel/)" },
145145
{ { "seccomp_string", required_argument, nullptr, 0x0901 }, "String with kafel seccomp-bpf policy (see kafel/)" },
146146
{ { "seccomp_log", no_argument, nullptr, 0x0902 }, "Use SECCOMP_FILTER_FLAG_LOG. Log all actions except SECCOMP_RET_ALLOW). Supported since kernel version 4.14" },
@@ -462,7 +462,7 @@ std::unique_ptr<nsj_t> parseArgs(int argc, char* argv[]) {
462462
nsj->orig_euid = geteuid();
463463
nsj->seccomp_fprog.filter = NULL;
464464
nsj->seccomp_fprog.len = 0;
465-
nsj->mnt_newapi = mnt::newapi::isAvailable();
465+
nsj->mnt_newapi = false; /* Make more tests before switching it to new or default */
466466

467467
nsj->openfds.push_back(STDIN_FILENO);
468468
nsj->openfds.push_back(STDOUT_FILENO);
@@ -683,7 +683,9 @@ std::unique_ptr<nsj_t> parseArgs(int argc, char* argv[]) {
683683
nsj->mnt_newapi = true;
684684
} else if (strcasecmp(optarg, "old") == 0) {
685685
nsj->mnt_newapi = false;
686-
} else if (strcasecmp(optarg, "default") != 0) {
686+
} else if (strcasecmp(optarg, "default") == 0) {
687+
nsj->mnt_newapi = mnt::newapi::isAvailable();
688+
} else {
687689
LOG_E("--experimental_mnt must be 'new', 'old', or 'default'");
688690
return nullptr;
689691
}

mnt_newapi.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "mnt_newapi.h"
2323

2424
#include <fcntl.h>
25+
// clang-format off
26+
/* https://github.com/google/nsjail/issues/250 */
27+
#include <sys/mount.h>
28+
// clang-format on
2529
#include <linux/mount.h>
2630
#include <sys/syscall.h>
2731

@@ -66,7 +70,6 @@ std::unique_ptr<std::string> buildMountTree(nsj_t*, std::vector<mnt::mount_t>*)
6670
#include <dirent.h>
6771
#include <errno.h>
6872
#include <inttypes.h>
69-
#include <sys/mount.h>
7073
#include <sys/stat.h>
7174
#include <unistd.h>
7275

subproc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
namespace subproc {
3535

3636
/* 0 - network connection limit reached, -1 - error */
37-
pid_t runChild(nsj_t* nsj, int listen_fd, int fd_in, int fd_out, int fd_err);
37+
pid_t runChild(nsj_t* nsj, int netfd, int fd_in, int fd_out, int fd_err);
3838
int countProc(nsj_t* nsj);
3939
void displayProc(nsj_t* nsj);
4040
void killAndReapAll(nsj_t* nsj, int signal);

0 commit comments

Comments
 (0)