aboutsummaryrefslogtreecommitdiff
path: root/src/common/sandbox.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-27 09:48:26 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-27 10:04:17 -0400
commitbee580ddbaabcd8d6066761cce385c00d75dd2c5 (patch)
tree8d1f192dffd16cdec221e3b9994f44009c114158 /src/common/sandbox.h
parentd893be190fc244330543c9e98613a3f0daebc6ed (diff)
downloadtor-bee580ddbaabcd8d6066761cce385c00d75dd2c5.tar.gz
tor-bee580ddbaabcd8d6066761cce385c00d75dd2c5.zip
Move sandbox code into a new library.
Diffstat (limited to 'src/common/sandbox.h')
-rw-r--r--src/common/sandbox.h150
1 files changed, 0 insertions, 150 deletions
diff --git a/src/common/sandbox.h b/src/common/sandbox.h
deleted file mode 100644
index 60d8e8816a..0000000000
--- a/src/common/sandbox.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Copyright (c) 2001 Matej Pfajfar.
- * Copyright (c) 2001-2004, Roger Dingledine.
- * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2018, The Tor Project, Inc. */
-/* See LICENSE for licensing information */
-
-/**
- * \file sandbox.h
- * \brief Header file for sandbox.c.
- **/
-
-#ifndef SANDBOX_H_
-#define SANDBOX_H_
-
-#include "orconfig.h"
-#include "lib/cc/torint.h"
-
-#ifndef SYS_SECCOMP
-
-/**
- * Used by SIGSYS signal handler to check if the signal was issued due to a
- * seccomp2 filter violation.
- */
-#define SYS_SECCOMP 1
-
-#endif /* !defined(SYS_SECCOMP) */
-
-#if defined(HAVE_SECCOMP_H) && defined(__linux__)
-#define USE_LIBSECCOMP
-#endif
-
-struct sandbox_cfg_elem;
-
-/** Typedef to structure used to manage a sandbox configuration. */
-typedef struct sandbox_cfg_elem sandbox_cfg_t;
-
-/**
- * Linux definitions
- */
-#ifdef USE_LIBSECCOMP
-
-#include <sys/ucontext.h>
-#include <seccomp.h>
-#include <netdb.h>
-
-#define PARAM_PTR 0
-#define PARAM_NUM 1
-
-/**
- * Enum used to manage the type of the implementation for general purpose.
- */
-typedef enum {
- /** Libseccomp implementation based on seccomp2*/
- LIBSECCOMP2 = 0
-} SB_IMPL;
-
-/**
- * Configuration parameter structure associated with the LIBSECCOMP2
- * implementation.
- */
-typedef struct smp_param {
- /** syscall associated with parameter. */
- int syscall;
-
- /** parameter value. */
- char *value;
- /** parameter value, second argument. */
- char *value2;
-
- /** parameter flag (0 = not protected, 1 = protected). */
- int prot;
-} smp_param_t;
-
-/**
- * Structure used to manage a sandbox configuration.
- *
- * It is implemented as a linked list of parameters. Currently only controls
- * parameters for open, openat, execve, stat64.
- */
-struct sandbox_cfg_elem {
- /** Sandbox implementation which dictates the parameter type. */
- SB_IMPL implem;
-
- /** Configuration parameter. */
- smp_param_t *param;
-
- /** Next element of the configuration*/
- struct sandbox_cfg_elem *next;
-};
-
-/** Function pointer defining the prototype of a filter function.*/
-typedef int (*sandbox_filter_func_t)(scmp_filter_ctx ctx,
- sandbox_cfg_t *filter);
-
-/** Type that will be used in step 3 in order to manage multiple sandboxes.*/
-typedef struct {
- /** function pointers associated with the filter */
- sandbox_filter_func_t *filter_func;
-
- /** filter function pointer parameters */
- sandbox_cfg_t *filter_dynamic;
-} sandbox_t;
-
-#endif /* defined(USE_LIBSECCOMP) */
-
-#ifdef USE_LIBSECCOMP
-/** Returns a registered protected string used with the sandbox, given that
- * it matches the parameter.
- */
-const char* sandbox_intern_string(const char *param);
-#else /* !(defined(USE_LIBSECCOMP)) */
-#define sandbox_intern_string(s) (s)
-#endif /* defined(USE_LIBSECCOMP) */
-
-/** Creates an empty sandbox configuration file.*/
-sandbox_cfg_t * sandbox_cfg_new(void);
-
-/**
- * Function used to add a open allowed filename to a supplied configuration.
- * The (char*) specifies the path to the allowed file; we take ownership
- * of the pointer.
- */
-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);
-
-/* DOCDOC */
-int sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2);
-
-/**
- * Function used to add a openat allowed filename to a supplied configuration.
- * The (char*) specifies the path to the allowed file; we steal the pointer to
- * that file.
- */
-int sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file);
-
-/**
- * Function used to add a stat/stat64 allowed filename to a configuration.
- * The (char*) specifies the path to the allowed file; that pointer is stolen.
- */
-int sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file);
-
-/** Function used to initialise a sandbox configuration.*/
-int sandbox_init(sandbox_cfg_t* cfg);
-
-/** Return true iff the sandbox is turned on. */
-int sandbox_is_active(void);
-
-#endif /* !defined(SANDBOX_H_) */