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

Diff of /trunk/sandbox.c

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

Revision 87 Revision 88
170 free(sandbox_pids_file); 170 free(sandbox_pids_file);
171 if (0 == success) 171 if (0 == success)
172 return; 172 return;
173} 173}
174 174
175void stop(int signum)
176{
177 if (stop_called == 0) {
178 stop_called = 1;
179 printf("Caught signal %d in pid %d\r\n", signum, getpid());
180 cleanup();
181 } else {
182 fprintf(stderr, "Pid %d alreadly caught signal and is still cleaning up\n", getpid());
183 }
184}
185
186void setenv_sandbox_write(char *home_dir, char *portage_tmp_dir, char *var_tmp_dir, char *tmp_dir)
187{
188 char buf[1024];
189
190 /* bzero out entire buffer then append trailing 0 */
191 memset(buf, 0, sizeof(buf));
192
193 if (!getenv(ENV_SANDBOX_WRITE)) {
194 /* these could go into make.globals later on */
195 snprintf(buf, sizeof(buf),
196 "%s:%s/.gconfd/lock:%s/.bash_history:",
197 "/dev/zero:/dev/fd/:/dev/null:/dev/pts/:"
198 "/dev/vc/:/dev/pty:/dev/tty:/tmp/:"
199 "/dev/shm/ngpt:/var/log/scrollkeeper.log:"
200 "/usr/tmp/conftest:/usr/lib/conftest:"
201 "/usr/lib32/conftest:/usr/lib64/conftest:"
202 "/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf",
203 home_dir, home_dir);
204
205 if (NULL == portage_tmp_dir) {
206 strncat(buf, tmp_dir, sizeof(buf));
207 strncat(buf, ":", sizeof(buf));
208 strncat(buf, var_tmp_dir, sizeof(buf));
209 strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
210 } else {
211 strncat(buf, portage_tmp_dir, sizeof(buf));
212 strncat(buf, ":", sizeof(buf));
213 strncat(buf, tmp_dir, sizeof(buf));
214 strncat(buf, ":", sizeof(buf));
215 strncat(buf, var_tmp_dir, sizeof(buf));
216 strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
217 }
218 buf[sizeof(buf) - 1] = '\0';
219 setenv(ENV_SANDBOX_WRITE, buf, 1);
220 }
221}
222
223void setenv_sandbox_predict(char *home_dir)
224{
225 char buf[1024];
226
227 memset(buf, 0, sizeof(buf));
228
229 if (!getenv(ENV_SANDBOX_PREDICT)) {
230 /* these should go into make.globals later on */
231 snprintf(buf, sizeof(buf), "%s/.:"
232 "/usr/lib/python2.0/:"
233 "/usr/lib/python2.1/:"
234 "/usr/lib/python2.2/:"
235 "/usr/lib/python2.3/:"
236 "/usr/lib/python2.4/:"
237 "/usr/lib/python2.5/:"
238 "/usr/lib/python3.0/:",
239 home_dir);
240
241 buf[sizeof(buf) - 1] = '\0';
242 setenv(ENV_SANDBOX_PREDICT, buf, 1);
243 }
244}
245
246int print_sandbox_log(char *sandbox_log) 175int print_sandbox_log(char *sandbox_log)
247{ 176{
248 int sandbox_log_file = -1; 177 int sandbox_log_file = -1;
249 char *beep_count_env = NULL; 178 char *beep_count_env = NULL;
250 int i, color, beep_count = 0; 179 int i, color, beep_count = 0;
290 fputc('\a', stderr); 219 fputc('\a', stderr);
291 if (i < beep_count - 1) 220 if (i < beep_count - 1)
292 sleep(1); 221 sleep(1);
293 } 222 }
294 return 1; 223 return 1;
224}
225
226void stop(int signum)
227{
228 if (stop_called == 0) {
229 stop_called = 1;
230 printf("Caught signal %d in pid %d\r\n", signum, getpid());
231 cleanup();
232 } else {
233 fprintf(stderr, "Pid %d alreadly caught signal and is still cleaning up\n", getpid());
234 }
235}
236
237void setenv_sandbox_write(char *home_dir, char *portage_tmp_dir, char *var_tmp_dir, char *tmp_dir)
238{
239 char buf[1024];
240
241 /* bzero out entire buffer then append trailing 0 */
242 memset(buf, 0, sizeof(buf));
243
244 if (!getenv(ENV_SANDBOX_WRITE)) {
245 /* these could go into make.globals later on */
246 snprintf(buf, sizeof(buf),
247 "%s:%s/.gconfd/lock:%s/.bash_history:",
248 "/dev/zero:/dev/fd/:/dev/null:/dev/pts/:"
249 "/dev/vc/:/dev/pty:/dev/tty:/tmp/:"
250 "/dev/shm/ngpt:/var/log/scrollkeeper.log:"
251 "/usr/tmp/conftest:/usr/lib/conftest:"
252 "/usr/lib32/conftest:/usr/lib64/conftest:"
253 "/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf",
254 home_dir, home_dir);
255
256 if (NULL == portage_tmp_dir) {
257 strncat(buf, tmp_dir, sizeof(buf));
258 strncat(buf, ":", sizeof(buf));
259 strncat(buf, var_tmp_dir, sizeof(buf));
260 strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
261 } else {
262 strncat(buf, portage_tmp_dir, sizeof(buf));
263 strncat(buf, ":", sizeof(buf));
264 strncat(buf, tmp_dir, sizeof(buf));
265 strncat(buf, ":", sizeof(buf));
266 strncat(buf, var_tmp_dir, sizeof(buf));
267 strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
268 }
269 buf[sizeof(buf) - 1] = '\0';
270 setenv(ENV_SANDBOX_WRITE, buf, 1);
271 }
272}
273
274void setenv_sandbox_predict(char *home_dir)
275{
276 char buf[1024];
277
278 memset(buf, 0, sizeof(buf));
279
280 if (!getenv(ENV_SANDBOX_PREDICT)) {
281 /* these should go into make.globals later on */
282 snprintf(buf, sizeof(buf), "%s/.:"
283 "/usr/lib/python2.0/:"
284 "/usr/lib/python2.1/:"
285 "/usr/lib/python2.2/:"
286 "/usr/lib/python2.3/:"
287 "/usr/lib/python2.4/:"
288 "/usr/lib/python2.5/:"
289 "/usr/lib/python3.0/:",
290 home_dir);
291
292 buf[sizeof(buf) - 1] = '\0';
293 setenv(ENV_SANDBOX_PREDICT, buf, 1);
294 }
295} 295}
296 296
297int spawn_shell(char *argv_bash[]) 297int spawn_shell(char *argv_bash[])
298{ 298{
299 int pid; 299 int pid;

Legend:
Removed from v.87  
changed lines
  Added in v.88

  ViewVC Help
Powered by ViewVC 1.1.20