aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorChristian S.J. Peron <csjp@FreeBSD.org>2007-07-14 19:04:00 +0000
committerChristian S.J. Peron <csjp@FreeBSD.org>2007-07-14 19:04:00 +0000
commit4b3e87d3341c6e1a5942a20dcc85273572a7a124 (patch)
treeab088d00639b28b095dcbf34eb059c407b3bdd70 /libexec
parentd688a95f38f4e73ab6072c909e36568172242f63 (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 8add50e0c9cf..bd8071bf3917 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -342,16 +342,26 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
trust = !issetugid();
ld_bind_now = getenv(LD_ "BIND_NOW");
- if (trust) {
- ld_debug = getenv(LD_ "DEBUG");
- libmap_disable = getenv(LD_ "LIBMAP_DISABLE") != NULL;
- libmap_override = getenv(LD_ "LIBMAP");
- ld_library_path = getenv(LD_ "LIBRARY_PATH");
- ld_preload = getenv(LD_ "PRELOAD");
- dangerous_ld_env = libmap_disable || (libmap_override != NULL) ||
- (ld_library_path != NULL) || (ld_preload != NULL);
- } else
- dangerous_ld_env = 0;
+ /*
+ * If the process is tainted, then we un-set the dangerous environment
+ * variables. The process will be marked as tainted until setuid(2)
+ * is called. If any child process calls setuid(2) we do not want any
+ * future processes to honor the potentially un-safe variables.
+ */
+ if (!trust) {
+ unsetenv(LD_ "PRELOAD");
+ unsetenv(LD_ "LIBMAP");
+ unsetenv(LD_ "LIBRARY_PATH");
+ unsetenv(LD_ "LIBMAP_DISABLE");
+ unsetenv(LD_ "DEBUG");
+ }
+ ld_debug = getenv(LD_ "DEBUG");
+ libmap_disable = getenv(LD_ "LIBMAP_DISABLE") != NULL;
+ libmap_override = getenv(LD_ "LIBMAP");
+ ld_library_path = getenv(LD_ "LIBRARY_PATH");
+ ld_preload = getenv(LD_ "PRELOAD");
+ dangerous_ld_env = libmap_disable || (libmap_override != NULL) ||
+ (ld_library_path != NULL) || (ld_preload != NULL);
ld_tracing = getenv(LD_ "TRACE_LOADED_OBJECTS");
ld_utrace = getenv(LD_ "UTRACE");