aboutsummaryrefslogtreecommitdiffstats
path: root/sandbox/sandbox.h
blob: 0a5a31f853c26d57aee22133c78550ae953eb2e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef SANDBOX_H
#define SANDBOX_H

#ifndef __x86_64__
# error unsupported
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#include <pwd.h>
#include <grp.h>
#include <sched.h>
#include <getopt.h>
#include <assert.h>
#include <signal.h>
#include <time.h>
#include <ftw.h>
#include <limits.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/reg.h>
#include <sys/prctl.h>
#include <sys/ptrace.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/sendfile.h>
#include <sys/epoll.h>
#include <sys/timerfd.h>
#include <sys/signalfd.h>

#define noreturn _Noreturn
#define unused __attribute__((__unused__))
#define warn_unused __attribute__((warn_unused_result))

enum poe_exit_reason {
	POE_SUCCESS,
	POE_SIGNALED,
	POE_TIMEDOUT,
};

struct playground {
	char *workbase;
	char *upperdir;
	char *workdir;
	char *mergeddir;
	char **command_line;
};

struct cgroups {
	int a;
};

#include "config.h"
#include "utils.h"

// seccomp.c
warn_unused int poe_seccomp_init(void);
char *poe_seccomp_syscall_resolve(int);

// cgroup.c
struct cgroups *poe_cgroups_init(const char *tmpdir);
int poe_cgroups_add(struct cgroups *, pid_t);
void poe_cgroups_destroy(struct cgroups *);

// playground.c
struct playground *poe_playground_init(const char *basedir,
				       const char *overlaydir,
				       const char *tmpdir);
int poe_playground_copy_files(const struct playground *, size_t, const char **);
void poe_playground_destroy(struct playground *);

_Noreturn void poe_child_do(struct playground *, int);

#endif