summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjlh <jlh@FreeBSD.org>2012-05-08 19:43:32 +0000
committerjlh <jlh@FreeBSD.org>2012-05-08 19:43:32 +0000
commitda2bdbf902da11446319f6b31c848b3a946cb2ca (patch)
tree4d4d8527606a807c2c1bcbc5b771e5cbba889b5e /usr.bin
parent52487d9a5cec5d4144a37b031adbf2b113602c8c (diff)
downloadFreeBSD-src-da2bdbf902da11446319f6b31c848b3a946cb2ca.zip
FreeBSD-src-da2bdbf902da11446319f6b31c848b3a946cb2ca.tar.gz
Always define LD_32_PRELOAD so it works for 32 bits binaries on
64 bits platforms. Let rtld(1) decide if it needs to honor it or not. While here, fix a small bug in error reporting when asprintf(3) returns an error. Submitted by: kib Reviewed by: kib (mentor) MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/stdbuf/stdbuf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/stdbuf/stdbuf.c b/usr.bin/stdbuf/stdbuf.c
index b2ade7e..3831b5e 100644
--- a/usr.bin/stdbuf/stdbuf.c
+++ b/usr.bin/stdbuf/stdbuf.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#define LIBSTDBUF "/usr/lib/libstdbuf.so"
+#define LIBSTDBUF32 "/usr/lib32/libstdbuf.so"
extern char *__progname;
@@ -92,7 +93,17 @@ main(int argc, char *argv[])
LIBSTDBUF);
if (i < 0 || putenv(preload1) == -1)
- warn("Failed to set environment variable: %s", preload1);
+ warn("Failed to set environment variable: LD_PRELOAD");
+
+ preload0 = getenv("LD_32_PRELOAD");
+ if (preload0 == NULL)
+ i = asprintf(&preload1, "LD_32_PRELOAD=" LIBSTDBUF32);
+ else
+ i = asprintf(&preload1, "LD_32_PRELOAD=%s:%s", preload0,
+ LIBSTDBUF32);
+
+ if (i < 0 || putenv(preload1) == -1)
+ warn("Failed to set environment variable: LD_32_PRELOAD");
execvp(argv[0], argv);
err(2, "%s", argv[0]);
OpenPOWER on IntegriCloud