/[path-sandbox]/trunk/src/sandbox_futils.c
Gentoo

Diff of /trunk/src/sandbox_futils.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 188 Revision 189
19 19
20#include "sandbox.h" 20#include "sandbox.h"
21#include "config.h" 21#include "config.h"
22 22
23/* glibc modified getcwd() functions */ 23/* glibc modified getcwd() functions */
24SB_STATIC char *egetcwd(char *, size_t); 24char *egetcwd(char *, size_t);
25 25
26SB_STATIC void get_sandbox_lib(char *path) 26void get_sandbox_lib(char *path)
27{ 27{
28#ifdef SB_HAVE_MULTILIB 28#ifdef SB_HAVE_MULTILIB
29 snprintf(path, SB_PATH_MAX, "%s", LIB_NAME); 29 snprintf(path, SB_PATH_MAX, "%s", LIB_NAME);
30#else 30#else
31 snprintf(path, SB_PATH_MAX, "%s/%s", LIBSANDBOX_PATH, LIB_NAME); 31 snprintf(path, SB_PATH_MAX, "%s/%s", LIBSANDBOX_PATH, LIB_NAME);
35#endif 35#endif
36} 36}
37 37
38#ifdef OUTSIDE_LIBSANDBOX 38#ifdef OUTSIDE_LIBSANDBOX
39 39
40SB_STATIC void get_sandbox_rc(char *path) 40void get_sandbox_rc(char *path)
41{ 41{
42 snprintf(path, SB_PATH_MAX, "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME); 42 snprintf(path, SB_PATH_MAX, "%s/%s", SANDBOX_BASHRC_PATH, BASHRC_NAME);
43} 43}
44 44
45SB_STATIC void get_sandbox_log(char *path) 45void get_sandbox_log(char *path)
46{ 46{
47 char *sandbox_log_env = NULL; 47 char *sandbox_log_env = NULL;
48 48
49 sandbox_log_env = getenv(ENV_SANDBOX_LOG); 49 sandbox_log_env = getenv(ENV_SANDBOX_LOG);
50 50
60 (sandbox_log_env == NULL ? "" : sandbox_log_env), 60 (sandbox_log_env == NULL ? "" : sandbox_log_env),
61 (sandbox_log_env == NULL ? "" : "-"), 61 (sandbox_log_env == NULL ? "" : "-"),
62 getpid(), LOG_FILE_EXT); 62 getpid(), LOG_FILE_EXT);
63} 63}
64 64
65SB_STATIC void get_sandbox_debug_log(char *path) 65void get_sandbox_debug_log(char *path)
66{ 66{
67 char *sandbox_debug_log_env = NULL; 67 char *sandbox_debug_log_env = NULL;
68 68
69 sandbox_debug_log_env = getenv(ENV_SANDBOX_DEBUG_LOG); 69 sandbox_debug_log_env = getenv(ENV_SANDBOX_DEBUG_LOG);
70 70
80 (sandbox_debug_log_env == NULL ? "" : sandbox_debug_log_env), 80 (sandbox_debug_log_env == NULL ? "" : sandbox_debug_log_env),
81 (sandbox_debug_log_env == NULL ? "" : "-"), 81 (sandbox_debug_log_env == NULL ? "" : "-"),
82 getpid(), LOG_FILE_EXT); 82 getpid(), LOG_FILE_EXT);
83} 83}
84 84
85SB_STATIC int get_tmp_dir(char *path) 85int get_tmp_dir(char *path)
86{ 86{
87 if (NULL == realpath(getenv(ENV_TMPDIR) ? getenv(ENV_TMPDIR) 87 if (NULL == realpath(getenv(ENV_TMPDIR) ? getenv(ENV_TMPDIR)
88 : TMPDIR, 88 : TMPDIR,
89 path)) { 89 path)) {
90 if (NULL == realpath(TMPDIR, path)) 90 if (NULL == realpath(TMPDIR, path))
94 return 0; 94 return 0;
95} 95}
96 96
97#endif /* OUTSIDE_LIBSANDBOX */ 97#endif /* OUTSIDE_LIBSANDBOX */
98 98
99SB_STATIC int exists(const char *pathname) 99int exists(const char *pathname)
100{ 100{
101 struct stat buf; 101 struct stat buf;
102 int retval; 102 int retval;
103 103
104 if ((NULL == pathname) || (0 == strlen(pathname))) 104 if ((NULL == pathname) || (0 == strlen(pathname)))
114 return 0; 114 return 0;
115} 115}
116 116
117#ifdef OUTSIDE_LIBSANDBOX 117#ifdef OUTSIDE_LIBSANDBOX
118 118
119SB_STATIC int is_file(const char *pathname) 119int is_file(const char *pathname)
120{ 120{
121 struct stat buf; 121 struct stat buf;
122 int retval; 122 int retval;
123 123
124 if ((NULL == pathname) || (0 == strlen(pathname))) 124 if ((NULL == pathname) || (0 == strlen(pathname)))
132 return -1; 132 return -1;
133 133
134 return 0; 134 return 0;
135} 135}
136 136
137SB_STATIC int is_dir(const char *pathname, int follow_link) 137int is_dir(const char *pathname, int follow_link)
138{ 138{
139 struct stat buf; 139 struct stat buf;
140 int retval; 140 int retval;
141 141
142 if ((NULL == pathname) || (0 == strlen(pathname))) 142 if ((NULL == pathname) || (0 == strlen(pathname)))
150 return -1; 150 return -1;
151 151
152 return 0; 152 return 0;
153} 153}
154 154
155SB_STATIC long file_length(int fd) 155long file_length(int fd)
156{ 156{
157 long pos, len; 157 long pos, len;
158 158
159 pos = lseek(fd, 0L, SEEK_CUR); 159 pos = lseek(fd, 0L, SEEK_CUR);
160 len = lseek(fd, 0L, SEEK_END); 160 len = lseek(fd, 0L, SEEK_END);

Legend:
Removed from v.188  
changed lines
  Added in v.189

  ViewVC Help
Powered by ViewVC 1.1.20