/[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 159 Revision 165
42static int print_debug = 0; 42static int print_debug = 0;
43static int stop_called = 0; 43static int stop_called = 0;
44 44
45int sandbox_setup(struct sandbox_info_t *sandbox_info) 45int sandbox_setup(struct sandbox_info_t *sandbox_info)
46{ 46{
47 char *workdir;
48
49 if (NULL != getenv(ENV_EBUILD)) { 47 if (NULL != getenv(ENV_PORTAGE_TMPDIR)) {
50 workdir = getenv(ENV_PORTAGE_TMPDIR) ? 48 /* Portage handle setting SANDBOX_WRITE itself. */
51 getenv(ENV_PORTAGE_TMPDIR) : 49 sandbox_info->work_dir[0] = '\0';
52 PORTAGE_TMPDIR;
53 /* Do not resolve symlinks, etc .. libsandbox will handle that. */
54 if (1 != is_dir(workdir, 1)) {
55 perror("sandbox: Failed to get " ENV_PORTAGE_TMPDIR);
56 return -1;
57 }
58 snprintf(sandbox_info->work_dir, SB_PATH_MAX, "%s", workdir);
59 setenv(ENV_PORTAGE_TMPDIR, sandbox_info->work_dir, 1);
60 } else { 50 } else {
61 if (NULL == getcwd(sandbox_info->work_dir, SB_PATH_MAX)) { 51 if (NULL == getcwd(sandbox_info->work_dir, SB_PATH_MAX)) {
62 perror("sandbox: Failed to get current directory"); 52 perror("sandbox: Failed to get current directory");
63 return -1; 53 return -1;
64 } 54 }
190 "/dev/shm/ngpt:/var/log/scrollkeeper.log:" 180 "/dev/shm/ngpt:/var/log/scrollkeeper.log:"
191 "/usr/tmp/conftest:/usr/lib/conftest:" 181 "/usr/tmp/conftest:/usr/lib/conftest:"
192 "/usr/lib32/conftest:/usr/lib64/conftest:" 182 "/usr/lib32/conftest:/usr/lib64/conftest:"
193 "/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf", 183 "/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf",
194 sandbox_info->home_dir, sandbox_info->home_dir, 184 sandbox_info->home_dir, sandbox_info->home_dir,
195 sandbox_info->work_dir, 185 sandbox_info->work_dir[0] != '\0' ? sandbox_info->work_dir
186 : "",
196 sandbox_info->tmp_dir, sandbox_info->var_tmp_dir, 187 sandbox_info->tmp_dir, sandbox_info->var_tmp_dir,
197 "/tmp/:/var/tmp/"); 188 "/tmp/:/var/tmp/");
198 if (SB_BUF_LEN <= retval) { 189 if (SB_BUF_LEN <= retval) {
199 errno = EMSGSIZE; 190 errno = EMSGSIZE;
200 perror("sandbox: Failed to generate SANDBOX_WRITE"); 191 perror("sandbox: Failed to generate SANDBOX_WRITE");
475 if (NULL == sandbox_environ) { 466 if (NULL == sandbox_environ) {
476 perror("sandbox: Out of memory (environ)"); 467 perror("sandbox: Out of memory (environ)");
477 exit(EXIT_FAILURE); 468 exit(EXIT_FAILURE);
478 } 469 }
479 470
480 /* if the portage temp dir was present, cd into it */ 471 /* If not in portage, cd into it work directory */
481 if (NULL != sandbox_info.work_dir) 472 if ('\0' != sandbox_info.work_dir[0])
482 chdir(sandbox_info.work_dir); 473 chdir(sandbox_info.work_dir);
483 474
484 argv_bash = (char **)malloc(6 * sizeof(char *)); 475 argv_bash = (char **)malloc(6 * sizeof(char *));
485 argv_bash[0] = strdup("/bin/bash"); 476 argv_bash[0] = strdup("/bin/bash");
486 argv_bash[1] = strdup("-rcfile"); 477 argv_bash[1] = strdup("-rcfile");

Legend:
Removed from v.159  
changed lines
  Added in v.165

  ViewVC Help
Powered by ViewVC 1.1.20