2 * A Simple Sandbox for MO-Eval
4 * (c) 2001--2008 Martin Mares <mj@ucw.cz>
7 #define _LARGEFILE64_SOURCE
22 #include <sys/ptrace.h>
23 #include <sys/signal.h>
24 #include <sys/sysinfo.h>
25 #include <sys/syscall.h>
26 #include <sys/resource.h>
28 #define NONRET __attribute__((noreturn))
29 #define UNUSED __attribute__((unused))
30 #define ARRAY_SIZE(a) (int)(sizeof(a)/sizeof(a[0]))
32 static int filter_syscalls; /* 0=off, 1=liberal, 2=totalitarian */
33 static int timeout; /* milliseconds */
34 static int wall_timeout;
35 static int pass_environ;
36 static int file_access;
38 static int memory_limit;
39 static char *redir_stdin, *redir_stdout, *redir_stderr;
43 static int is_ptraced;
44 static volatile int timer_tick;
45 static struct timeval start_time;
46 static int ticks_per_sec;
48 static int partial_line;
50 static int mem_peak_kb;
51 static int total_ms, wall_ms;
53 static void die(char *msg, ...) NONRET;
54 static void sample_mem_peak(void);
58 static FILE *metafile;
61 meta_open(const char *name)
63 if (!strcmp(name, "-"))
68 metafile = fopen(name, "w");
70 die("Failed to open metafile '%s'",name);
76 if (metafile && metafile != stdout)
80 static void __attribute__((format(printf,1,2)))
81 meta_printf(const char *fmt, ...)
88 vfprintf(metafile, fmt, args);
93 final_stats(struct rusage *rus)
95 struct timeval total, now, wall;
96 timeradd(&rus->ru_utime, &rus->ru_stime, &total);
97 total_ms = total.tv_sec*1000 + total.tv_usec/1000;
98 gettimeofday(&now, NULL);
99 timersub(&now, &start_time, &wall);
100 wall_ms = wall.tv_sec*1000 + wall.tv_usec/1000;
102 meta_printf("time:%d.%03d\n", total_ms/1000, total_ms%1000);
103 meta_printf("time-wall:%d.%03d\n", wall_ms/1000, wall_ms%1000);
104 meta_printf("mem:%llu\n", (unsigned long long) mem_peak_kb * 1024);
107 /*** Messages and exits ***/
116 ptrace(PTRACE_KILL, box_pid);
117 kill(-box_pid, SIGKILL);
118 kill(box_pid, SIGKILL);
122 int p = wait4(box_pid, &stat, 0, &rus);
124 fprintf(stderr, "UGH: Lost track of the process\n");
140 /* Report an error of the sandbox itself */
141 static void NONRET __attribute__((format(printf,1,2)))
148 vsnprintf(buf, sizeof(buf), msg, args);
149 meta_printf("status:XX\nmessage:%s\n", buf);
155 /* Report an error of the program inside the sandbox */
156 static void NONRET __attribute__((format(printf,1,2)))
162 if (msg[0] && msg[1] && msg[2] == ':' && msg[3] == ' ')
164 meta_printf("status:%c%c\n", msg[0], msg[1]);
168 vsnprintf(buf, sizeof(buf), msg, args);
169 meta_printf("message:%s\n", buf);
175 /* Write a message, but only if in verbose mode */
176 static void __attribute__((format(printf,1,2)))
183 int len = strlen(msg);
185 partial_line = (msg[len-1] != '\n');
186 vfprintf(stderr, msg, args);
195 void *p = malloc(size);
197 die("Out of memory");
201 /*** Syscall rules ***/
203 static const char * const syscall_names[] = {
204 #include "box/syscall-table.h"
206 #define NUM_SYSCALLS ARRAY_SIZE(syscall_names)
207 #define NUM_ACTIONS (NUM_SYSCALLS+64)
210 A_DEFAULT, // Use the default action
211 A_NO, // Always forbid
212 A_YES, // Always permit
213 A_FILENAME, // Permit if arg1 is a known filename
215 A_NO_RETVAL = 32, // Does not return a value
216 A_SAMPLE_MEM = 64, // Sample memory usage before the syscall
217 A_LIBERAL = 128, // Valid only in liberal mode
218 // Must fit in a unsigned char
221 static unsigned char syscall_action[NUM_ACTIONS] = {
222 #define S(x) [__NR_##x]
224 // Syscalls permitted for specific file names
225 S(open) = A_FILENAME,
226 S(creat) = A_FILENAME,
227 S(unlink) = A_FILENAME,
228 S(oldstat) = A_FILENAME,
229 S(access) = A_FILENAME,
230 S(oldlstat) = A_FILENAME,
231 S(truncate) = A_FILENAME,
232 S(stat) = A_FILENAME,
233 S(lstat) = A_FILENAME,
234 S(truncate64) = A_FILENAME,
235 S(stat64) = A_FILENAME,
236 S(lstat64) = A_FILENAME,
237 S(readlink) = A_FILENAME,
239 // Syscalls permitted always
240 S(exit) = A_YES | A_SAMPLE_MEM,
254 S(ftruncate) = A_YES,
256 S(personality) = A_YES,
260 S(getresuid) = A_YES,
268 S(ftruncate64) = A_YES,
278 S(set_thread_area) = A_YES,
279 S(get_thread_area) = A_YES,
280 S(set_tid_address) = A_YES,
281 S(exit_group) = A_YES | A_SAMPLE_MEM,
283 // Syscalls permitted only in liberal mode
284 S(time) = A_YES | A_LIBERAL,
285 S(alarm) = A_YES | A_LIBERAL,
286 S(pause) = A_YES | A_LIBERAL,
287 S(signal) = A_YES | A_LIBERAL,
288 S(fchmod) = A_YES | A_LIBERAL,
289 S(sigaction) = A_YES | A_LIBERAL,
290 S(sgetmask) = A_YES | A_LIBERAL,
291 S(ssetmask) = A_YES | A_LIBERAL,
292 S(sigsuspend) = A_YES | A_LIBERAL,
293 S(sigpending) = A_YES | A_LIBERAL,
294 S(getrlimit) = A_YES | A_LIBERAL,
295 S(getrusage) = A_YES | A_LIBERAL,
296 S(ugetrlimit) = A_YES | A_LIBERAL,
297 S(gettimeofday) = A_YES | A_LIBERAL,
298 S(select) = A_YES | A_LIBERAL,
299 S(readdir) = A_YES | A_LIBERAL,
300 S(setitimer) = A_YES | A_LIBERAL,
301 S(getitimer) = A_YES | A_LIBERAL,
302 S(sigreturn) = A_YES | A_LIBERAL | A_NO_RETVAL,
303 S(mprotect) = A_YES | A_LIBERAL,
304 S(sigprocmask) = A_YES | A_LIBERAL,
305 S(getdents) = A_YES | A_LIBERAL,
306 S(getdents64) = A_YES | A_LIBERAL,
307 S(_newselect) = A_YES | A_LIBERAL,
308 S(fdatasync) = A_YES | A_LIBERAL,
309 S(mremap) = A_YES | A_LIBERAL,
310 S(poll) = A_YES | A_LIBERAL,
311 S(getcwd) = A_YES | A_LIBERAL,
312 S(nanosleep) = A_YES | A_LIBERAL,
313 S(rt_sigreturn) = A_YES | A_LIBERAL | A_NO_RETVAL,
314 S(rt_sigaction) = A_YES | A_LIBERAL,
315 S(rt_sigprocmask) = A_YES | A_LIBERAL,
316 S(rt_sigpending) = A_YES | A_LIBERAL,
317 S(rt_sigtimedwait) = A_YES | A_LIBERAL,
318 S(rt_sigqueueinfo) = A_YES | A_LIBERAL,
319 S(rt_sigsuspend) = A_YES | A_LIBERAL,
320 S(_sysctl) = A_YES | A_LIBERAL,
325 syscall_name(unsigned int id, char *buf)
327 if (id < NUM_SYSCALLS && syscall_names[id])
328 return syscall_names[id];
331 sprintf(buf, "#%d", id);
337 syscall_by_name(char *name)
339 for (unsigned int i=0; i<NUM_SYSCALLS; i++)
340 if (syscall_names[i] && !strcmp(syscall_names[i], name))
347 unsigned long l = strtoul(name, &ep, 0);
350 if (l >= NUM_ACTIONS)
356 set_syscall_action(char *a)
358 char *sep = strchr(a, '=');
359 enum action act = A_YES;
363 if (!strcmp(sep, "yes"))
365 else if (!strcmp(sep, "no"))
367 else if (!strcmp(sep, "file"))
373 int sys = syscall_by_name(a);
375 die("Unknown syscall `%s'", a);
376 if (sys >= NUM_ACTIONS)
377 die("Syscall `%s' out of range", a);
378 syscall_action[sys] = act;
387 struct path_rule *next;
390 static struct path_rule default_path_rules[] = {
393 { "/usr/lib/", A_YES },
394 { "/opt/lib/", A_YES },
395 { "/usr/share/zoneinfo/", A_YES },
396 { "/usr/share/locale/", A_YES },
397 { "/dev/null", A_YES },
398 { "/dev/zero", A_YES },
399 { "/proc/meminfo", A_YES },
400 { "/proc/self/stat", A_YES },
401 { "/proc/self/exe", A_YES }, // Needed by FPC 2.0.x runtime
404 static struct path_rule *user_path_rules;
405 static struct path_rule **last_path_rule = &user_path_rules;
408 set_path_action(char *a)
410 char *sep = strchr(a, '=');
411 enum action act = A_YES;
415 if (!strcmp(sep, "yes"))
417 else if (!strcmp(sep, "no"))
423 struct path_rule *r = xmalloc(sizeof(*r) + strlen(a) + 1);
424 r->path = (char *)(r+1);
429 last_path_rule = &r->next;
434 match_path_rule(struct path_rule *r, char *path)
438 if (*rr++ != *path++)
440 if (rr[-1] == '/' && !path[-1])
444 if (rr > r->path && rr[-1] != '/' && *path)
449 /*** Environment rules ***/
452 char *var; // Variable to match
453 char *val; // ""=clear, NULL=inherit
455 struct env_rule *next;
458 static struct env_rule *first_env_rule;
459 static struct env_rule **last_env_rule = &first_env_rule;
461 static struct env_rule default_env_rules[] = {
462 { "LIBC_FATAL_STDERR_", "1" }
466 set_env_action(char *a0)
468 struct env_rule *r = xmalloc(sizeof(*r) + strlen(a0) + 1);
469 char *a = (char *)(r+1);
472 char *sep = strchr(a, '=');
484 last_env_rule = &r->next;
490 match_env_var(char *env_entry, struct env_rule *r)
492 if (strncmp(env_entry, r->var, r->var_len))
494 return (env_entry[r->var_len] == '=');
498 apply_env_rule(char **env, int *env_sizep, struct env_rule *r)
500 // First remove the variable if already set
502 while (pos < *env_sizep && !match_env_var(env[pos], r))
504 if (pos < *env_sizep)
507 env[pos] = env[*env_sizep];
508 env[*env_sizep] = NULL;
511 // What is the new value?
517 new = xmalloc(r->var_len + 1 + strlen(r->val) + 1);
518 sprintf(new, "%s=%s", r->var, r->val);
523 while (environ[pos] && !match_env_var(environ[pos], r))
525 if (!(new = environ[pos]))
529 // Add it at the end of the array
530 env[(*env_sizep)++] = new;
531 env[*env_sizep] = NULL;
535 setup_environment(void)
537 // Link built-in rules with user rules
538 for (int i=ARRAY_SIZE(default_env_rules)-1; i >= 0; i--)
540 default_env_rules[i].next = first_env_rule;
541 first_env_rule = &default_env_rules[i];
544 // Scan the original environment
545 char **orig_env = environ;
547 while (orig_env[orig_size])
550 // For each rule, reserve one more slot and calculate length
552 for (struct env_rule *r = first_env_rule; r; r=r->next)
555 r->var_len = strlen(r->var);
558 // Create a new environment
559 char **env = xmalloc((orig_size + num_rules + 1) * sizeof(char *));
563 memcpy(env, environ, orig_size * sizeof(char *));
570 // Apply the rules one by one
571 for (struct env_rule *r = first_env_rule; r; r=r->next)
572 apply_env_rule(env, &size, r);
574 // Return the new env and pass some gossip
577 fprintf(stderr, "Passing environment:\n");
578 for (int i=0; env[i]; i++)
579 fprintf(stderr, "\t%s\n", env[i]);
584 /*** Syscall checks ***/
587 valid_filename(unsigned long addr)
589 char namebuf[4096], *p, *end;
593 err("FA: File access forbidden");
594 if (file_access >= 9)
599 sprintf(namebuf, "/proc/%d/mem", (int) box_pid);
600 mem_fd = open(namebuf, O_RDONLY);
602 die("open(%s): %m", namebuf);
609 int remains = PAGE_SIZE - (addr & (PAGE_SIZE-1));
610 int l = namebuf + sizeof(namebuf) - end;
614 err("FA: Access to file with name too long");
615 if (lseek64(mem_fd, addr, SEEK_SET) < 0)
616 die("lseek64(mem): %m");
617 remains = read(mem_fd, end, l);
619 die("read(mem): %m");
621 err("FA: Access to file with name out of memory");
628 msg("[%s] ", namebuf);
629 if (file_access >= 3)
632 // Everything in current directory is permitted
633 if (!strchr(namebuf, '/') && strcmp(namebuf, ".."))
636 // ".." anywhere in the path is forbidden
637 enum action act = A_DEFAULT;
638 if (strstr(namebuf, ".."))
642 for (struct path_rule *r = user_path_rules; r && !act; r=r->next)
643 act = match_path_rule(r, namebuf);
645 // Scan built-in rules
646 if (file_access >= 2)
647 for (int i=0; i<ARRAY_SIZE(default_path_rules) && !act; i++)
648 act = match_path_rule(&default_path_rules[i], namebuf);
651 err("FA: Forbidden access to file `%s'", namebuf);
654 // Check syscall. If invalid, return -1, otherwise return the action mask.
656 valid_syscall(struct user *u)
658 unsigned int sys = u->regs.orig_eax;
659 unsigned int act = (sys < NUM_ACTIONS) ? syscall_action[sys] : A_DEFAULT;
663 if (filter_syscalls != 1)
667 switch (act & A_ACTION_MASK)
674 valid_filename(u->regs.ebx);
682 if (u->regs.ebx == box_pid)
684 meta_printf("exitsig:%d\n", (int)u->regs.ecx);
685 err("SG: Committed suicide by signal %d", (int)u->regs.ecx);
689 if (u->regs.ebx == box_pid && u->regs.ecx == box_pid)
691 meta_printf("exitsig:%d\n", (int)u->regs.edx);
692 err("SG: Committed suicide by signal %d", (int)u->regs.edx);
701 signal_alarm(int unused UNUSED)
703 /* Time limit checks are synchronous, so we only schedule them there. */
709 signal_int(int unused UNUSED)
711 /* Interrupts are fatal, so no synchronization requirements. */
712 meta_printf("exitsig:%d\n", SIGINT);
713 err("SG: Interrupted");
716 #define PROC_BUF_SIZE 4096
718 read_proc_file(char *buf, char *name, int *fdp)
724 sprintf(buf, "/proc/%d/%s", (int) box_pid, name);
725 *fdp = open(buf, O_RDONLY);
727 die("open(%s): %m", buf);
729 lseek(*fdp, 0, SEEK_SET);
730 if ((c = read(*fdp, buf, PROC_BUF_SIZE-1)) < 0)
731 die("read on /proc/$pid/%s: %m", name);
732 if (c >= PROC_BUF_SIZE-1)
733 die("/proc/$pid/%s too long", name);
742 struct timeval now, wall;
744 gettimeofday(&now, NULL);
745 timersub(&now, &start_time, &wall);
746 wall_ms = wall.tv_sec*1000 + wall.tv_usec/1000;
747 if (wall_ms > wall_timeout)
748 err("TO: Time limit exceeded (wall clock)");
750 fprintf(stderr, "[wall time check: %d msec]\n", wall_ms);
754 char buf[PROC_BUF_SIZE], *x;
755 int utime, stime, ms;
756 static int proc_stat_fd;
757 read_proc_file(buf, "stat", &proc_stat_fd);
759 while (*x && *x != ' ')
764 die("proc stat syntax error 1");
765 while (*x && (*x != ')' || x[1] != ' '))
767 while (*x == ')' || *x == ' ')
769 if (sscanf(x, "%*c %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %d %d", &utime, &stime) != 2)
770 die("proc stat syntax error 2");
771 ms = (utime + stime) * 1000 / ticks_per_sec;
773 fprintf(stderr, "[time check: %d msec]\n", ms);
775 err("TO: Time limit exceeded");
780 sample_mem_peak(void)
783 * We want to find out the peak memory usage of the process, which is
784 * maintained by the kernel, but unforunately it gets lost when the
785 * process exits (it is not reported in struct rusage). Therefore we
786 * have to sample it whenever we suspect that the process is about
789 char buf[PROC_BUF_SIZE], *x;
790 static int proc_status_fd;
791 read_proc_file(buf, "status", &proc_status_fd);
797 while (*x && *x != ':' && *x != '\n')
799 if (!*x || *x == '\n')
802 while (*x == ' ' || *x == '\t')
806 while (*x && *x != '\n')
812 if (!strcmp(key, "VmPeak"))
814 int peak = atoi(val);
815 if (peak > mem_peak_kb)
821 msg("[mem-peak: %u KB]\n", mem_peak_kb);
827 int syscall_count = 0;
831 bzero(&sa, sizeof(sa));
832 sa.sa_handler = signal_int;
833 sigaction(SIGINT, &sa, NULL);
834 gettimeofday(&start_time, NULL);
835 ticks_per_sec = sysconf(_SC_CLK_TCK);
836 if (ticks_per_sec <= 0)
837 die("Invalid ticks_per_sec!");
838 if (timeout || wall_timeout)
840 sa.sa_handler = signal_alarm;
841 sigaction(SIGALRM, &sa, NULL);
854 p = wait4(box_pid, &stat, WUNTRACED, &rus);
862 die("wait4: unknown pid %d exited!", p);
867 if (WEXITSTATUS(stat))
871 meta_printf("exitcode:%d\n", WEXITSTATUS(stat));
872 err("RE: Exited with error status %d", WEXITSTATUS(stat));
876 // Internal error happened inside the child process and it has been already reported.
880 if (timeout && total_ms > timeout)
881 err("TO: Time limit exceeded");
882 if (wall_timeout && wall_ms > wall_timeout)
883 err("TO: Time limit exceeded (wall clock)");
885 fprintf(stderr, "OK (%d.%03d sec real, %d.%03d sec wall, %d MB, %d syscalls)\n",
886 total_ms/1000, total_ms%1000,
887 wall_ms/1000, wall_ms%1000,
888 (mem_peak_kb + 1023) / 1024,
892 if (WIFSIGNALED(stat))
895 meta_printf("exitsig:%d\n", WTERMSIG(stat));
897 err("SG: Caught fatal signal %d%s", WTERMSIG(stat), (syscall_count ? "" : " during startup"));
899 if (WIFSTOPPED(stat))
901 int sig = WSTOPSIG(stat);
905 msg("[ptrace status %08x] ", stat);
906 static int stop_count;
907 if (!stop_count++) /* Traceme request */
908 msg(">> Traceme request caught\n");
910 err("SG: Breakpoint");
911 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
913 else if (sig == (SIGTRAP | 0x80))
916 msg("[ptrace status %08x] ", stat);
918 static unsigned int sys_tick, last_sys, last_act;
919 if (ptrace(PTRACE_GETREGS, box_pid, NULL, &u) < 0)
920 die("ptrace(PTRACE_GETREGS): %m");
921 unsigned int sys = u.regs.orig_eax;
922 if (++sys_tick & 1) /* Syscall entry */
926 msg(">> Syscall %-12s (%08lx,%08lx,%08lx) ", syscall_name(sys, namebuf), u.regs.ebx, u.regs.ecx, u.regs.edx);
930 if (sys == __NR_execve)
933 else if ((act = valid_syscall(&u)) >= 0)
937 if (act & A_SAMPLE_MEM)
943 * Unfortunately, PTRACE_KILL kills _after_ the syscall completes,
944 * so we have to change it to something harmless (e.g., an undefined
945 * syscall) and make the program continue.
947 u.regs.orig_eax = 0xffffffff;
948 if (ptrace(PTRACE_SETREGS, box_pid, NULL, &u) < 0)
949 die("ptrace(PTRACE_SETREGS): %m");
950 err("FO: Forbidden syscall %s", syscall_name(sys, namebuf));
954 else /* Syscall return */
956 if (sys == 0xffffffff)
958 /* Some syscalls (sigreturn et al.) do not return a value */
959 if (!(last_act & A_NO_RETVAL))
960 err("XX: Syscall does not return, but it should");
965 err("XX: Mismatched syscall entry/exit");
967 if (last_act & A_NO_RETVAL)
970 msg("= %ld\n", u.regs.eax);
972 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
974 else if (sig == SIGSTOP)
977 if (ptrace(PTRACE_SETOPTIONS, box_pid, NULL, (void *) PTRACE_O_TRACESYSGOOD) < 0)
978 die("ptrace(PTRACE_SETOPTIONS): %m");
979 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
981 else if (sig != SIGXCPU && sig != SIGXFSZ)
983 msg(">> Signal %d\n", sig);
984 sample_mem_peak(); /* Signal might be fatal, so update mem-peak */
985 ptrace(PTRACE_SYSCALL, box_pid, 0, sig);
989 meta_printf("exitsig:%d", sig);
990 err("SG: Received signal %d", sig);
994 die("wait4: unknown status %x, giving up!", stat);
999 box_inside(int argc, char **argv)
1004 memcpy(args, argv, argc * sizeof(char *));
1006 if (set_cwd && chdir(set_cwd))
1011 if (open(redir_stdin, O_RDONLY) != 0)
1012 die("open(\"%s\"): %m", redir_stdin);
1017 if (open(redir_stdout, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1)
1018 die("open(\"%s\"): %m", redir_stdout);
1023 if (open(redir_stderr, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 2)
1024 die("open(\"%s\"): %m", redir_stderr);
1031 rl.rlim_cur = rl.rlim_max = memory_limit * 1024;
1032 if (setrlimit(RLIMIT_AS, &rl) < 0)
1033 die("setrlimit: %m");
1035 rl.rlim_cur = rl.rlim_max = 64;
1036 if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
1037 die("setrlimit: %m");
1038 char **env = setup_environment();
1039 if (filter_syscalls)
1041 if (ptrace(PTRACE_TRACEME) < 0)
1042 die("ptrace(PTRACE_TRACEME): %m");
1043 /* Trick: Make sure that we are stopped until the boxkeeper wakes up. */
1046 execve(args[0], args, env);
1047 die("execve(\"%s\"): %m", args[0]);
1053 fprintf(stderr, "Invalid arguments!\n");
1055 Usage: box [<options>] -- <command> <arguments>\n\
1058 -a <level>\tSet file access level (0=none, 1=cwd, 2=/etc,/lib,..., 3=whole fs, 9=no checks; needs -f)\n\
1059 -c <dir>\tChange directory to <dir> first\n\
1060 -e\t\tInherit full environment of the parent process\n\
1061 -E <var>\tInherit the environment variable <var> from the parent process\n\
1062 -E <var>=<val>\tSet the environment variable <var> to <val>; unset it if <var> is empty\n\
1063 -f\t\tFilter system calls (-ff=very restricted)\n\
1064 -i <file>\tRedirect stdin from <file>\n\
1065 -m <size>\tLimit address space to <size> KB\n\
1066 -M <file>\tOutput process information to <file> (name:value)\n\
1067 -o <file>\tRedirect stdout to <file>\n\
1068 -p <path>\tPermit access to the specified path (or subtree if it ends with a `/')\n\
1069 -p <path>=<act>\tDefine action for the specified path (<act>=yes/no)\n\
1070 -r <file>\tRedirect stderr to <file>\n\
1071 -s <sys>\tPermit the specified syscall (be careful)\n\
1072 -s <sys>=<act>\tDefine action for the specified syscall (<act>=yes/no/file)\n\
1073 -t <time>\tSet run time limit (seconds, fractions allowed)\n\
1074 -T\t\tAllow syscalls for measuring run time\n\
1075 -v\t\tBe verbose (use multiple times for even more verbosity)\n\
1076 -w <time>\tSet wall clock time limit (seconds, fractions allowed)\n\
1082 main(int argc, char **argv)
1087 while ((c = getopt(argc, argv, "a:c:eE:fi:m:M:o:p:r:s:t:Tvw:")) >= 0)
1091 file_access = atol(optarg);
1100 if (!set_env_action(optarg))
1107 redir_stdin = optarg;
1110 memory_limit = atol(optarg);
1116 redir_stdout = optarg;
1119 if (!set_path_action(optarg))
1123 redir_stderr = optarg;
1126 if (!set_syscall_action(optarg))
1130 timeout = 1000*atof(optarg);
1133 syscall_action[__NR_times] = A_YES;
1139 wall_timeout = 1000*atof(optarg);
1148 if (setreuid(uid, uid) < 0)
1149 die("setreuid: %m");
1154 box_inside(argc-optind, argv+optind);
1157 die("Internal error: fell over edge of the world");