| 1 |
/*
|
| 2 |
* Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>,
|
| 3 |
* Possibly based on code from Geert Bevin, Uwyn, http://www.uwyn.com
|
| 4 |
* Distributed under the terms of the GNU General Public License, v2 or later
|
| 5 |
* Author: Brad House <brad@mainstreetsoftworks.com>
|
| 6 |
*
|
| 7 |
* $Header$
|
| 8 |
*/
|
| 9 |
|
| 10 |
#ifndef __SANDBOX_H__
|
| 11 |
#define __SANDBOX_H__
|
| 12 |
|
| 13 |
#include "localdecls.h"
|
| 14 |
#include "config.h"
|
| 15 |
|
| 16 |
/* Uncomment below to use flock instead of fcntl (POSIX way) to lock/unlock files */
|
| 17 |
/* #define USE_FLOCK */
|
| 18 |
|
| 19 |
#define LD_PRELOAD_EQ "LD_PRELOAD="
|
| 20 |
#define LD_PRELOAD_FILE "/etc/ld.so.preload"
|
| 21 |
#define LIB_NAME "libsandbox.so"
|
| 22 |
#define BASHRC_NAME "sandbox.bashrc"
|
| 23 |
#define TMPDIR "/tmp"
|
| 24 |
#define VAR_TMPDIR "/var/tmp"
|
| 25 |
#define PORTAGE_TMPDIR "/var/tmp/portage"
|
| 26 |
#define SANDBOX_LOG_LOCATION "/var/log/sandbox"
|
| 27 |
#define LOG_FILE_PREFIX "/sandbox-"
|
| 28 |
#define DEBUG_LOG_FILE_PREFIX "/sandbox-debug-"
|
| 29 |
#define LOG_FILE_EXT ".log"
|
| 30 |
|
| 31 |
#define ENV_LD_PRELOAD "LD_PRELOAD"
|
| 32 |
|
| 33 |
#define ENV_TMPDIR "TMPDIR"
|
| 34 |
#define ENV_PORTAGE_TMPDIR "PORTAGE_TMPDIR"
|
| 35 |
|
| 36 |
#define ENV_SANDBOX_LIB "SANDBOX_LIB"
|
| 37 |
#define ENV_SANDBOX_BASHRC "SANDBOX_BASHRC"
|
| 38 |
#define ENV_SANDBOX_LOG "SANDBOX_LOG"
|
| 39 |
#define ENV_SANDBOX_DEBUG_LOG "SANDBOX_DEBUG_LOG"
|
| 40 |
|
| 41 |
#define ENV_SANDBOX_DENY "SANDBOX_DENY"
|
| 42 |
#define ENV_SANDBOX_READ "SANDBOX_READ"
|
| 43 |
#define ENV_SANDBOX_WRITE "SANDBOX_WRITE"
|
| 44 |
#define ENV_SANDBOX_PREDICT "SANDBOX_PREDICT"
|
| 45 |
|
| 46 |
#define ENV_SANDBOX_ON "SANDBOX_ON"
|
| 47 |
#define ENV_SANDBOX_BEEP "SANDBOX_BEEP"
|
| 48 |
|
| 49 |
#define DEFAULT_BEEP_COUNT 3
|
| 50 |
|
| 51 |
#define SB_BUF_LEN 2048
|
| 52 |
|
| 53 |
#if !HAVE_DLVSYM
|
| 54 |
# define dlvsym(lib, sym, ver) dlsym(lib, sym)
|
| 55 |
#endif
|
| 56 |
|
| 57 |
/* Gentoo style e* printing macro's */
|
| 58 |
#define EINFO(_color, _hilight, _args...) \
|
| 59 |
do { \
|
| 60 |
int old_errno = errno; \
|
| 61 |
if (_color) \
|
| 62 |
printf("\033[32;01m" _hilight "\033[0m" _args); \
|
| 63 |
else \
|
| 64 |
printf(_hilight _args); \
|
| 65 |
errno = old_errno; \
|
| 66 |
} while (0)
|
| 67 |
|
| 68 |
#define EWARN(_color, _hilight, _args...) \
|
| 69 |
do { \
|
| 70 |
int old_errno = errno; \
|
| 71 |
if (_color) \
|
| 72 |
printf("\033[33;01m" _hilight "\033[0m" _args); \
|
| 73 |
else \
|
| 74 |
printf(_hilight _args); \
|
| 75 |
errno = old_errno; \
|
| 76 |
} while (0)
|
| 77 |
|
| 78 |
#define EERROR(_color, _hilight, _args...) \
|
| 79 |
do { \
|
| 80 |
int old_errno = errno; \
|
| 81 |
if (_color) \
|
| 82 |
fprintf(stderr, "\033[31;01m" _hilight "\033[0m" _args); \
|
| 83 |
else \
|
| 84 |
fprintf(stderr, _hilight _args); \
|
| 85 |
errno = old_errno; \
|
| 86 |
} while (0)
|
| 87 |
|
| 88 |
SB_STATIC void get_sandbox_lib(char *path);
|
| 89 |
#ifdef OUTSIDE_LIBSANDBOX
|
| 90 |
SB_STATIC void get_sandbox_rc(char *path);
|
| 91 |
SB_STATIC void get_sandbox_log(char *path);
|
| 92 |
SB_STATIC void get_sandbox_debug_log(char *path);
|
| 93 |
SB_STATIC int get_tmp_dir(char *path);
|
| 94 |
#endif /* OUTSIDE_LIBSANDBOX */
|
| 95 |
SB_STATIC int exists(const char *pathname);
|
| 96 |
#ifdef OUTSIDE_LIBSANDBOX
|
| 97 |
SB_STATIC int is_file(const char *pathname);
|
| 98 |
SB_STATIC long file_length(int fd);
|
| 99 |
#endif /* OUTSIDE_LIBSANDBOX */
|
| 100 |
|
| 101 |
#endif
|
| 102 |
|
| 103 |
// vim:noexpandtab noai:cindent ai
|