2017-05-26 11:01:22 +08:00
|
|
|
syntax = "proto2";
|
2017-05-26 07:55:02 +08:00
|
|
|
|
|
|
|
package nsjail;
|
|
|
|
|
2017-05-26 10:37:50 +08:00
|
|
|
enum Mode {
|
2017-05-27 21:40:24 +08:00
|
|
|
LISTEN = 0; /* Listening on a TCP port */
|
|
|
|
ONCE = 1; /* Running the command once only */
|
|
|
|
RERUN = 2; /* Re-executing the command (forever) */
|
2017-05-27 09:59:02 +08:00
|
|
|
EXECVE = 3; /* Executing command w/o the supervisor */
|
2017-05-26 10:37:50 +08:00
|
|
|
}
|
2017-05-27 21:40:24 +08:00
|
|
|
/* Should be self explanatory */
|
|
|
|
enum LogLevel {
|
2017-05-27 22:47:12 +08:00
|
|
|
DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
|
|
|
|
INFO = 1; /* Default level */
|
|
|
|
WARNING = 2; /* Equivalent to the '-q' cmd-line option */
|
2017-05-27 09:59:02 +08:00
|
|
|
ERROR = 3;
|
|
|
|
FATAL = 4;
|
2017-05-26 20:08:09 +08:00
|
|
|
}
|
2017-05-27 09:59:02 +08:00
|
|
|
message IdMap
|
|
|
|
{
|
|
|
|
/* Empty string means "current uid/gid" */
|
|
|
|
required string inside_id = 1 [ default = "" ];
|
|
|
|
required string outside_id = 2 [ default = "" ];
|
2017-05-27 22:47:12 +08:00
|
|
|
/* See 'man user_namespaces' for the meaning of count */
|
2017-05-27 09:59:02 +08:00
|
|
|
required uint32 count = 3 [ default = 1 ];
|
|
|
|
/* Does this map use /usr/bin/new[u|g]idmap binary? */
|
|
|
|
required bool use_newidmap = 4 [ default = false ];
|
2017-05-26 23:50:28 +08:00
|
|
|
}
|
2017-05-27 09:59:02 +08:00
|
|
|
message MountPt
|
|
|
|
{
|
2017-05-27 21:01:34 +08:00
|
|
|
/* Can be skipped for filesystems like 'proc' */
|
|
|
|
optional string src = 1;
|
2017-06-12 08:08:16 +08:00
|
|
|
/* Should 'src' path be prefixed with this envvar? */
|
|
|
|
optional string prefix_src_env = 2;
|
|
|
|
/* If specified, contains buffer that will be written to the dst file */
|
|
|
|
optional bytes src_content = 3;
|
|
|
|
/* Mount point inside jail */
|
2017-05-28 22:56:16 +08:00
|
|
|
required string dst = 4;
|
2017-06-12 08:08:16 +08:00
|
|
|
/* Should 'dst' path be prefixed with this envvar? */
|
|
|
|
optional string prefix_dst_env = 5;
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Can be empty for mount --bind mounts */
|
2017-05-28 22:56:16 +08:00
|
|
|
optional string fstype = 6 [ default = "" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* E.g. size=5000000 for 'tmpfs' */
|
2017-05-28 22:56:16 +08:00
|
|
|
required string options = 7 [ default = "" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Is it 'mount --bind src dst' type of mount */
|
2017-05-28 22:56:16 +08:00
|
|
|
required bool is_bind = 8 [ default = false ];
|
2017-05-28 07:24:55 +08:00
|
|
|
/* It it R/W mount */
|
2017-05-28 22:56:16 +08:00
|
|
|
required bool rw = 9 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Is it directory? If not specified an internal
|
2017-05-27 21:40:24 +08:00
|
|
|
heuristics will be used to determine that */
|
2017-05-28 22:56:16 +08:00
|
|
|
optional bool is_dir = 10;
|
2017-05-27 21:40:24 +08:00
|
|
|
/* Should the sandboxing fail if we cannot mount this resource? */
|
2017-05-28 22:56:16 +08:00
|
|
|
required bool mandatory = 11 [ default = true ];
|
2017-05-27 07:16:12 +08:00
|
|
|
}
|
2017-05-27 09:59:02 +08:00
|
|
|
message Exe
|
|
|
|
{
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Will be used both as execv's path and as argv[0] */
|
2017-05-27 09:59:02 +08:00
|
|
|
required string path = 1;
|
|
|
|
/* This will be argv[1] and so on.. */
|
|
|
|
repeated string arg = 2;
|
2017-06-12 08:14:18 +08:00
|
|
|
/* Override argv[0] */
|
|
|
|
optional string arg0 = 3;
|
2017-05-27 08:24:41 +08:00
|
|
|
}
|
2017-05-27 09:59:02 +08:00
|
|
|
message NsJailConfig
|
|
|
|
{
|
2017-06-12 08:08:16 +08:00
|
|
|
/* Optional name and description for this config */
|
|
|
|
optional string name = 1 [ default = "" ];
|
|
|
|
optional string description = 2 [ default = "" ];
|
2017-05-28 01:05:42 +08:00
|
|
|
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Execution mode: see 'msg Mode' description for more */
|
2017-05-28 01:05:42 +08:00
|
|
|
required Mode mode = 3 [ default = ONCE ];
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Equivalent to a bind mount with dst='/' */
|
2017-05-28 01:05:42 +08:00
|
|
|
optional string chroot_dir = 4;
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Applies both to the chroot_dir and to /proc mounts */
|
2017-05-28 01:05:42 +08:00
|
|
|
required bool is_root_rw = 5 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Hostname inside jail */
|
2017-05-28 01:05:42 +08:00
|
|
|
required string hostname = 8 [ default = "NSJAIL" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Initial current working directory for the binary */
|
2017-05-28 01:05:42 +08:00
|
|
|
required string cwd = 9 [ default = "/" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* TCP port to listen to. Valid with mode=LISTEN only */
|
2017-05-28 01:05:42 +08:00
|
|
|
required uint32 port = 10 [ default = 0 ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Host to bind to for mode=LISTEN. Must be in IPv6 format */
|
2017-05-28 01:05:42 +08:00
|
|
|
required string bindhost = 11 [ default = "::" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* For mode=LISTEN, maximum number of connections from a single IP */
|
2017-05-28 01:05:42 +08:00
|
|
|
required uint32 max_conns_per_ip = 12 [ default = 0 ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* Wall-time time limit for commands */
|
2017-05-28 01:05:42 +08:00
|
|
|
required uint32 time_limit = 13 [ default = 600 ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Should nsjail go into background? */
|
2017-05-28 01:05:42 +08:00
|
|
|
required bool daemon = 14 [ default = false ];
|
2017-06-19 23:05:01 +08:00
|
|
|
/* Maximum number of CPUs to use: 0 - no limit */
|
2017-06-21 23:52:16 +08:00
|
|
|
required uint32 max_cpus = 62;
|
2017-05-27 10:06:28 +08:00
|
|
|
|
2017-06-12 06:06:13 +08:00
|
|
|
/* FD to log to. */
|
2017-06-12 06:27:27 +08:00
|
|
|
optional int32 log_fd = 61;
|
2017-05-27 09:59:02 +08:00
|
|
|
/* File to save lofs to */
|
2017-05-28 01:05:42 +08:00
|
|
|
optional string log_file = 15;
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Minimum log level displayed.
|
2017-05-27 21:40:24 +08:00
|
|
|
See 'msg LogLevel' description for more */
|
2017-05-28 01:05:42 +08:00
|
|
|
optional LogLevel log_level = 16;
|
2017-05-27 10:06:28 +08:00
|
|
|
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Should the current environment variables be kept
|
2017-05-27 21:40:24 +08:00
|
|
|
when executing the binary */
|
2017-05-28 01:05:42 +08:00
|
|
|
required bool keep_env = 17 [ default = false ];
|
2017-05-27 10:06:28 +08:00
|
|
|
/* EnvVars to be set before executing binaries */
|
2017-05-28 01:05:42 +08:00
|
|
|
repeated string envar = 18;
|
2017-05-27 10:06:28 +08:00
|
|
|
|
2017-05-29 01:17:48 +08:00
|
|
|
/* Should capabilities be preserved or dropped */
|
|
|
|
required bool keep_caps = 19 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Should nsjail close FD=0,1,2 before executing the process */
|
2017-05-29 01:17:48 +08:00
|
|
|
required bool silent = 20 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Should the child process have control over terminal?
|
2017-05-27 21:40:24 +08:00
|
|
|
Can be useful to allow /bin/sh to provide
|
|
|
|
job control / signals */
|
2017-05-29 01:17:48 +08:00
|
|
|
required bool skip_setsid = 21 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Which FDs should be passed to the newly executed process
|
2017-05-27 21:40:24 +08:00
|
|
|
By default only FD=0,1,2 are passed */
|
2017-05-29 01:17:48 +08:00
|
|
|
repeated int32 pass_fd = 22;
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Setting it to true will allow to have set-uid binaries
|
2017-05-27 21:40:24 +08:00
|
|
|
inside the jail */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool disable_no_new_privs = 23 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
2017-05-29 09:11:32 +08:00
|
|
|
required uint64 rlimit_as = 24 [ default = 512 ]; /* In MiB */
|
|
|
|
required uint64 rlimit_core = 25 [ default = 0 ]; /* In MiB */
|
|
|
|
required uint64 rlimit_cpu = 26 [ default = 600 ]; /* In seconds */
|
|
|
|
required uint64 rlimit_fsize = 27 [ default = 1 ]; /* In MiB */
|
|
|
|
required uint64 rlimit_nofile = 28 [ default = 32 ];
|
|
|
|
optional uint64 rlimit_nproc = 29; /* This is system-wide: tricky to use */
|
|
|
|
optional uint64 rlimit_stack = 30; /* In MiB */
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* See 'man personality' for more */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool persona_addr_compat_layout = 31 [ default = false ];
|
|
|
|
required bool persona_mmap_page_zero = 32 [ default = false ];
|
|
|
|
required bool persona_read_implies_exec = 33 [ default = false ];
|
|
|
|
required bool persona_addr_limit_3gb = 34 [ default = false ];
|
|
|
|
required bool persona_addr_no_randomize = 35 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* Which name-spaces should be used? */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool clone_newnet = 36 [ default = true ];
|
|
|
|
required bool clone_newuser = 37 [ default = true ];
|
|
|
|
required bool clone_newns = 38 [ default = true ];
|
|
|
|
required bool clone_newpid = 39 [ default = true ];
|
|
|
|
required bool clone_newipc = 40 [ default = true ];
|
|
|
|
required bool clone_newuts = 41 [ default = true ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* It's only supported in newer kernels, hence disabled by default */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool clone_newcgroup = 42 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* Mappings for UIDs and GIDs. See the description for 'msg IdMap'
|
2017-05-27 21:40:24 +08:00
|
|
|
for more */
|
2017-05-29 09:11:32 +08:00
|
|
|
repeated IdMap uidmap = 43;
|
|
|
|
repeated IdMap gidmap = 44;
|
2017-05-27 07:16:12 +08:00
|
|
|
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Should /proc be mounted (R/O)? This can also be added in the 'mount'
|
|
|
|
section below */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool mount_proc = 45 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Mount points inside the jail. See the description for 'msg MountPt'
|
2017-05-27 21:40:24 +08:00
|
|
|
for more */
|
2017-05-29 09:11:32 +08:00
|
|
|
repeated MountPt mount = 46;
|
2017-05-27 08:09:21 +08:00
|
|
|
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Kafel seccomp-bpf policy file or a string:
|
2017-05-27 21:40:24 +08:00
|
|
|
Homepage of the project: https://github.com/google/kafel */
|
2017-05-29 09:11:32 +08:00
|
|
|
optional string seccomp_policy_file = 47;
|
|
|
|
optional string seccomp_string = 48;
|
2017-05-27 09:59:02 +08:00
|
|
|
|
2017-05-27 22:47:12 +08:00
|
|
|
/* If > 0, maximum cumulative size of RAM used inside any jail */
|
2017-05-29 09:11:32 +08:00
|
|
|
required uint64 cgroup_mem_max = 49 [ default = 0 ]; /* In MiB */
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Mount point for cgroups-memory in your system */
|
2017-05-29 09:11:32 +08:00
|
|
|
required string cgroup_mem_mount = 50 [ default = "/sys/fs/cgroup/memory" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Writeable directory (for the nsjail user) under cgroup_mem_mount */
|
2017-05-29 09:11:32 +08:00
|
|
|
required string cgroup_mem_parent = 51 [ default = "NSJAIL" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* If > 0, maximum number of PIDs (threads/processes) inside jail */
|
2017-05-29 09:11:32 +08:00
|
|
|
required uint64 cgroup_pids_max = 52 [ default = 0 ];
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Mount point for cgroups-pids in your system */
|
2017-05-29 09:11:32 +08:00
|
|
|
required string cgroup_pids_mount = 53 [ default = "/sys/fs/cgroup/pids" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
/* Writeable directory (for the nsjail user) under cgroup_pids_mount */
|
2017-05-29 09:11:32 +08:00
|
|
|
required string cgroup_pids_parent = 54 [ default = "NSJAIL" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Should the 'lo' interface be brought up (active) inside this jail? */
|
2017-05-29 09:11:32 +08:00
|
|
|
required bool iface_no_lo = 55 [ default = false ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
|
|
|
/* Parameters for the cloned MACVLAN interface inside jail */
|
2017-05-29 09:11:32 +08:00
|
|
|
optional string macvlan_iface = 56; /* Interface to be cloned, eg 'eth0' */
|
|
|
|
required string macvlan_vs_ip = 57 [ default = "192.168.0.2" ];
|
|
|
|
required string macvlan_vs_nm = 58 [ default = "255.255.255.0" ];
|
|
|
|
required string macvlan_vs_gw = 59 [ default = "192.168.0.1" ];
|
2017-05-27 09:59:02 +08:00
|
|
|
|
2017-05-27 22:47:12 +08:00
|
|
|
/* Binary path (with arguments) to be executed. If not specified here, it
|
|
|
|
can be specified with cmd-line as "-- /path/to/command arg1 arg2" */
|
2017-05-29 09:11:32 +08:00
|
|
|
optional Exe exec_bin = 60;
|
2017-05-26 07:55:02 +08:00
|
|
|
}
|