I think I've finally fixed things to my satisfaction, system-wide: $ cat getaddrinfo_wrap.c // getaddrinfo wrapper #include <dlfcn.h> #define getaddrinfo _foo #include <netdb.h> #undef getaddrinfo
int getaddrinfo(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res) { typedef int (*FP_getaddrinfo)(const char*, const char*, struct addrinfo*, struct addrinfo **); FP_getaddrinfo org_getaddrinfo = dlsym(((void *) -1), "getaddrinfo"); hints->ai_flags|=AI_ADDRCONFIG; return org_getaddrinfo(node, service, hints, res); }
Running: gcc -fPIC -c -Wall getaddrinfo_wrap.c getaddrinfo_wrap.o gcc -shared getaddrinfo_wrap.o -ldl -lstdc++ -o getaddrinfo_wrap.so sudo cp getaddrinfo_wrap.so /usr/local/lib/ sudo chown root:root /usr/local/lib/getaddrinfo_wrap.so sudo sh -c "echo /usr/local/lib/getaddrinfo_wrap.so >> /etc/ld.so.preload"
There. No more problems.
BTW, I do have ipv6 interfaces after stripping all my ipv4 hacks from above, that seems utterly irrelevant to this finally working. I of course have no idea what the results of this could be on various apps, but at least the ones I use seem happy.
I think I've finally fixed things to my satisfaction, system-wide:
$ cat getaddrinfo_wrap.c
// getaddrinfo wrapper
#include <dlfcn.h>
#define getaddrinfo _foo
#include <netdb.h>
#undef getaddrinfo
int getaddrinfo(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res) o)(const char*, const char*, struct addrinfo*, struct addrinfo **); >ai_flags| =AI_ADDRCONFIG; (node, service, hints, res);
{
typedef int (*FP_getaddrinf
FP_getaddrinfo org_getaddrinfo = dlsym(((void *) -1), "getaddrinfo");
hints-
return org_getaddrinfo
}
Running: lib/getaddrinfo _wrap.so lib/getaddrinfo _wrap.so >> /etc/ld.so.preload"
gcc -fPIC -c -Wall getaddrinfo_wrap.c getaddrinfo_wrap.o
gcc -shared getaddrinfo_wrap.o -ldl -lstdc++ -o getaddrinfo_wrap.so
sudo cp getaddrinfo_wrap.so /usr/local/lib/
sudo chown root:root /usr/local/
sudo sh -c "echo /usr/local/
There. No more problems.
BTW, I do have ipv6 interfaces after stripping all my ipv4 hacks from above, that seems utterly irrelevant to this finally working.
I of course have no idea what the results of this could be on various apps, but at least the ones I use seem happy.