cosmetic
This commit is contained in:
parent
0480a7a73f
commit
ae2f0d965e
@ -1,14 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
*
|
|
||||||
* spy_getenv.so: spy_getenv.c Makefile
|
* spy_getenv.so: spy_getenv.c Makefile
|
||||||
* gcc -Wall -shared -fPIC $< -ldl -o $@
|
* gcc -Wall -shared -fPIC $< -ldl -o $@
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
@ -18,15 +14,12 @@ char *getenv(char *envname)
|
|||||||
{
|
{
|
||||||
static char *arrow = "--getenv--> ";
|
static char *arrow = "--getenv--> ";
|
||||||
static char *wtf = " --> (nil)";
|
static char *wtf = " --> (nil)";
|
||||||
|
|
||||||
char *content;
|
char *content;
|
||||||
original_getenv orig_getenv;
|
original_getenv orig_getenv;
|
||||||
|
|
||||||
orig_getenv = (original_getenv)dlsym(RTLD_NEXT, "getenv");
|
orig_getenv = (original_getenv)dlsym(RTLD_NEXT, "getenv");
|
||||||
|
|
||||||
write(STDERR_FILENO, arrow, strlen(arrow));
|
write(STDERR_FILENO, arrow, strlen(arrow));
|
||||||
write(STDERR_FILENO, envname, strlen(envname));
|
write(STDERR_FILENO, envname, strlen(envname));
|
||||||
|
|
||||||
content = orig_getenv(envname);
|
content = orig_getenv(envname);
|
||||||
if (NULL != content) {
|
if (NULL != content) {
|
||||||
write(STDERR_FILENO, "=", 1);
|
write(STDERR_FILENO, "=", 1);
|
||||||
@ -35,9 +28,7 @@ if (NULL != content) {
|
|||||||
else {
|
else {
|
||||||
write(STDERR_FILENO, wtf, strlen(wtf));
|
write(STDERR_FILENO, wtf, strlen(wtf));
|
||||||
}
|
}
|
||||||
|
|
||||||
write(STDERR_FILENO, "\n", 1);
|
write(STDERR_FILENO, "\n", 1);
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user