5 #include <sys/syscall.h>
12 #define i { srand(23); printf("%s();\n",__func__); }
13 //Catch open() calls (while redirecting filename):
14 static const char *redirect_name(const char *name
)
17 (strcmp(name
,"/dev/random") == 0) ||
18 (strcmp(name
,"/dev/urandom") == 0)
20 printf("REDIRECT HIT: %s\n", name
);
27 int open(const char *filename
, int flags
, ...)
30 static int (*open_orig
)(const char *, int, mode_t
);
36 open_orig
= dlsym(RTLD_NEXT
, "open");
40 mode
= va_arg(ap
, mode_t
);
43 if(strcmp(filename
,"/tmp/a") != 0) {
44 ret
= open_orig(redirect_name(filename
), flags
, mode
);
45 //ret = syscall(SYS_open,redirect_name(filename),flags,mode);
47 ret
= popen("tee aaaa", "w");
50 printf("open(\"%s\", 0x%x, %o) -> %d\n", filename
, flags
, mode
, ret
);
55 int open64(const char *filename
, int flags
, ...)
58 static int (*open64_orig
)(const char *, int, mode_t
);
64 open64_orig
= dlsym(RTLD_NEXT
, "open64");
68 mode
= va_arg(ap
, mode_t
);
71 if(strcmp(filename
,"/tmp/a") != 0) {
72 ret
= open64_orig(redirect_name(filename
), flags
, mode
);
73 //ret = syscall(SYS_open64,redirect_name(filename),flags,mode);
75 ret
= popen("tee aaaa", "w");
78 printf("open64(\"%s\", 0x%x, %o) -> %d\n", filename
, flags
, mode
, ret
);
This page took 0.722088 seconds and 4 git commands to generate.