aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2003-09-28 08:37:19 +0000
committerMartin Schlemmer <azarah@gentoo.org>2003-09-28 08:37:19 +0000
commit041b25b582c43d620af45f7b42a5973bd82789ff (patch)
tree66580e326a013107ef23f00224c3e7e69d2a510c /src
parentFix our mkdir wrapper to check if the dir exist, and return EEXIST if so, (diff)
downloadportage-cvs-041b25b582c43d620af45f7b42a5973bd82789ff.tar.gz
portage-cvs-041b25b582c43d620af45f7b42a5973bd82789ff.tar.bz2
portage-cvs-041b25b582c43d620af45f7b42a5973bd82789ff.zip
Add support to set the pids file via SANDBOX_PIDS_FILE
Diffstat (limited to 'src')
-rw-r--r--src/sandbox-1.1/ChangeLog7
-rw-r--r--src/sandbox-1.1/libsandbox.c13
-rw-r--r--src/sandbox-1.1/sandbox.c31
-rw-r--r--src/sandbox-1.1/sandbox.h3
-rw-r--r--src/sandbox-1.1/sandbox_futils.c11
5 files changed, 51 insertions, 14 deletions
diff --git a/src/sandbox-1.1/ChangeLog b/src/sandbox-1.1/ChangeLog
index 334620f..23cb876 100644
--- a/src/sandbox-1.1/ChangeLog
+++ b/src/sandbox-1.1/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for Path Sandbox
# Copyright 2002 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/ChangeLog,v 1.21 2003/09/27 16:46:43 azarah Exp $
+# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/ChangeLog,v 1.22 2003/09/28 08:37:19 azarah Exp $
+
+ 28 Sep 2003; Martin Schlemmer <azarah@gentoo.org> libsandbox.c, sandbox.c,
+ sandbox.h, sandbox_futils.c :
+ Add support to set the pids file via SANDBOX_PIDS_FILE at startup. If
+ it is not set, it will revert to its old value.
27 Sep 2003; Martin Schlemmer <azarah@gentoo.org> libsandbox.c :
Fix our mkdir wrapper to check if the dir exist, and return EEXIST if so,
diff --git a/src/sandbox-1.1/libsandbox.c b/src/sandbox-1.1/libsandbox.c
index 7280e79..dc317db 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.10 2003/09/27 16:46:43 azarah Exp $
+ * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/libsandbox.c,v 1.11 2003/09/28 08:37:19 azarah Exp $
*
*/
@@ -78,8 +78,6 @@
#include "localdecls.h"
#include "sandbox.h"
-#define PIDS_FILE "/tmp/sandboxpids.tmp"
-
/* Macros to check if a function should be executed */
#define FUNCTION_SANDBOX_SAFE(func, path) \
((0 == is_sandbox_on()) || (1 == before_syscall(func, path)))
@@ -116,6 +114,7 @@
}
static char sandbox_lib[255];
+static char sandbox_pids_file[255];
typedef struct {
int show_access_violation;
@@ -262,7 +261,13 @@ _init(void)
/* Get the path and name to this library */
tmp_string = get_sandbox_lib("/");
strncpy(sandbox_lib, tmp_string, 254);
+ 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);
if (tmp_string)
free(tmp_string);
tmp_string = NULL;
@@ -847,7 +852,7 @@ is_sandbox_pid()
init_wrappers();
- pids_stream = true_fopen(PIDS_FILE, "r");
+ pids_stream = true_fopen(sandbox_pids_file, "r");
if (NULL == pids_stream) {
perror(">>> pids file fopen");
diff --git a/src/sandbox-1.1/sandbox.c b/src/sandbox-1.1/sandbox.c
index af31368..28a3f8f 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.10 2003/07/27 12:31:06 azarah Exp $
+** $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox.c,v 1.11 2003/09/28 08:37:19 azarah Exp $
*/
#define _GNU_SOURCE
@@ -160,12 +160,21 @@ cleanup()
int pids_file = -1, num_of_pids = 0;
int *pids_array = NULL;
char pid_string[255];
+ char sandbox_pids_file[255];
+ char *tmp_string;
#ifdef USE_LD_SO_PRELOAD
int preload_file = -1, num_of_preloads = 0;
char preload_entry[255];
char **preload_array = NULL;
#endif
+ /* Generate sandbox pids-file path */
+ tmp_string = get_sandbox_pids_file();
+ strncpy(sandbox_pids_file, tmp_string, 254);
+ if (tmp_string)
+ free(tmp_string);
+ tmp_string = NULL;
+
/* Remove this sandbox's bash pid from the global pids
* file if it has rights to adapt the ld.so.preload file */
if ((1 == preload_adaptable) && (0 == cleaned_up)) {
@@ -176,7 +185,7 @@ cleanup()
printf("Cleaning up pids file.\n");
/* Stat the PIDs file, make sure it exists and is a regular file */
- if (file_exist(PIDS_FILE, 1) <= 0) {
+ if (file_exist(sandbox_pids_file, 1) <= 0) {
perror(">>> pids file is not a regular file");
success = 0;
/* We should really not fail if the pidsfile is missing here, but
@@ -184,7 +193,7 @@ cleanup()
return;
}
- pids_file = file_open(PIDS_FILE, "r+", 0);
+ pids_file = file_open(sandbox_pids_file, "r+", 0);
if (-1 == pids_file) {
success = 0;
/* Nothing more to do here */
@@ -268,7 +277,7 @@ cleanup()
pids_file = -1;
/* remove the pidsfile, as this was the last sandbox */
- unlink(PIDS_FILE);
+ unlink(sandbox_pids_file);
}
if (pids_array != NULL)
@@ -509,6 +518,7 @@ main(int argc, char **argv)
char sandbox_debug_log[255];
char sandbox_dir[255];
char sandbox_lib[255];
+ char sandbox_pids_file[255];
char sandbox_rc[255];
char pid_string[255];
char **argv_bash = NULL;
@@ -555,6 +565,13 @@ main(int argc, char **argv)
free(tmp_string);
tmp_string = NULL;
+ /* Generate sandbox pids-file path */
+ tmp_string = get_sandbox_pids_file();
+ strncpy(sandbox_pids_file, tmp_string, 254);
+ if (tmp_string)
+ free(tmp_string);
+ tmp_string = NULL;
+
/* Generate sandbox bashrc path */
tmp_string = get_sandbox_rc(sandbox_dir);
strncpy(sandbox_rc, tmp_string, 254);
@@ -776,11 +793,11 @@ main(int argc, char **argv)
/* Load our PID into PIDs file */
success = 1;
- if (file_exist(PIDS_FILE, 1) < 0) {
+ if (file_exist(sandbox_pids_file, 1) < 0) {
success = 0;
- fprintf(stderr, ">>> %s is not a regular file", PIDS_FILE);
+ fprintf(stderr, ">>> %s is not a regular file", sandbox_pids_file);
} else {
- pids_file = file_open(PIDS_FILE, "r+", 1, 0644);
+ pids_file = file_open(sandbox_pids_file, "r+", 1, 0644);
if (-1 == pids_file)
success = 0;
}
diff --git a/src/sandbox-1.1/sandbox.h b/src/sandbox-1.1/sandbox.h
index 3b76336..aefad43 100644
--- a/src/sandbox-1.1/sandbox.h
+++ b/src/sandbox-1.1/sandbox.h
@@ -4,7 +4,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.h,v 1.4 2003/07/27 12:31:06 azarah Exp $
+ * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox.h,v 1.5 2003/09/28 08:37:19 azarah Exp $
*/
#ifndef __SANDBOX_H__
@@ -48,6 +48,7 @@
char *get_sandbox_path(char *argv0);
char *get_sandbox_lib(char *sb_path);
+char *get_sandbox_pids_file(void);
char *get_sandbox_rc(char *sb_path);
char *get_sandbox_log();
char *sb_dirname(const char *path);
diff --git a/src/sandbox-1.1/sandbox_futils.c b/src/sandbox-1.1/sandbox_futils.c
index 9d2f820..cd33448 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.4 2003/07/27 12:31:06 azarah Exp $
+ * $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/src/sandbox-1.1/Attic/sandbox_futils.c,v 1.5 2003/09/28 08:37:19 azarah Exp $
*
*/
@@ -65,6 +65,15 @@ get_sandbox_lib(char *sb_path)
}
char *
+get_sandbox_pids_file(void)
+{
+ if (0 < getenv("SANDBOX_PIDS_FILE")) {
+ return (strdup(getenv("SANDBOX_PIDS_FILE")));
+ }
+ return (strdup(PIDS_FILE));
+}
+
+char *
get_sandbox_rc(char *sb_path)
{
char path[255];