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

Contents of /trunk/src/sandbox.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (show annotations) (download) (as text)
Sun Jul 9 20:33:52 2006 UTC (8 years, 1 month ago) by azarah
File MIME type: text/x-csrc
File size: 18988 byte(s)
Remove file_length(), and rather use rc_get_size().

1 /*
2 ** Path sandbox for the gentoo linux portage package system, initially
3 ** based on the ROCK Linux Wrapper for getting a list of created files
4 **
5 ** to integrate with bash, bash should have been built like this
6 **
7 ** ./configure --prefix=<prefix> --host=<host> --without-gnu-malloc
8 **
9 ** it's very important that the --enable-static-link option is NOT specified
10 **
11 ** Copyright (C) 2001 Geert Bevin, Uwyn, http://www.uwyn.com
12 ** Distributed under the terms of the GNU General Public License, v2 or later
13 ** Author : Geert Bevin <gbevin@uwyn.com>
14 ** $Header$
15 */
16
17 /* #define _GNU_SOURCE */
18
19 #include <errno.h>
20 #include <signal.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <limits.h>
24 #include <string.h>
25 #include <sys/wait.h>
26 #include <signal.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29
30 #include "sbutil.h"
31
32 struct sandbox_info_t {
33 char sandbox_log[SB_PATH_MAX];
34 char sandbox_debug_log[SB_PATH_MAX];
35 char sandbox_lib[SB_PATH_MAX];
36 char sandbox_rc[SB_PATH_MAX];
37 char work_dir[SB_PATH_MAX];
38 char var_tmp_dir[SB_PATH_MAX];
39 char tmp_dir[SB_PATH_MAX];
40 char *home_dir;
41 } sandbox_info_t;
42
43 static int print_debug = 0;
44
45 volatile static int stop_called = 0;
46 volatile static pid_t child_pid = 0;
47
48 static char log_domain[] = "sandbox";
49
50 extern char **environ;
51
52 int sandbox_setup(struct sandbox_info_t *sandbox_info, bool interactive)
53 {
54 if (NULL != getenv(ENV_PORTAGE_TMPDIR)) {
55 /* Portage handle setting SANDBOX_WRITE itself. */
56 sandbox_info->work_dir[0] = '\0';
57 } else {
58 if (NULL == getcwd(sandbox_info->work_dir, SB_PATH_MAX)) {
59 perror("sandbox: Failed to get current directory");
60 return -1;
61 }
62 if (interactive)
63 setenv(ENV_SANDBOX_WORKDIR, sandbox_info->work_dir, 1);
64 }
65
66 /* Do not resolve symlinks, etc .. libsandbox will handle that. */
67 if (!rc_is_dir(VAR_TMPDIR, TRUE)) {
68 perror("sandbox: Failed to get var_tmp_dir");
69 return -1;
70 }
71 snprintf(sandbox_info->var_tmp_dir, SB_PATH_MAX, "%s", VAR_TMPDIR);
72
73 if (-1 == get_tmp_dir(sandbox_info->tmp_dir)) {
74 perror("sandbox: Failed to get tmp_dir");
75 return -1;
76 }
77 setenv(ENV_TMPDIR, sandbox_info->tmp_dir, 1);
78
79 sandbox_info->home_dir = getenv("HOME");
80 if (!sandbox_info->home_dir) {
81 sandbox_info->home_dir = sandbox_info->tmp_dir;
82 setenv("HOME", sandbox_info->home_dir, 1);
83 }
84
85 /* Generate sandbox lib path */
86 get_sandbox_lib(sandbox_info->sandbox_lib);
87
88 /* Generate sandbox bashrc path */
89 get_sandbox_rc(sandbox_info->sandbox_rc);
90
91 /* Generate sandbox log full path */
92 get_sandbox_log(sandbox_info->sandbox_log);
93 if (rc_file_exists(sandbox_info->sandbox_log)) {
94 if (-1 == unlink(sandbox_info->sandbox_log)) {
95 perror("sandbox: Could not unlink old log file");
96 return -1;
97 }
98 }
99
100 /* Generate sandbox debug log full path */
101 get_sandbox_debug_log(sandbox_info->sandbox_debug_log);
102 if (rc_file_exists(sandbox_info->sandbox_debug_log)) {
103 if (-1 == unlink(sandbox_info->sandbox_debug_log)) {
104 perror("sandbox: Could not unlink old debug log file");
105 return -1;
106 }
107 }
108
109 return 0;
110 }
111
112 int print_sandbox_log(char *sandbox_log)
113 {
114 int sandbox_log_file = -1;
115 char *beep_count_env = NULL;
116 int i, color, beep_count = 0;
117 off_t len = 0;
118 char *buffer = NULL;
119
120 if (!rc_is_file(sandbox_log, FALSE)) {
121 perror("sandbox: Log file is not a regular file");
122 return 0;
123 }
124
125 sandbox_log_file = open(sandbox_log, O_RDONLY);
126 if (-1 == sandbox_log_file) {
127 perror("sandbox: Could not open Log file");
128 return 0;
129 }
130
131 len = rc_get_size(sandbox_log, TRUE);
132 buffer = (char *)xmalloc((len + 1) * sizeof(char));
133 memset(buffer, 0, len + 1);
134 read(sandbox_log_file, buffer, len);
135 close(sandbox_log_file);
136
137 color = ((is_env_on(ENV_NOCOLOR)) ? 0 : 1);
138
139 SB_EERROR(color,
140 "--------------------------- ACCESS VIOLATION SUMMARY ---------------------------",
141 "\n");
142 SB_EERROR(color, "LOG FILE = \"%s\"", "\n\n", sandbox_log);
143 fprintf(stderr, "%s", buffer);
144 if (NULL != buffer)
145 free(buffer);
146 SB_EERROR(color,
147 "--------------------------------------------------------------------------------",
148 "\n");
149
150 beep_count_env = getenv(ENV_SANDBOX_BEEP);
151 if (beep_count_env)
152 beep_count = atoi(beep_count_env);
153 else
154 beep_count = DEFAULT_BEEP_COUNT;
155
156 for (i = 0; i < beep_count; i++) {
157 fputc('\a', stderr);
158 if (i < beep_count - 1)
159 sleep(1);
160 }
161
162 return 1;
163 }
164
165 void stop(int signum)
166 {
167 if (0 == stop_called) {
168 stop_called = 1;
169 printf("sandbox: Caught signal %d in pid %d\n",
170 signum, getpid());
171 } else {
172 fprintf(stderr,
173 "sandbox: Signal already caught and busy still cleaning up!\n");
174 }
175 }
176
177 void usr1_handler(int signum, siginfo_t *siginfo, void *ucontext)
178 {
179 if (0 == stop_called) {
180 stop_called = 1;
181 printf("sandbox: Caught signal %d in pid %d\n",
182 signum, getpid());
183
184 /* FIXME: This is really bad form, as we should kill the whole process
185 * tree, but currently that is too much work and not worth the
186 * effort. Thus we only kill the calling process and our child
187 * for now.
188 */
189 if (siginfo->si_pid > 0)
190 kill(siginfo->si_pid, SIGKILL);
191 kill(child_pid, SIGKILL);
192 } else {
193 fprintf(stderr,
194 "sandbox: Signal already caught and busy still cleaning up!\n");
195 }
196 }
197
198 char *sandbox_subst_env_vars(dyn_buf_t *env_data)
199 {
200 dyn_buf_t *new_data = NULL;
201 char *tmp_ptr, *tmp_data = NULL;
202 char *var_start, *var_stop;
203
204 new_data = new_dyn_buf();
205 if (NULL == new_data)
206 return NULL;
207
208 tmp_data = read_line_dyn_buf(env_data);
209 if (NULL == tmp_data)
210 goto error;
211 tmp_ptr = tmp_data;
212
213 while (NULL != (var_start = strchr(tmp_ptr, '$'))) {
214 char *env = NULL;
215
216 var_stop = strchr(var_start, '}');
217
218 /* We only support ${} style env var names, so just skip any
219 * '$' that do not follow this syntax */
220 if (('{' != var_start[1]) || (NULL == var_stop)) {
221 tmp_ptr = var_start + 1;
222 continue;
223 }
224
225 /* Terminate part before env string so that we can copy it */
226 var_start[0] = '\0';
227 /* Move var_start past '${' */
228 var_start += 2;
229 /* Terminate the name of the env var */
230 var_stop[0] = '\0';
231
232 if (strlen(var_start) > 0)
233 env = getenv(var_start);
234 if (-1 == sprintf_dyn_buf(new_data, "%s%s",
235 tmp_ptr ? tmp_ptr : "",
236 env ? env : ""))
237 goto error;
238
239 /* Move tmp_ptr past the '}' of the env var */
240 tmp_ptr = var_stop + 1;
241 }
242
243 if (0 != strlen(tmp_ptr))
244 if (-1 == write_dyn_buf(new_data, tmp_ptr, strlen(tmp_ptr)))
245 goto error;
246
247 free(tmp_data);
248
249 tmp_data = read_line_dyn_buf(new_data);
250 if (NULL == tmp_data)
251 goto error;
252
253 free_dyn_buf(new_data);
254
255 return tmp_data;
256
257 error:
258 if (NULL != new_data)
259 free_dyn_buf(new_data);
260 if (NULL != tmp_data)
261 free(tmp_data);
262
263 return NULL;
264 }
265
266 void sandbox_set_env_var(const char *env_var)
267 {
268 char *config;
269
270 /* We check if the variable is set in the environment, and if not, we
271 * get it from sandbox.conf, and if they exist, we just add them to the
272 * environment if not already present. */
273 config = rc_get_cnf_entry(SANDBOX_CONF_FILE, env_var, NULL);
274 if (NULL != config) {
275 setenv(ENV_SANDBOX_VERBOSE, config, 0);
276 free(config);
277 }
278 }
279
280 int sandbox_set_env_access_var(const char *access_var)
281 {
282 dyn_buf_t *env_data = NULL;
283 int count = 0;
284 char *config = NULL;
285 char **confd_files = NULL;
286 bool use_confd = TRUE;
287
288 env_data = new_dyn_buf();
289 if (NULL == env_data)
290 return -1;
291
292 /* Now get the defaults for the access variable from sandbox.conf.
293 * These do not get overridden via the environment. */
294 config = rc_get_cnf_entry(SANDBOX_CONF_FILE, access_var, ":");
295 if (NULL != config) {
296 if (-1 == write_dyn_buf(env_data, config, strlen(config)))
297 goto error;
298 free(config);
299 config = NULL;
300 }
301 /* Append whatever might be already set. If anything is set, we do
302 * not process the sandbox.d/ files for this variable. */
303 if (NULL != getenv(access_var)) {
304 use_confd = FALSE;
305 if (-1 == sprintf_dyn_buf(env_data, env_data->wr_index ? ":%s" : "%s",
306 getenv(access_var)))
307 goto error;
308 }
309
310 if (!use_confd)
311 goto done;
312
313 /* Now scan the files in sandbox.d/ if the access variable was not
314 * alreay set. */
315 confd_files = rc_ls_dir(SANDBOX_CONFD_DIR, FALSE, TRUE);
316 if (NULL != confd_files) {
317 while (NULL != confd_files[count]) {
318 config = rc_get_cnf_entry(confd_files[count], access_var, ":");
319 if (NULL != config) {
320 if (-1 == sprintf_dyn_buf(env_data,
321 env_data->wr_index ? ":%s" : "%s",
322 config))
323 goto error;
324 free(config);
325 config = NULL;
326 }
327 count++;
328 }
329
330 str_list_free(confd_files);
331 }
332
333 done:
334 if (env_data->wr_index > 0) {
335 char *subst;
336
337 subst = sandbox_subst_env_vars(env_data);
338 if (NULL == subst)
339 goto error;
340
341 setenv(access_var, subst, 1);
342 free(subst);
343 }
344
345 free_dyn_buf(env_data);
346
347 return 0;
348
349 error:
350 if (NULL != env_data)
351 free_dyn_buf(env_data);
352 if (NULL != config)
353 free(config);
354 if (NULL != confd_files)
355 str_list_free(confd_files);
356
357 return -1;
358 }
359
360 int sandbox_setup_env_config(struct sandbox_info_t *sandbox_info)
361 {
362 sandbox_set_env_var(ENV_SANDBOX_VERBOSE);
363 sandbox_set_env_var(ENV_SANDBOX_DEBUG);
364 sandbox_set_env_var(ENV_SANDBOX_BEEP);
365 sandbox_set_env_var(ENV_NOCOLOR);
366
367 if (-1 == sandbox_set_env_access_var(ENV_SANDBOX_DENY))
368 return -1;
369 if (NULL == getenv(ENV_SANDBOX_DENY))
370 setenv(ENV_SANDBOX_DENY, LD_PRELOAD_FILE, 1);
371
372 if (-1 == sandbox_set_env_access_var(ENV_SANDBOX_READ))
373 return -1;
374 if (NULL == getenv(ENV_SANDBOX_READ))
375 setenv(ENV_SANDBOX_READ, "/", 1);
376
377 if (-1 == sandbox_set_env_access_var(ENV_SANDBOX_WRITE))
378 return -1;
379 if ((NULL == getenv(ENV_SANDBOX_WRITE)) &&
380 (NULL != sandbox_info->work_dir))
381 setenv(ENV_SANDBOX_WRITE, sandbox_info->work_dir, 1);
382
383 if (-1 == sandbox_set_env_access_var(ENV_SANDBOX_PREDICT))
384 return -1;
385 if ((NULL == getenv(ENV_SANDBOX_PREDICT)) &&
386 (NULL != sandbox_info->home_dir))
387 setenv(ENV_SANDBOX_PREDICT, sandbox_info->home_dir, 1);
388
389 return 0;
390 }
391
392 int sandbox_setenv(char ***envp, const char *name, const char *val) {
393 char *tmp_string = NULL;
394
395 /* strlen(name) + strlen(val) + '=' + '\0' */
396 tmp_string = xmalloc((strlen(name) + strlen(val) + 2) * sizeof(char));
397 if (NULL == tmp_string)
398 goto error;
399
400 snprintf(tmp_string, strlen(name) + strlen(val) + 2,
401 "%s=%s", name, val);
402
403 str_list_add_item((*envp), tmp_string, error);
404
405 return 0;
406
407 error:
408 perror("sandbox: Out of memory (sandbox_setenv)");
409 exit(EXIT_FAILURE);
410 }
411
412 /* We setup the environment child side only to prevent issues with
413 * setting LD_PRELOAD parent side */
414 char **sandbox_setup_environ(struct sandbox_info_t *sandbox_info, bool interactive)
415 {
416 int have_ld_preload = 0;
417
418 char **new_environ = NULL;
419 char **env_ptr;
420 char *ld_preload_envvar = NULL;
421 char *orig_ld_preload_envvar = NULL;
422 char sb_pid[64];
423
424 if (-1 == sandbox_setup_env_config(sandbox_info))
425 return NULL;
426
427 /* Unset these, as its easier than replacing when setting up our
428 * new environment below */
429 unsetenv(ENV_SANDBOX_ON);
430 unsetenv(ENV_SANDBOX_PID);
431 unsetenv(ENV_SANDBOX_LIB);
432 unsetenv(ENV_SANDBOX_BASHRC);
433 unsetenv(ENV_SANDBOX_LOG);
434 unsetenv(ENV_SANDBOX_DEBUG_LOG);
435 unsetenv(ENV_SANDBOX_WORKDIR);
436 unsetenv(ENV_SANDBOX_ACTIVE);
437 unsetenv(ENV_SANDBOX_INTRACTV);
438 unsetenv(ENV_BASH_ENV);
439
440 if (NULL != getenv(ENV_LD_PRELOAD)) {
441 have_ld_preload = 1;
442 orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD);
443
444 ld_preload_envvar = xcalloc(strlen(orig_ld_preload_envvar) +
445 strlen(sandbox_info->sandbox_lib) + 2,
446 sizeof(char));
447 if (NULL == ld_preload_envvar)
448 return NULL;
449 snprintf(ld_preload_envvar, strlen(orig_ld_preload_envvar) +
450 strlen(sandbox_info->sandbox_lib) + 2, "%s %s",
451 sandbox_info->sandbox_lib, orig_ld_preload_envvar);
452 } else {
453 ld_preload_envvar = rc_strndup(sandbox_info->sandbox_lib,
454 strlen(sandbox_info->sandbox_lib));
455 if (NULL == ld_preload_envvar)
456 return NULL;
457 }
458 /* Do not unset this, as strange things might happen */
459 /* unsetenv(ENV_LD_PRELOAD); */
460
461 snprintf(sb_pid, sizeof(sb_pid), "%i", getpid());
462
463 /* First add our new variables to the beginning - this is due to some
464 * weirdness that I cannot remember */
465 sandbox_setenv(&new_environ, ENV_SANDBOX_ON, "1");
466 sandbox_setenv(&new_environ, ENV_SANDBOX_PID, sb_pid);
467 sandbox_setenv(&new_environ, ENV_SANDBOX_LIB, sandbox_info->sandbox_lib);
468 sandbox_setenv(&new_environ, ENV_SANDBOX_BASHRC, sandbox_info->sandbox_rc);
469 sandbox_setenv(&new_environ, ENV_SANDBOX_LOG, sandbox_info->sandbox_log);
470 sandbox_setenv(&new_environ, ENV_SANDBOX_DEBUG_LOG,
471 sandbox_info->sandbox_debug_log);
472 /* Is this an interactive session? */
473 if (interactive)
474 sandbox_setenv(&new_environ, ENV_SANDBOX_INTRACTV, "1");
475 /* Just set the these if not already set so that is_env_on() work */
476 if (!getenv(ENV_SANDBOX_VERBOSE))
477 sandbox_setenv(&new_environ, ENV_SANDBOX_VERBOSE, "1");
478 if (!getenv(ENV_SANDBOX_DEBUG))
479 sandbox_setenv(&new_environ, ENV_SANDBOX_DEBUG, "0");
480 if (!getenv(ENV_NOCOLOR))
481 sandbox_setenv(&new_environ, ENV_NOCOLOR, "no");
482 /* If LD_PRELOAD was not set, set it here, else do it below */
483 if (1 != have_ld_preload)
484 sandbox_setenv(&new_environ, ENV_LD_PRELOAD, ld_preload_envvar);
485
486 /* Make sure our bashrc gets preference */
487 sandbox_setenv(&new_environ, ENV_BASH_ENV, sandbox_info->sandbox_rc);
488
489 /* This one should NEVER be set in ebuilds, as it is the one
490 * private thing libsandbox.so use to test if the sandbox
491 * should be active for this pid, or not.
492 *
493 * azarah (3 Aug 2002)
494 */
495
496 sandbox_setenv(&new_environ, ENV_SANDBOX_ACTIVE, SANDBOX_ACTIVE);
497
498 /* Now add the rest */
499 env_ptr = environ;
500 while (NULL != *env_ptr) {
501 if ((1 == have_ld_preload) &&
502 (strstr(*env_ptr, LD_PRELOAD_EQ) == *env_ptr))
503 /* If LD_PRELOAD was set, and this is it in the original
504 * environment, replace it with our new copy */
505 /* XXX: The following works as it just add whatever as
506 * the last variable to nev_environ */
507 sandbox_setenv(&new_environ, ENV_LD_PRELOAD,
508 ld_preload_envvar);
509 else
510 str_list_add_item_copy(new_environ, (*env_ptr), error);
511
512 env_ptr++;
513 }
514
515 if (NULL != ld_preload_envvar)
516 free(ld_preload_envvar);
517
518 return new_environ;
519
520 error:
521 if (NULL != new_environ)
522 str_list_free(new_environ);
523 if (NULL != ld_preload_envvar)
524 free(ld_preload_envvar);
525
526 return NULL;
527 }
528
529 int spawn_shell(char *argv_bash[], char **env, int debug)
530 {
531 int status = 0;
532 int ret = 0;
533
534 child_pid = fork();
535
536 /* Child's process */
537 if (0 == child_pid) {
538 execve(argv_bash[0], argv_bash, env);
539 _exit(EXIT_FAILURE);
540 } else if (child_pid < 0) {
541 if (debug)
542 fprintf(stderr, "Process failed to spawn!\n");
543 return 0;
544 }
545
546 /* fork() creates a copy of this, so no need to use more memory than
547 * absolutely needed. */
548 str_list_free(argv_bash);
549 str_list_free(env);
550
551 ret = waitpid(child_pid, &status, 0);
552 if ((-1 == ret) || (status > 0)) {
553 if (debug)
554 fprintf(stderr, "Process returned with failed exit status!\n");
555 return 0;
556 }
557
558 return 1;
559 }
560
561 int main(int argc, char **argv)
562 {
563 struct sigaction act_new;
564
565 int success = 1;
566 int sandbox_log_presence = 0;
567
568 struct sandbox_info_t sandbox_info;
569
570 char **sandbox_environ;
571 char **argv_bash = NULL;
572
573 char *run_str = "-c";
574
575 rc_log_domain(log_domain);
576
577 /* Only print info if called with no arguments .... */
578 if (argc < 2)
579 print_debug = 1;
580
581 if (print_debug)
582 printf("========================== Gentoo linux path sandbox ===========================\n");
583
584 /* check if a sandbox is already running */
585 if (NULL != getenv(ENV_SANDBOX_ACTIVE)) {
586 fprintf(stderr, "Not launching a new sandbox instance\n");
587 fprintf(stderr, "Another one is already running in this process hierarchy.\n");
588 exit(EXIT_FAILURE);
589 }
590
591 /* determine the location of all the sandbox support files */
592 if (print_debug)
593 printf("Detection of the support files.\n");
594
595 if (-1 == sandbox_setup(&sandbox_info, print_debug)) {
596 fprintf(stderr, "sandbox: Failed to setup sandbox.");
597 exit(EXIT_FAILURE);
598 }
599
600 /* verify the existance of required files */
601 if (print_debug)
602 printf("Verification of the required files.\n");
603
604 #ifndef SB_HAVE_MULTILIB
605 if (!rc_file_exists(sandbox_info.sandbox_lib)) {
606 perror("sandbox: Could not open the sandbox library");
607 exit(EXIT_FAILURE);
608 }
609 #endif
610 if (!rc_file_exists(sandbox_info.sandbox_rc)) {
611 perror("sandbox: Could not open the sandbox rc file");
612 exit(EXIT_FAILURE);
613 }
614
615 /* set up the required environment variables */
616 if (print_debug)
617 printf("Setting up the required environment variables.\n");
618
619 /* If not in portage, cd into it work directory */
620 if ('\0' != sandbox_info.work_dir[0])
621 chdir(sandbox_info.work_dir);
622
623 /* Setup bash argv */
624 str_list_add_item_copy(argv_bash, "/bin/bash", oom_error);
625 str_list_add_item_copy(argv_bash, "-rcfile", oom_error);
626 str_list_add_item_copy(argv_bash, sandbox_info.sandbox_rc, oom_error);
627 if (argc >= 2) {
628 int i;
629
630 str_list_add_item_copy(argv_bash, run_str, oom_error);
631 str_list_add_item_copy(argv_bash, argv[1], oom_error);
632 for (i = 2; i < argc; i++) {
633 char *tmp_ptr;
634
635 tmp_ptr = xrealloc(argv_bash[4],
636 (strlen(argv_bash[4]) +
637 strlen(argv[i]) + 2) *
638 sizeof(char));
639 if (NULL == tmp_ptr)
640 goto oom_error;
641
642 snprintf(argv_bash[4] + strlen(argv_bash[4]),
643 strlen(argv[i]) + 2, " %s",
644 argv[i]);
645 }
646 }
647
648 /* Setup the child environment stuff.
649 * XXX: We free this in spawn_shell(). */
650 sandbox_environ = sandbox_setup_environ(&sandbox_info, print_debug);
651 if (NULL == sandbox_environ)
652 goto oom_error;
653
654 /* set up the required signal handlers */
655 signal(SIGHUP, &stop);
656 signal(SIGINT, &stop);
657 signal(SIGQUIT, &stop);
658 signal(SIGTERM, &stop);
659 act_new.sa_sigaction = usr1_handler;
660 sigemptyset (&act_new.sa_mask);
661 act_new.sa_flags = SA_SIGINFO | SA_RESTART;
662 sigaction (SIGUSR1, &act_new, NULL);
663
664 /* STARTING PROTECTED ENVIRONMENT */
665 if (print_debug) {
666 printf("The protected environment has been started.\n");
667 printf("--------------------------------------------------------------------------------\n");
668 }
669
670 if (print_debug)
671 printf("Process being started in forked instance.\n");
672
673 /* Start Bash */
674 if (!spawn_shell(argv_bash, sandbox_environ, print_debug))
675 success = 0;
676
677 /* As spawn_shell() free both argv_bash and sandbox_environ, make sure
678 * we do not run into issues in future if we need a OOM error below
679 * this ... */
680 argv_bash = NULL;
681 sandbox_environ = NULL;
682
683 if (print_debug)
684 printf("Cleaning up sandbox process\n");
685
686 if (print_debug) {
687 printf("========================== Gentoo linux path sandbox ===========================\n");
688 printf("The protected environment has been shut down.\n");
689 }
690
691 if (rc_file_exists(sandbox_info.sandbox_log)) {
692 sandbox_log_presence = 1;
693 print_sandbox_log(sandbox_info.sandbox_log);
694 } else if (print_debug) {
695 printf("--------------------------------------------------------------------------------\n");
696 }
697
698 if ((sandbox_log_presence) || (!success))
699 return 1;
700 else
701 return 0;
702
703 oom_error:
704 if (NULL != argv_bash)
705 str_list_free(argv_bash);
706
707 perror("sandbox: Out of memory (environ)");
708 exit(EXIT_FAILURE);
709 }
710
711 // 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