aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicholas Jones <carpaski@gentoo.org>2004-10-10 10:07:21 +0000
committerNicholas Jones <carpaski@gentoo.org>2004-10-10 10:07:21 +0000
commit94b584e2642672ea8ca8b8b78b4d32c1f57c4aff (patch)
tree313d3ddeac15c1192575c96f4fbe62bab968f15f /src
parentupdate info about --prune to reflect the broken behavior it exhibits (diff)
downloadportage-cvs-94b584e2642672ea8ca8b8b78b4d32c1f57c4aff.tar.gz
portage-cvs-94b584e2642672ea8ca8b8b78b4d32c1f57c4aff.tar.bz2
portage-cvs-94b584e2642672ea8ca8b8b78b4d32c1f57c4aff.zip
_rc8, basically.
Lots of little cleanups. Solar's patch for sandbox. Spanky's patches on various outstanding bugs.
Diffstat (limited to 'src')
-rw-r--r--src/sandbox-1.1/libsandbox.c6
-rw-r--r--src/sandbox-1.1/sandbox.c186
-rw-r--r--src/sandbox-1.1/sandbox_futils.c30
3 files changed, 86 insertions, 136 deletions
diff --git a/src/sandbox-1.1/libsandbox.c b/src/sandbox-1.1/libsandbox.c
index 77f64bd..34aeb1c 100644
--- a/src/sandbox-1.1/libsandbox.c
+++ b/src/sandbox-1.1/libsandbox.c
@@ -25,7 +25,7 @@
* as some of the InstallWatch code was used.
*
*
- * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/libsandbox.c,v 1.21 2004/08/02 18:49:31 carpaski Exp $
+ * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/libsandbox.c,v 1.22 2004/10/10 10:07:21 carpaski Exp $
*
*/
@@ -260,14 +260,14 @@ _init(void)
/* Get the path and name to this library */
tmp_string = get_sandbox_lib("/");
- strncpy(sandbox_lib, tmp_string, 254);
+ strncpy(sandbox_lib, tmp_string, sizeof(sandbox_lib)-1);
if (tmp_string)
free(tmp_string);
tmp_string = NULL;
/* Generate sandbox pids-file path */
tmp_string = get_sandbox_pids_file();
- strncpy(sandbox_pids_file, tmp_string, 254);
+ strncpy(sandbox_pids_file, tmp_string, sizeof(sandbox_pids_file)-1);
if (tmp_string)
free(tmp_string);
tmp_string = NULL;
diff --git a/src/sandbox-1.1/sandbox.c b/src/sandbox-1.1/sandbox.c
index 9814a7e..c8d6dbb 100644
--- a/src/sandbox-1.1/sandbox.c
+++ b/src/sandbox-1.1/sandbox.c
@@ -11,7 +11,7 @@
** Copyright (C) 2001 Geert Bevin, Uwyn, http://www.uwyn.com
** Distributed under the terms of the GNU General Public License, v2 or later
** Author : Geert Bevin <gbevin@uwyn.com>
-** $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox.c,v 1.18 2004/08/16 08:19:38 carpaski Exp $
+** $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox.c,v 1.19 2004/10/10 10:07:21 carpaski Exp $
*/
/* #define _GNU_SOURCE */
@@ -36,6 +36,7 @@
int preload_adaptable = 1;
int cleaned_up = 0;
int print_debug = 0;
+int stop_called = 0;
/* Read pids file, and load active pids into an array. Return number of pids in array */
int
@@ -170,7 +171,7 @@ cleanup()
/* Generate sandbox pids-file path */
tmp_string = get_sandbox_pids_file();
- strncpy(sandbox_pids_file, tmp_string, 254);
+ strncpy(sandbox_pids_file, tmp_string, sizeof(sandbox_pids_file)-1);
if (tmp_string)
free(tmp_string);
tmp_string = NULL;
@@ -292,116 +293,75 @@ cleanup()
void
stop(int signum)
{
- printf("Caught signal %d\r\n", signum);
+ if (stop_called == 0) {
+ stop_called = 1;
+ printf("Caught signal %d in pid %d\r\n", signum, getpid());
cleanup();
+ } else {
+ fprintf(stderr, "Pid %d alreadly caught signal and is still cleaning up\n", getpid());
+ }
}
void
setenv_sandbox_write(char *home_dir, char *portage_tmp_dir, char *var_tmp_dir,
char *tmp_dir)
{
- char sandbox_write_var[1024];
+ char buf[1024];
+
+ /* bzero out entire buffer then append trailing 0 */
+ memset(buf, 0, sizeof(buf));
if (!getenv(ENV_SANDBOX_WRITE)) {
- /* these should go into make.globals later on */
- strcpy(sandbox_write_var, "");
- strcat(sandbox_write_var,
- "/dev/zero:/dev/fd/:/dev/null:/dev/pts/:/dev/vc/:/dev/tty:/tmp/");
- strcat(sandbox_write_var, ":");
- /* NGPT support */
- strcat(sandbox_write_var, "/dev/shm/ngpt");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/var/log/scrollkeeper.log");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, home_dir);
- strcat(sandbox_write_var, "/.gconfd/lock");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, home_dir);
- strcat(sandbox_write_var, "/.bash_history");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/tmp/conftest");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib/conftest");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib32/conftest");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib64/conftest");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/tmp/cf");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib/cf");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib32/cf");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/usr/lib64/cf");
- strcat(sandbox_write_var, ":");
+ /* these could go into make.globals later on */
+ snprintf(buf, sizeof(buf),
+ "%s:%s/.gconfd/lock:%s/.bash_history:", \
+ "/dev/zero:/dev/fd/:/dev/null:/dev/pts/:" \
+ "/dev/vc/:/dev/tty:/tmp/:" \
+ "/dev/shm/ngpt:/var/log/scrollkeeper.log:" \
+ "/usr/tmp/conftest:/usr/lib/conftest:" \
+ "/usr/lib32/conftest:/usr/lib64/conftest:" \
+ "/usr/tmp/cf:/usr/lib/cf:/usr/lib32/cf:/usr/lib64/cf",
+ home_dir, home_dir);
+
if (NULL == portage_tmp_dir) {
- strcat(sandbox_write_var, tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, var_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/tmp/");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/var/tmp/");
-
- /* How the heck is this possible?? we just set it above! */
- } else if (0 == strcmp(sandbox_write_var, "/var/tmp/")) {
- strcat(sandbox_write_var, portage_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/tmp/");
-
- /* Still don't think this is possible, am I just stupid or something? */
- } else if (0 == strcmp(sandbox_write_var, "/tmp/")) {
- strcat(sandbox_write_var, portage_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, var_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/var/tmp/");
-
- /* Amazing, one I think is possible */
+ strncat(buf, tmp_dir, sizeof(buf));
+ strncat(buf, ":", sizeof(buf));
+ strncat(buf, var_tmp_dir, sizeof(buf));
+ strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
} else {
- strcat(sandbox_write_var, portage_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, var_tmp_dir);
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/tmp/");
- strcat(sandbox_write_var, ":");
- strcat(sandbox_write_var, "/var/tmp/");
+ strncat(buf, portage_tmp_dir, sizeof(buf));
+ strncat(buf, ":", sizeof(buf));
+ strncat(buf, tmp_dir, sizeof(buf));
+ strncat(buf, ":", sizeof(buf));
+ strncat(buf, var_tmp_dir, sizeof(buf));
+ strncat(buf, ":/tmp/:/var/tmp/", sizeof(buf));
}
-
- setenv(ENV_SANDBOX_WRITE, sandbox_write_var, 1);
+ buf[sizeof(buf)] = 0;
+ setenv(ENV_SANDBOX_WRITE, buf, 1);
}
}
void
setenv_sandbox_predict(char *home_dir)
{
- char sandbox_predict_var[1024];
+ char buf[1024];
+
+ memset(buf, 0, sizeof(buf));
if (!getenv(ENV_SANDBOX_PREDICT)) {
/* these should go into make.globals later on */
- strcpy(sandbox_predict_var, "");
- strcat(sandbox_predict_var, home_dir);
- strcat(sandbox_predict_var, "/.");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.0/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.1/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.2/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.3/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.4/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python2.5/");
- strcat(sandbox_predict_var, ":");
- strcat(sandbox_predict_var, "/usr/lib/python3.0/");
- setenv(ENV_SANDBOX_PREDICT, sandbox_predict_var, 1);
+ snprintf(buf, sizeof(buf), "%s/.:" \
+ "/usr/lib/python2.0/:" \
+ "/usr/lib/python2.1/:" \
+ "/usr/lib/python2.2/:" \
+ "/usr/lib/python2.3/:" \
+ "/usr/lib/python2.4/:" \
+ "/usr/lib/python2.5/:" \
+ "/usr/lib/python3.0/:",
+ home_dir);
+
+ buf[sizeof(buf)] = 0;
+ setenv(ENV_SANDBOX_PREDICT, buf, 1);
}
}
@@ -410,7 +370,7 @@ print_sandbox_log(char *sandbox_log)
{
int sandbox_log_file = -1;
char *beep_count_env = NULL;
- int i, beep_count = 0;
+ int i, color, beep_count = 0;
long len = 0;
char *buffer = NULL;
@@ -424,10 +384,15 @@ print_sandbox_log(char *sandbox_log)
read(sandbox_log_file, buffer, len);
file_close(sandbox_log_file);
- printf
- ("\e[31;01m--------------------------- ACCESS VIOLATION SUMMARY ---------------------------\033[0m\n");
- printf("\e[31;01mLOG FILE = \"%s\"\033[0m\n", sandbox_log);
- printf("\n");
+ color = ( (getenv("NOCOLOR") != NULL) ? 0 : 1);
+
+ if (color) printf("\e[31;01m");
+ printf("--------------------------- ACCESS VIOLATION SUMMARY ---------------------------");
+ if (color) printf("\033[0m");
+ if (color) printf("\e[31;01m");
+ printf("\nLOG FILE = \"%s\"", sandbox_log);
+ if (color) printf("\033[0m");
+ printf("\n\n");
printf("%s", buffer);
if (buffer)
free(buffer);
@@ -716,7 +681,12 @@ main(int argc, char **argv)
* this, access is denied to /var/tmp, hurtin' ebuilds.
*/
- realpath(getenv("PORTAGE_TMPDIR"), portage_tmp_dir);
+ { char *e;
+ e = getenv("PORTAGE_TMPDIR");
+ if ( e && ( strlen(e) < sizeof(portage_tmp_dir)-1 ) && (strlen(e) > 1) )
+ realpath(e, portage_tmp_dir);
+
+ }
realpath("/var/tmp", var_tmp_dir);
realpath("/tmp", tmp_dir);
@@ -772,28 +742,6 @@ main(int argc, char **argv)
strcat(argv_bash[4], argv[i]);
}
}
-#if 0
- char *argv_bash[] = {
- "/bin/bash",
- "-rcfile",
- NULL,
- NULL,
- NULL,
- NULL
- };
-
- /* adding additional bash arguments */
- for (i = 1; i < argc; i++) {
- if (1 == i) {
- argv_bash[3] = run_str;
- argv_bash[4] = run_arg;
- strcpy(argv_bash[4], argv[i]);
- } else {
- strcat(argv_bash[4], " ");
- strcat(argv_bash[4], argv[i]);
- }
- }
-#endif
/* set up the required signal handlers */
signal(SIGHUP, &stop);
diff --git a/src/sandbox-1.1/sandbox_futils.c b/src/sandbox-1.1/sandbox_futils.c
index f3bf2b5..a254e1b 100644
--- a/src/sandbox-1.1/sandbox_futils.c
+++ b/src/sandbox-1.1/sandbox_futils.c
@@ -3,7 +3,7 @@
* Distributed under the terms of the GNU General Public License, v2 or later
* Author: Brad House <brad@mainstreetsoftworks.com>
*
- * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox_futils.c,v 1.9 2004/04/04 20:37:21 carpaski Exp $
+ * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox_futils.c,v 1.10 2004/10/10 10:07:21 carpaski Exp $
*
*/
@@ -43,14 +43,15 @@ get_sandbox_path(char *argv0)
char path[255];
char *cwd = NULL;
+ memset(path, 0, sizeof(path));
/* ARGV[0] specifies full path */
if (argv0[0] == '/') {
- strncpy(path, argv0, 254);
+ strncpy(path, argv0, sizeof(path)-1);
/* ARGV[0] specifies relative path */
} else {
- egetcwd(cwd, 253);
- sprintf(path, "%s/%s", cwd, argv0);
+ egetcwd(cwd, sizeof(path)-2);
+ snprintf(path, sizeof(path)-1, "%s/%s", cwd, argv0);
if (cwd)
free(cwd);
cwd = NULL;
@@ -66,11 +67,11 @@ get_sandbox_lib(char *sb_path)
char path[255];
#ifdef SB_HAVE_64BIT_ARCH
- snprintf(path, 254, "%s", LIB_NAME);
+ snprintf(path, sizeof(path)-1, "%s", LIB_NAME);
#else
- snprintf(path, 254, "/lib/%s", LIB_NAME);
+ snprintf(path, sizeof(path)-1, "/lib/%s", LIB_NAME);
if (file_exist(path, 0) <= 0) {
- snprintf(path, 254, "%s%s", sb_path, LIB_NAME);
+ snprintf(path, sizeof(path)-1, "%s%s", sb_path, LIB_NAME);
}
#endif
return (strdup(path));
@@ -90,9 +91,9 @@ get_sandbox_rc(char *sb_path)
{
char path[255];
- snprintf(path, 254, "/usr/lib/portage/lib/%s", BASHRC_NAME);
+ snprintf(path, sizeof(path)-1, "/usr/lib/portage/lib/%s", BASHRC_NAME);
if (file_exist(path, 0) <= 0) {
- snprintf(path, 254, "%s%s", sb_path, BASHRC_NAME);
+ snprintf(path, sizeof(path)-1, "%s%s", sb_path, BASHRC_NAME);
}
return (strdup(path));
}
@@ -106,7 +107,8 @@ get_sandbox_log()
sprintf(pid_string, "%d", getpid());
- strcpy(path, LOG_FILE_PREFIX);
+ memset(path, 0 , sizeof(path));
+ strncpy(path, LOG_FILE_PREFIX, sizeof(path)-1);
/* THIS CHUNK BREAK THINGS BY DOING THIS:
* SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log
@@ -114,12 +116,12 @@ get_sandbox_log()
sandbox_log_env = getenv(ENV_SANDBOX_LOG);
if (sandbox_log_env) {
- strcat(path, sandbox_log_env);
- strcat(path, "-");
+ strncat(path, sandbox_log_env, sizeof(path)-1);
+ strncat(path, "-", sizeof(path)-1);
}
- strcat(path, pid_string);
- strcat(path, LOG_FILE_EXT);
+ strncat(path, pid_string, sizeof(path)-1);
+ strncat(path, LOG_FILE_EXT, sizeof(path)-1);
return (strdup(path));
}