我想监视由bash打开的文件,
deposit
并编译了这个共享库,
int open(const char *filename, int flags) {
printf("Path is %s\n", filename)
static int (*origin_open)(const char *filename, int flags);
if (!origin_open) {
origin_open = dlsym(RTLD_NEXT, "open");
}
return origin_open(filename, flags);
}
然后运行以下命令,
gcc -Wall -fPIC -shared -o hookopen.so hookeopen.c -ldl
终于得到了错误,
LD_PRELOAD="./hookeopen.so" /bin/bash
如何解决错误?感谢。