#ifndef SANDBOX_H_
#define SANDBOX_H_
#include "orconfig.h"
#include "lib/cc/torint.h"
#ifndef SYS_SECCOMP
#define SYS_SECCOMP 1
#endif
#if defined(HAVE_SECCOMP_H) && defined(__linux__)
#define USE_LIBSECCOMP
#endif
struct sandbox_cfg_elem_t;
typedef struct sandbox_cfg_elem_t sandbox_cfg_t;
#ifdef USE_LIBSECCOMP
#include <sys/ucontext.h>
#include <seccomp.h>
#include <netdb.h>
#define PARAM_PTR 0
#define PARAM_NUM 1
typedef enum {
LIBSECCOMP2 = 0
} SB_IMPL;
typedef struct smp_param_t {
int syscall;
char *value;
char *value2;
int prot;
} smp_param_t;
struct sandbox_cfg_elem_t {
SB_IMPL implem;
smp_param_t *param;
struct sandbox_cfg_elem_t *next;
};
typedef int (*sandbox_filter_func_t)(scmp_filter_ctx ctx,
sandbox_cfg_t *filter);
typedef struct {
sandbox_filter_func_t *filter_func;
sandbox_cfg_t *filter_dynamic;
} sandbox_t;
#endif
#ifdef USE_LIBSECCOMP
const char* sandbox_intern_string(const char *param);
bool sandbox_interned_string_is_missing(const char *s);
#else
#define sandbox_intern_string(s) (s)
#define sandbox_interned_string_is_missing(s) (false)
#endif
sandbox_cfg_t * sandbox_cfg_new(void);
int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file);
int sandbox_cfg_allow_chmod_filename(sandbox_cfg_t **cfg, char *file);
int sandbox_cfg_allow_chown_filename(sandbox_cfg_t **cfg, char *file);
int sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2);
int sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file);
int sandbox_cfg_allow_opendir_dirname(sandbox_cfg_t **cfg, char *dir);
int sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file);
int sandbox_init(sandbox_cfg_t* cfg);
int sandbox_is_active(void);
#endif