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 extra_timeout;
36 static int pass_environ;
37 static int file_access;
39 static int memory_limit;
40 static char *redir_stdin, *redir_stdout, *redir_stderr;
44 static int is_ptraced;
45 static volatile int timer_tick;
46 static struct timeval start_time;
47 static int ticks_per_sec;
49 static int partial_line;
51 static int mem_peak_kb;
52 static int total_ms, wall_ms;
54 static void die(char *msg, ...) NONRET;
55 static void sample_mem_peak(void);
59 static FILE *metafile;
62 meta_open(const char *name)
64 if (!strcmp(name, "-"))
69 metafile = fopen(name, "w");
71 die("Failed to open metafile '%s'",name);
77 if (metafile && metafile != stdout)
81 static void __attribute__((format(printf,1,2)))
82 meta_printf(const char *fmt, ...)
89 vfprintf(metafile, fmt, args);
94 final_stats(struct rusage *rus)
96 struct timeval total, now, wall;
97 timeradd(&rus->ru_utime, &rus->ru_stime, &total);
98 total_ms = total.tv_sec*1000 + total.tv_usec/1000;
99 gettimeofday(&now, NULL);
100 timersub(&now, &start_time, &wall);
101 wall_ms = wall.tv_sec*1000 + wall.tv_usec/1000;
103 meta_printf("time:%d.%03d\n", total_ms/1000, total_ms%1000);
104 meta_printf("time-wall:%d.%03d\n", wall_ms/1000, wall_ms%1000);
105 meta_printf("mem:%llu\n", (unsigned long long) mem_peak_kb * 1024);
108 /*** Messages and exits ***/
117 ptrace(PTRACE_KILL, box_pid);
118 kill(-box_pid, SIGKILL);
119 kill(box_pid, SIGKILL);
120 meta_printf("killed:1\n");
124 int p = wait4(box_pid, &stat, 0, &rus);
126 fprintf(stderr, "UGH: Lost track of the process\n");
142 /* Report an error of the sandbox itself */
143 static void NONRET __attribute__((format(printf,1,2)))
150 vsnprintf(buf, sizeof(buf), msg, args);
151 meta_printf("status:XX\nmessage:%s\n", buf);
157 /* Report an error of the program inside the sandbox */
158 static void NONRET __attribute__((format(printf,1,2)))
164 if (msg[0] && msg[1] && msg[2] == ':' && msg[3] == ' ')
166 meta_printf("status:%c%c\n", msg[0], msg[1]);
170 vsnprintf(buf, sizeof(buf), msg, args);
171 meta_printf("message:%s\n", buf);
177 /* Write a message, but only if in verbose mode */
178 static void __attribute__((format(printf,1,2)))
185 int len = strlen(msg);
187 partial_line = (msg[len-1] != '\n');
188 vfprintf(stderr, msg, args);
197 void *p = malloc(size);
199 die("Out of memory");
203 /*** Syscall rules ***/
205 static const char * const syscall_names[] = {
206 #include "box/syscall-table.h"
208 #define NUM_SYSCALLS ARRAY_SIZE(syscall_names)
209 #define NUM_ACTIONS (NUM_SYSCALLS+64)
212 A_DEFAULT, // Use the default action
213 A_NO, // Always forbid
214 A_YES, // Always permit
215 A_FILENAME, // Permit if arg1 is a known filename
217 A_NO_RETVAL = 32, // Does not return a value
218 A_SAMPLE_MEM = 64, // Sample memory usage before the syscall
219 A_LIBERAL = 128, // Valid only in liberal mode
220 // Must fit in a unsigned char
223 static unsigned char syscall_action[NUM_ACTIONS] = {
224 #define S(x) [__NR_##x]
226 // Syscalls permitted for specific file names
227 S(open) = A_FILENAME,
228 S(creat) = A_FILENAME,
229 S(unlink) = A_FILENAME,
230 S(oldstat) = A_FILENAME,
231 S(access) = A_FILENAME,
232 S(oldlstat) = A_FILENAME,
233 S(truncate) = A_FILENAME,
234 S(stat) = A_FILENAME,
235 S(lstat) = A_FILENAME,
236 S(truncate64) = A_FILENAME,
237 S(stat64) = A_FILENAME,
238 S(lstat64) = A_FILENAME,
239 S(readlink) = A_FILENAME,
241 // Syscalls permitted always
242 S(exit) = A_YES | A_SAMPLE_MEM,
256 S(ftruncate) = A_YES,
258 S(personality) = A_YES,
262 S(getresuid) = A_YES,
270 S(ftruncate64) = A_YES,
280 S(set_thread_area) = A_YES,
281 S(get_thread_area) = A_YES,
282 S(set_tid_address) = A_YES,
283 S(exit_group) = A_YES | A_SAMPLE_MEM,
285 // Syscalls permitted only in liberal mode
286 S(time) = A_YES | A_LIBERAL,
287 S(alarm) = A_YES | A_LIBERAL,
288 S(pause) = A_YES | A_LIBERAL,
289 S(signal) = A_YES | A_LIBERAL,
290 S(fchmod) = A_YES | A_LIBERAL,
291 S(sigaction) = A_YES | A_LIBERAL,
292 S(sgetmask) = A_YES | A_LIBERAL,
293 S(ssetmask) = A_YES | A_LIBERAL,
294 S(sigsuspend) = A_YES | A_LIBERAL,
295 S(sigpending) = A_YES | A_LIBERAL,
296 S(getrlimit) = A_YES | A_LIBERAL,
297 S(getrusage) = A_YES | A_LIBERAL,
298 S(ugetrlimit) = A_YES | A_LIBERAL,
299 S(gettimeofday) = A_YES | A_LIBERAL,
300 S(select) = A_YES | A_LIBERAL,
301 S(readdir) = A_YES | A_LIBERAL,
302 S(setitimer) = A_YES | A_LIBERAL,
303 S(getitimer) = A_YES | A_LIBERAL,
304 S(sigreturn) = A_YES | A_LIBERAL | A_NO_RETVAL,
305 S(mprotect) = A_YES | A_LIBERAL,
306 S(sigprocmask) = A_YES | A_LIBERAL,
307 S(getdents) = A_YES | A_LIBERAL,
308 S(getdents64) = A_YES | A_LIBERAL,
309 S(_newselect) = A_YES | A_LIBERAL,
310 S(fdatasync) = A_YES | A_LIBERAL,
311 S(mremap) = A_YES | A_LIBERAL,
312 S(poll) = A_YES | A_LIBERAL,
313 S(getcwd) = A_YES | A_LIBERAL,
314 S(nanosleep) = A_YES | A_LIBERAL,
315 S(rt_sigreturn) = A_YES | A_LIBERAL | A_NO_RETVAL,
316 S(rt_sigaction) = A_YES | A_LIBERAL,
317 S(rt_sigprocmask) = A_YES | A_LIBERAL,
318 S(rt_sigpending) = A_YES | A_LIBERAL,
319 S(rt_sigtimedwait) = A_YES | A_LIBERAL,
320 S(rt_sigqueueinfo) = A_YES | A_LIBERAL,
321 S(rt_sigsuspend) = A_YES | A_LIBERAL,
322 S(_sysctl) = A_YES | A_LIBERAL,
327 syscall_name(unsigned int id, char *buf)
329 if (id < NUM_SYSCALLS && syscall_names[id])
330 return syscall_names[id];
333 sprintf(buf, "#%d", id);
339 syscall_by_name(char *name)
341 for (unsigned int i=0; i<NUM_SYSCALLS; i++)
342 if (syscall_names[i] && !strcmp(syscall_names[i], name))
349 unsigned long l = strtoul(name, &ep, 0);
352 if (l >= NUM_ACTIONS)
358 set_syscall_action(char *a)
360 char *sep = strchr(a, '=');
361 enum action act = A_YES;
365 if (!strcmp(sep, "yes"))
367 else if (!strcmp(sep, "no"))
369 else if (!strcmp(sep, "file"))
375 int sys = syscall_by_name(a);
377 die("Unknown syscall `%s'", a);
378 if (sys >= NUM_ACTIONS)
379 die("Syscall `%s' out of range", a);
380 syscall_action[sys] = act;
389 struct path_rule *next;
392 static struct path_rule default_path_rules[] = {
395 { "/usr/lib/", A_YES },
396 { "/opt/lib/", A_YES },
397 { "/usr/share/zoneinfo/", A_YES },
398 { "/usr/share/locale/", A_YES },
399 { "/dev/null", A_YES },
400 { "/dev/zero", A_YES },
401 { "/proc/meminfo", A_YES },
402 { "/proc/self/stat", A_YES },
403 { "/proc/self/exe", A_YES }, // Needed by FPC 2.0.x runtime
406 static struct path_rule *user_path_rules;
407 static struct path_rule **last_path_rule = &user_path_rules;
410 set_path_action(char *a)
412 char *sep = strchr(a, '=');
413 enum action act = A_YES;
417 if (!strcmp(sep, "yes"))
419 else if (!strcmp(sep, "no"))
425 struct path_rule *r = xmalloc(sizeof(*r) + strlen(a) + 1);
426 r->path = (char *)(r+1);
431 last_path_rule = &r->next;
436 match_path_rule(struct path_rule *r, char *path)
440 if (*rr++ != *path++)
442 if (rr[-1] == '/' && !path[-1])
446 if (rr > r->path && rr[-1] != '/' && *path)
451 /*** Environment rules ***/
454 char *var; // Variable to match
455 char *val; // ""=clear, NULL=inherit
457 struct env_rule *next;
460 static struct env_rule *first_env_rule;
461 static struct env_rule **last_env_rule = &first_env_rule;
463 static struct env_rule default_env_rules[] = {
464 { "LIBC_FATAL_STDERR_", "1" }
468 set_env_action(char *a0)
470 struct env_rule *r = xmalloc(sizeof(*r) + strlen(a0) + 1);
471 char *a = (char *)(r+1);
474 char *sep = strchr(a, '=');
486 last_env_rule = &r->next;
492 match_env_var(char *env_entry, struct env_rule *r)
494 if (strncmp(env_entry, r->var, r->var_len))
496 return (env_entry[r->var_len] == '=');
500 apply_env_rule(char **env, int *env_sizep, struct env_rule *r)
502 // First remove the variable if already set
504 while (pos < *env_sizep && !match_env_var(env[pos], r))
506 if (pos < *env_sizep)
509 env[pos] = env[*env_sizep];
510 env[*env_sizep] = NULL;
513 // What is the new value?
519 new = xmalloc(r->var_len + 1 + strlen(r->val) + 1);
520 sprintf(new, "%s=%s", r->var, r->val);
525 while (environ[pos] && !match_env_var(environ[pos], r))
527 if (!(new = environ[pos]))
531 // Add it at the end of the array
532 env[(*env_sizep)++] = new;
533 env[*env_sizep] = NULL;
537 setup_environment(void)
539 // Link built-in rules with user rules
540 for (int i=ARRAY_SIZE(default_env_rules)-1; i >= 0; i--)
542 default_env_rules[i].next = first_env_rule;
543 first_env_rule = &default_env_rules[i];
546 // Scan the original environment
547 char **orig_env = environ;
549 while (orig_env[orig_size])
552 // For each rule, reserve one more slot and calculate length
554 for (struct env_rule *r = first_env_rule; r; r=r->next)
557 r->var_len = strlen(r->var);
560 // Create a new environment
561 char **env = xmalloc((orig_size + num_rules + 1) * sizeof(char *));
565 memcpy(env, environ, orig_size * sizeof(char *));
572 // Apply the rules one by one
573 for (struct env_rule *r = first_env_rule; r; r=r->next)
574 apply_env_rule(env, &size, r);
576 // Return the new env and pass some gossip
579 fprintf(stderr, "Passing environment:\n");
580 for (int i=0; env[i]; i++)
581 fprintf(stderr, "\t%s\n", env[i]);
586 /*** Syscall checks ***/
589 valid_filename(unsigned long addr)
591 char namebuf[4096], *p, *end;
595 err("FA: File access forbidden");
596 if (file_access >= 9)
601 sprintf(namebuf, "/proc/%d/mem", (int) box_pid);
602 mem_fd = open(namebuf, O_RDONLY);
604 die("open(%s): %m", namebuf);
611 int remains = PAGE_SIZE - (addr & (PAGE_SIZE-1));
612 int l = namebuf + sizeof(namebuf) - end;
616 err("FA: Access to file with name too long");
617 if (lseek64(mem_fd, addr, SEEK_SET) < 0)
618 die("lseek64(mem): %m");
619 remains = read(mem_fd, end, l);
621 die("read(mem): %m");
623 err("FA: Access to file with name out of memory");
630 msg("[%s] ", namebuf);
631 if (file_access >= 3)
634 // Everything in current directory is permitted
635 if (!strchr(namebuf, '/') && strcmp(namebuf, ".."))
638 // ".." anywhere in the path is forbidden
639 enum action act = A_DEFAULT;
640 if (strstr(namebuf, ".."))
644 for (struct path_rule *r = user_path_rules; r && !act; r=r->next)
645 act = match_path_rule(r, namebuf);
647 // Scan built-in rules
648 if (file_access >= 2)
649 for (int i=0; i<ARRAY_SIZE(default_path_rules) && !act; i++)
650 act = match_path_rule(&default_path_rules[i], namebuf);
653 err("FA: Forbidden access to file `%s'", namebuf);
656 // Check syscall. If invalid, return -1, otherwise return the action mask.
658 valid_syscall(struct user *u)
660 unsigned int sys = u->regs.orig_eax;
661 unsigned int act = (sys < NUM_ACTIONS) ? syscall_action[sys] : A_DEFAULT;
665 if (filter_syscalls != 1)
669 switch (act & A_ACTION_MASK)
676 valid_filename(u->regs.ebx);
684 if (u->regs.ebx == box_pid)
686 meta_printf("exitsig:%d\n", (int)u->regs.ecx);
687 err("SG: Committed suicide by signal %d", (int)u->regs.ecx);
691 if (u->regs.ebx == box_pid && u->regs.ecx == box_pid)
693 meta_printf("exitsig:%d\n", (int)u->regs.edx);
694 err("SG: Committed suicide by signal %d", (int)u->regs.edx);
703 signal_alarm(int unused UNUSED)
705 /* Time limit checks are synchronous, so we only schedule them there. */
711 signal_int(int unused UNUSED)
713 /* Interrupts are fatal, so no synchronization requirements. */
714 meta_printf("exitsig:%d\n", SIGINT);
715 err("SG: Interrupted");
718 #define PROC_BUF_SIZE 4096
720 read_proc_file(char *buf, char *name, int *fdp)
726 sprintf(buf, "/proc/%d/%s", (int) box_pid, name);
727 *fdp = open(buf, O_RDONLY);
729 die("open(%s): %m", buf);
731 lseek(*fdp, 0, SEEK_SET);
732 if ((c = read(*fdp, buf, PROC_BUF_SIZE-1)) < 0)
733 die("read on /proc/$pid/%s: %m", name);
734 if (c >= PROC_BUF_SIZE-1)
735 die("/proc/$pid/%s too long", name);
744 struct timeval now, wall;
746 gettimeofday(&now, NULL);
747 timersub(&now, &start_time, &wall);
748 wall_ms = wall.tv_sec*1000 + wall.tv_usec/1000;
749 if (wall_ms > wall_timeout)
750 err("TO: Time limit exceeded (wall clock)");
752 fprintf(stderr, "[wall time check: %d msec]\n", wall_ms);
756 char buf[PROC_BUF_SIZE], *x;
757 int utime, stime, ms;
758 static int proc_stat_fd;
759 read_proc_file(buf, "stat", &proc_stat_fd);
761 while (*x && *x != ' ')
766 die("proc stat syntax error 1");
767 while (*x && (*x != ')' || x[1] != ' '))
769 while (*x == ')' || *x == ' ')
771 if (sscanf(x, "%*c %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %d %d", &utime, &stime) != 2)
772 die("proc stat syntax error 2");
773 ms = (utime + stime) * 1000 / ticks_per_sec;
775 fprintf(stderr, "[time check: %d msec]\n", ms);
776 if (ms > timeout && ms > extra_timeout)
777 err("TO: Time limit exceeded");
782 sample_mem_peak(void)
785 * We want to find out the peak memory usage of the process, which is
786 * maintained by the kernel, but unforunately it gets lost when the
787 * process exits (it is not reported in struct rusage). Therefore we
788 * have to sample it whenever we suspect that the process is about
791 char buf[PROC_BUF_SIZE], *x;
792 static int proc_status_fd;
793 read_proc_file(buf, "status", &proc_status_fd);
799 while (*x && *x != ':' && *x != '\n')
801 if (!*x || *x == '\n')
804 while (*x == ' ' || *x == '\t')
808 while (*x && *x != '\n')
814 if (!strcmp(key, "VmPeak"))
816 int peak = atoi(val);
817 if (peak > mem_peak_kb)
823 msg("[mem-peak: %u KB]\n", mem_peak_kb);
829 int syscall_count = 0;
833 bzero(&sa, sizeof(sa));
834 sa.sa_handler = signal_int;
835 sigaction(SIGINT, &sa, NULL);
836 gettimeofday(&start_time, NULL);
837 ticks_per_sec = sysconf(_SC_CLK_TCK);
838 if (ticks_per_sec <= 0)
839 die("Invalid ticks_per_sec!");
840 if (timeout || wall_timeout)
842 sa.sa_handler = signal_alarm;
843 sigaction(SIGALRM, &sa, NULL);
856 p = wait4(box_pid, &stat, WUNTRACED, &rus);
864 die("wait4: unknown pid %d exited!", p);
869 if (WEXITSTATUS(stat))
873 meta_printf("exitcode:%d\n", WEXITSTATUS(stat));
874 err("RE: Exited with error status %d", WEXITSTATUS(stat));
878 // Internal error happened inside the child process and it has been already reported.
882 if (timeout && total_ms > timeout)
883 err("TO: Time limit exceeded");
884 if (wall_timeout && wall_ms > wall_timeout)
885 err("TO: Time limit exceeded (wall clock)");
887 fprintf(stderr, "OK (%d.%03d sec real, %d.%03d sec wall, %d MB, %d syscalls)\n",
888 total_ms/1000, total_ms%1000,
889 wall_ms/1000, wall_ms%1000,
890 (mem_peak_kb + 1023) / 1024,
894 if (WIFSIGNALED(stat))
897 meta_printf("exitsig:%d\n", WTERMSIG(stat));
899 err("SG: Caught fatal signal %d%s", WTERMSIG(stat), (syscall_count ? "" : " during startup"));
901 if (WIFSTOPPED(stat))
903 int sig = WSTOPSIG(stat);
907 msg("[ptrace status %08x] ", stat);
908 static int stop_count;
909 if (!stop_count++) /* Traceme request */
910 msg(">> Traceme request caught\n");
912 err("SG: Breakpoint");
913 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
915 else if (sig == (SIGTRAP | 0x80))
918 msg("[ptrace status %08x] ", stat);
920 static unsigned int sys_tick, last_sys, last_act;
921 if (ptrace(PTRACE_GETREGS, box_pid, NULL, &u) < 0)
922 die("ptrace(PTRACE_GETREGS): %m");
923 unsigned int sys = u.regs.orig_eax;
924 if (++sys_tick & 1) /* Syscall entry */
928 msg(">> Syscall %-12s (%08lx,%08lx,%08lx) ", syscall_name(sys, namebuf), u.regs.ebx, u.regs.ecx, u.regs.edx);
932 if (sys == __NR_execve)
935 else if ((act = valid_syscall(&u)) >= 0)
939 if (act & A_SAMPLE_MEM)
945 * Unfortunately, PTRACE_KILL kills _after_ the syscall completes,
946 * so we have to change it to something harmless (e.g., an undefined
947 * syscall) and make the program continue.
949 u.regs.orig_eax = 0xffffffff;
950 if (ptrace(PTRACE_SETREGS, box_pid, NULL, &u) < 0)
951 die("ptrace(PTRACE_SETREGS): %m");
952 err("FO: Forbidden syscall %s", syscall_name(sys, namebuf));
956 else /* Syscall return */
958 if (sys == 0xffffffff)
960 /* Some syscalls (sigreturn et al.) do not return a value */
961 if (!(last_act & A_NO_RETVAL))
962 err("XX: Syscall does not return, but it should");
967 err("XX: Mismatched syscall entry/exit");
969 if (last_act & A_NO_RETVAL)
972 msg("= %ld\n", u.regs.eax);
974 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
976 else if (sig == SIGSTOP)
979 if (ptrace(PTRACE_SETOPTIONS, box_pid, NULL, (void *) PTRACE_O_TRACESYSGOOD) < 0)
980 die("ptrace(PTRACE_SETOPTIONS): %m");
981 ptrace(PTRACE_SYSCALL, box_pid, 0, 0);
983 else if (sig != SIGXCPU && sig != SIGXFSZ)
985 msg(">> Signal %d\n", sig);
986 sample_mem_peak(); /* Signal might be fatal, so update mem-peak */
987 ptrace(PTRACE_SYSCALL, box_pid, 0, sig);
991 meta_printf("exitsig:%d", sig);
992 err("SG: Received signal %d", sig);
996 die("wait4: unknown status %x, giving up!", stat);
1001 box_inside(int argc, char **argv)
1006 memcpy(args, argv, argc * sizeof(char *));
1008 if (set_cwd && chdir(set_cwd))
1013 if (open(redir_stdin, O_RDONLY) != 0)
1014 die("open(\"%s\"): %m", redir_stdin);
1019 if (open(redir_stdout, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1)
1020 die("open(\"%s\"): %m", redir_stdout);
1025 if (open(redir_stderr, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 2)
1026 die("open(\"%s\"): %m", redir_stderr);
1033 rl.rlim_cur = rl.rlim_max = memory_limit * 1024;
1034 if (setrlimit(RLIMIT_AS, &rl) < 0)
1035 die("setrlimit: %m");
1037 rl.rlim_cur = rl.rlim_max = 64;
1038 if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
1039 die("setrlimit: %m");
1040 char **env = setup_environment();
1041 if (filter_syscalls)
1043 if (ptrace(PTRACE_TRACEME) < 0)
1044 die("ptrace(PTRACE_TRACEME): %m");
1045 /* Trick: Make sure that we are stopped until the boxkeeper wakes up. */
1048 execve(args[0], args, env);
1049 die("execve(\"%s\"): %m", args[0]);
1055 fprintf(stderr, "Invalid arguments!\n");
1057 Usage: box [<options>] -- <command> <arguments>\n\
1060 -a <level>\tSet file access level (0=none, 1=cwd, 2=/etc,/lib,..., 3=whole fs, 9=no checks; needs -f)\n\
1061 -c <dir>\tChange directory to <dir> first\n\
1062 -e\t\tInherit full environment of the parent process\n\
1063 -E <var>\tInherit the environment variable <var> from the parent process\n\
1064 -E <var>=<val>\tSet the environment variable <var> to <val>; unset it if <var> is empty\n\
1065 -f\t\tFilter system calls (-ff=very restricted)\n\
1066 -i <file>\tRedirect stdin from <file>\n\
1067 -m <size>\tLimit address space to <size> KB\n\
1068 -M <file>\tOutput process information to <file> (name:value)\n\
1069 -o <file>\tRedirect stdout to <file>\n\
1070 -p <path>\tPermit access to the specified path (or subtree if it ends with a `/')\n\
1071 -p <path>=<act>\tDefine action for the specified path (<act>=yes/no)\n\
1072 -r <file>\tRedirect stderr to <file>\n\
1073 -s <sys>\tPermit the specified syscall (be careful)\n\
1074 -s <sys>=<act>\tDefine action for the specified syscall (<act>=yes/no/file)\n\
1075 -t <time>\tSet run time limit (seconds, fractions allowed)\n\
1076 -T\t\tAllow syscalls for measuring run time\n\
1077 -v\t\tBe verbose (use multiple times for even more verbosity)\n\
1078 -w <time>\tSet wall clock time limit (seconds, fractions allowed)\n\
1079 -x <time>\tSet extra timeout, before which a timing-out program is not yet killed,\n\
1080 \t\tso that its real execution time is reported (seconds, fractions allowed)\n\
1086 main(int argc, char **argv)
1091 while ((c = getopt(argc, argv, "a:c:eE:fi:m:M:o:p:r:s:t:Tvw:x:")) >= 0)
1095 file_access = atol(optarg);
1104 if (!set_env_action(optarg))
1111 redir_stdin = optarg;
1114 memory_limit = atol(optarg);
1120 redir_stdout = optarg;
1123 if (!set_path_action(optarg))
1127 redir_stderr = optarg;
1130 if (!set_syscall_action(optarg))
1134 timeout = 1000*atof(optarg);
1137 syscall_action[__NR_times] = A_YES;
1143 wall_timeout = 1000*atof(optarg);
1146 extra_timeout = 1000*atof(optarg);
1155 if (setreuid(uid, uid) < 0)
1156 die("setreuid: %m");
1161 box_inside(argc-optind, argv+optind);
1164 die("Internal error: fell over edge of the world");