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

Diff of /trunk/src/sandbox.c

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

Revision 34 Revision 35
461#endif 461#endif
462} 462}
463 463
464int main(int argc, char **argv) 464int main(int argc, char **argv)
465{ 465{
466 int i = 0, success = 1; 466 int ret = 0, i = 0, success = 1;
467#ifdef USE_LD_SO_PRELOAD 467#ifdef USE_LD_SO_PRELOAD
468 int preload_file = -1; 468 int preload_file = -1;
469#endif 469#endif
470 int sandbox_log_presence = 0; 470 int sandbox_log_presence = 0;
471 int sandbox_log_file = -1; 471 int sandbox_log_file = -1;
638 free(tmp_string); 638 free(tmp_string);
639 tmp_string = NULL; 639 tmp_string = NULL;
640 640
641 setenv(ENV_SANDBOX_LOG, sandbox_log, 1); 641 setenv(ENV_SANDBOX_LOG, sandbox_log, 1);
642 642
643 sprintf(pid_string, "%d", getpid());
643 snprintf(sandbox_debug_log, sizeof(sandbox_debug_log), "%s%s%s", 644 snprintf(sandbox_debug_log, sizeof(sandbox_debug_log), "%s%s%s",
644 DEBUG_LOG_FILE_PREFIX, pid_string, LOG_FILE_EXT); 645 DEBUG_LOG_FILE_PREFIX, pid_string, LOG_FILE_EXT);
645 setenv(ENV_SANDBOX_DEBUG_LOG, sandbox_debug_log, 1); 646 setenv(ENV_SANDBOX_DEBUG_LOG, sandbox_debug_log, 1);
646 647
647 home_dir = getenv("HOME"); 648 home_dir = getenv("HOME");
648 if (!home_dir) { 649 if (!home_dir) {
649 home_dir = "/tmp"; 650 home_dir = "/tmp";
650 setenv("HOME", home_dir, 1); 651 setenv("HOME", home_dir, 1);
651 } 652 }
652 653
653 /* drobbins: we need to expand these paths using realpath() so that PORTAGE_TMPDIR 654 if (NULL == realpath(getenv("PORTAGE_TMPDIR") ? getenv("PORTAGE_TMPDIR")
654 * can contain symlinks (example, /var is a symlink, /var/tmp is a symlink.) Without 655 : "/var/tmp/portage",
655 * this, access is denied to /var/tmp, hurtin' ebuilds. 656 portage_tmp_dir)) {
656 */ 657 perror(">>> get portage_tmp_dir");
657 658 exit(1);
658 {
659 char *e;
660 e = getenv("PORTAGE_TMPDIR");
661 if (e && (strlen(e) < sizeof(portage_tmp_dir) - 1) && (strlen(e) > 1))
662 realpath(e, portage_tmp_dir);
663
664 } 659 }
665 realpath("/var/tmp", var_tmp_dir); 660 if (NULL == realpath("/var/tmp", var_tmp_dir)) {
661 perror(">>> get var_tmp_dir");
662 exit(1);
663 }
666 realpath("/tmp", tmp_dir); 664 if (NULL == realpath("/tmp", tmp_dir)) {
665 perror(">>> get tmp_dir");
666 exit(1);
667 }
667 668
668 setenv(ENV_SANDBOX_DIR, sandbox_dir, 1); 669 setenv(ENV_SANDBOX_DIR, sandbox_dir, 1);
669 setenv(ENV_SANDBOX_LIB, sandbox_lib, 1); 670 setenv(ENV_SANDBOX_LIB, sandbox_lib, 1);
670 setenv("LD_PRELOAD", sandbox_lib, 1); 671 setenv("LD_PRELOAD", sandbox_lib, 1);
671 672
828 sandbox_log_file = -1; 829 sandbox_log_file = -1;
829 } else if (print_debug) { 830 } else if (print_debug) {
830 printf("--------------------------------------------------------------------------------\n"); 831 printf("--------------------------------------------------------------------------------\n");
831 } 832 }
832 833
834 free(sandbox_pids_file);
835
833 if ((sandbox_log_presence) || (!success)) 836 if ((sandbox_log_presence) || (!success))
834 return 1; 837 return 1;
835 else 838 else
836 return 0; 839 return 0;
837 } 840 }

Legend:
Removed from v.34  
changed lines
  Added in v.35

  ViewVC Help
Powered by ViewVC 1.1.20