use non-zero data
[tridge/junkcode.git] / preload_getenv.c
1 #include <pwd.h>
2 #include <sys/types.h>
3 #include <dlfcn.h>
4 #include <stdio.h>
5
6 const char *getenv(const char *name)
7 {
8         static void *h;
9         static const char *(*getenv_orig)(const char *);
10         const char *ret;
11
12         if (!h) {
13                 h = dlopen("/lib/libc.so.6", RTLD_LAZY);
14                 getenv_orig = dlsym(h, "getenv");
15         }
16
17         ret = getenv_orig(name);
18
19         fprintf(stderr, "getenv(%s) -> '%s'\n", name, ret);
20
21         return ret;
22 }