/[path-sandbox]/trunk/src/sandbox.h
Gentoo

Contents of /trunk/src/sandbox.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 263 - (show annotations) (download) (as text)
Tue Jul 4 14:58:16 2006 UTC (8 years, 3 months ago) by azarah
File MIME type: text/x-chdr
File size: 3706 byte(s)
Add is_env_off().  Also check for true/false. Use is_env_*.

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 #define LD_PRELOAD_EQ "LD_PRELOAD="
17 #define LD_PRELOAD_FILE "/etc/ld.so.preload"
18 #define LIB_NAME "libsandbox.so"
19 #define BASHRC_NAME "sandbox.bashrc"
20 #define TMPDIR "/tmp"
21 #define VAR_TMPDIR "/var/tmp"
22 #define PORTAGE_TMPDIR "/var/tmp/portage"
23 #define SANDBOX_LOG_LOCATION "/var/log/sandbox"
24 #define LOG_FILE_PREFIX "/sandbox-"
25 #define DEBUG_LOG_FILE_PREFIX "/sandbox-debug-"
26 #define LOG_FILE_EXT ".log"
27
28 #define ENV_LD_PRELOAD "LD_PRELOAD"
29
30 #define ENV_EBUILD "EBUILD"
31 #define ENV_TMPDIR "TMPDIR"
32 #define ENV_PORTAGE_TMPDIR "PORTAGE_TMPDIR"
33
34 #define ENV_BASH_ENV "BASH_ENV"
35
36 #define ENV_NOCOLOR "NOCOLOR"
37
38 #define ENV_SANDBOX_VERBOSE "SANDBOX_VERBOSE"
39 #define ENV_SANDBOX_DEBUG "SANDBOX_DEBUG"
40
41 #define ENV_SANDBOX_LIB "SANDBOX_LIB"
42 #define ENV_SANDBOX_BASHRC "SANDBOX_BASHRC"
43 #define ENV_SANDBOX_LOG "SANDBOX_LOG"
44 #define ENV_SANDBOX_DEBUG_LOG "SANDBOX_DEBUG_LOG"
45
46 #define ENV_SANDBOX_DENY "SANDBOX_DENY"
47 #define ENV_SANDBOX_READ "SANDBOX_READ"
48 #define ENV_SANDBOX_WRITE "SANDBOX_WRITE"
49 #define ENV_SANDBOX_PREDICT "SANDBOX_PREDICT"
50
51 #define ENV_SANDBOX_ON "SANDBOX_ON"
52 #define ENV_SANDBOX_BEEP "SANDBOX_BEEP"
53
54 #define ENV_SANDBOX_PID "SANDBOX_PID"
55 #define ENV_SANDBOX_ABORT "SANDBOX_ABORT"
56 #define ENV_SANDBOX_INTRACTV "SANDBOX_INTRACTV"
57
58 #define ENV_SANDBOX_ACTIVE "SANDBOX_ACTIVE"
59 #define SANDBOX_ACTIVE "armedandready"
60
61 #define DEFAULT_BEEP_COUNT 3
62
63 #define SB_BUF_LEN 2048
64
65 /* Gentoo style e* printing macro's */
66 #define EINFO(_color, _hilight, _args...) \
67 do { \
68 int old_errno = errno; \
69 if (_color) \
70 fprintf(stderr, "\033[32;01m" _hilight "\033[0m" _args); \
71 else \
72 fprintf(stderr, _hilight _args); \
73 errno = old_errno; \
74 } while (0)
75
76 #define EWARN(_color, _hilight, _args...) \
77 do { \
78 int old_errno = errno; \
79 if (_color) \
80 fprintf(stderr, "\033[33;01m" _hilight "\033[0m" _args); \
81 else \
82 fprintf(stderr, _hilight _args); \
83 errno = old_errno; \
84 } while (0)
85
86 #define EERROR(_color, _hilight, _args...) \
87 do { \
88 int old_errno = errno; \
89 if (_color) \
90 fprintf(stderr, "\033[31;01m" _hilight "\033[0m" _args); \
91 else \
92 fprintf(stderr, _hilight _args); \
93 errno = old_errno; \
94 } while (0)
95
96 typedef enum {
97 false,
98 true
99 } bool;
100
101 void get_sandbox_lib(char *path);
102 #ifdef OUTSIDE_LIBSANDBOX
103 void get_sandbox_rc(char *path);
104 void get_sandbox_log(char *path);
105 void get_sandbox_debug_log(char *path);
106 int get_tmp_dir(char *path);
107 #endif /* OUTSIDE_LIBSANDBOX */
108 int exists(const char *pathname);
109 #ifdef OUTSIDE_LIBSANDBOX
110 int is_file(const char *pathname);
111 int is_dir(const char *pathname, int follow_link);
112 long file_length(int fd);
113 #endif /* OUTSIDE_LIBSANDBOX */
114 bool is_env_on (const char *);
115 bool is_env_off (const char *);
116
117 /* Compat functions for GNU extensions */
118 char *gstrndup (const char *str, size_t size);
119 /* Same as basename(3), but do not modify path */
120 char *gbasename (const char *path);
121
122 /* glibc modified realpath() function */
123 char *erealpath(const char *, char *);
124 #ifndef OUTSIDE_LIBSANDBOX
125 char *egetcwd(char *, size_t);
126 #endif
127
128 #endif /* __SANDBOX_H__ */
129
130 // vim:noexpandtab noai:cindent ai

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20