Skip to content

Commit

Permalink
[fix] Remove LD_PRELOAD/DYLD_INSERT_LIBRARIES at startup
Browse files Browse the repository at this point in the history
Make it possible to launch binaries of different architectures (32 vs 64
bit).

Fixes #32.
  • Loading branch information
mmalecki committed Sep 27, 2013
1 parent 0dcbc35 commit 002572c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/plugins/start/libinterposed.c
Expand Up @@ -2,13 +2,28 @@
#include <dlfcn.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <netinet/in.h>

int __interposed_ipc = 3;

static void __interposed_init() __attribute__((constructor));

#pragma CALL_ON_MODULE_BIND __interposed_init
#pragma CALL_ON_LOAD __interposed_init
#pragma init(__interposed_init)
void __interposed_init() {
#if (__APPLE__ && __MACH__)
unsetenv("DYLD_INSERT_LIBRARIES");
unsetenv("DYLD_FORCE_FLAT_NAMESPACE");
#else
unsetenv("LD_PRELOAD");
#endif
}

int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
int result, r;

Expand Down

0 comments on commit 002572c

Please sign in to comment.