summaryrefslogtreecommitdiff
path: root/libexec/ld.so
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2002-05-28 00:30:20 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2002-05-28 00:30:20 +0000
commit61b45f2a60edf0113061163079886c758d0530bc (patch)
treed652e00c09709882696619069dab4e33329a8ec8 /libexec/ld.so
parent9ef201cda84a928ebdceeef18465b0d493c6648a (diff)
Remove LD_LIBRARY_PATH completely from environment, as per ldconfig manpage.
ok deraadt@
Diffstat (limited to 'libexec/ld.so')
-rw-r--r--libexec/ld.so/loader.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index d1b4ef97ebb..45c779835e5 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.31 2002/05/28 00:23:57 deraadt Exp $ */
+/* $OpenBSD: loader.c,v 1.32 2002/05/28 00:30:19 drahn Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -47,7 +47,8 @@
/*
* Local decls.
*/
-static char *_dl_getenv(const char *var, const char **env);
+static char *_dl_getenv(const char *var, char **env);
+static void _dl_unsetenv(const char *var, char **env);
const char *_dl_progname;
int _dl_pagesz;
@@ -95,7 +96,7 @@ _dl_dtors(void)
* to do is to dig out all information we need to accomplish out task.
*/
unsigned long
-_dl_boot(const char **argv, const char **envp, const long loff,
+_dl_boot(const char **argv, char **envp, const long loff,
Elf_Dyn *dynp, long *dl_data)
{
int n;
@@ -129,10 +130,23 @@ _dl_boot(const char **argv, const char **envp, const long loff,
* a suid program without credentials high enough.
*/
if (_dl_issetugid()) { /* Zap paths if s[ug]id... */
- if (_dl_preload)
- *_dl_preload = '\0';
- if (_dl_libpath)
- *_dl_libpath = '\0';
+ if (_dl_preload) {
+ _dl_preload = NULL;
+ _dl_unsetenv("LD_PRELOAD", envp);
+ }
+ if (_dl_libpath) {
+ _dl_libpath = NULL;
+ _dl_unsetenv("LD_LIBRARY_PATH", envp);
+ }
+ if (_dl_bindnow) {
+ _dl_bindnow = NULL;
+ _dl_unsetenv("LD_BIND_NOW", envp);
+ }
+ if (_dl_debug) {
+ _dl_debug = NULL;
+ _dl_unsetenv("LD_DEBUG", envp);
+ }
+
}
/*
@@ -521,7 +535,7 @@ _dl_call_init(elf_object_t *object)
}
static char *
-_dl_getenv(const char *var, const char **env)
+_dl_getenv(const char *var, char **env)
{
const char *ep;
@@ -537,3 +551,27 @@ _dl_getenv(const char *var, const char **env)
}
return(0);
}
+static void
+_dl_unsetenv(const char *var, char **env)
+{
+ char *ep;
+
+ while ((ep = *env)) {
+ const char *vp = var;
+ char *lep = ep;
+
+ while (*vp && *vp == *ep) {
+ vp++;
+ ep++;
+ }
+ if (*vp == '\0' && *ep++ == '=') {
+ char **P;
+
+ for (P = env;; ++P)
+ if (!(*P = *(P + 1)))
+ break;
+ }
+ env++;
+ }
+
+}