Skip to content

Commit

Permalink
added __open_2 wrapper for centos6
Browse files Browse the repository at this point in the history
  • Loading branch information
ValHayot committed May 15, 2020
1 parent 7dae2d8 commit 23c6a08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ extern "C" {
return ((funcptr___open)libc___open)(passpath, flags, mode);
}

int __open_2 (const char *file, int oflag){
initialize_passthrough_if_necessary();
log_msg(INFO, "opening file %s", file);
char passpath[PATH_MAX];
pass_getpath(file, passpath);
return ((funcptr___open_2)libc___open_2)(passpath, oflag);

}

int open64(const char* pathname, int flags, ...){
initialize_passthrough_if_necessary();
log_msg(INFO, "open64 %s", pathname);
Expand Down
2 changes: 2 additions & 0 deletions passthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
void* libc;
void* libc_open;
void* libc___open;
void* libc___open_2;
void* libc_open64;
void* libc___open64;
void* libc_openat;
Expand Down Expand Up @@ -263,6 +264,7 @@ static void initialize_passthrough() {
libc = dlopen("libc.so.6", RTLD_LAZY); // TODO: link with correct libc, version vs. 32 bit vs. 64 bit
libc_open = dlsym(libc, "open");
libc___open = dlsym(libc, "__open");
libc___open_2 = dlsym(libc, "__open_2");
libc_open64 = dlsym(libc, "open64");
libc___open64 = dlsym(libc, "__open64");
libc_openat = dlsym(libc, "openat");
Expand Down
2 changes: 2 additions & 0 deletions passthrough.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern char* log_fn;

typedef int (*funcptr_open)(const char*, int, mode_t);
typedef int (*funcptr___open)(const char*, int, mode_t);
typedef int (*funcptr___open_2)(const char *file, int oflag);
typedef int (*funcptr_open64)(const char*, int, mode_t);
typedef int (*funcptr___open64)(const char*, int, mode_t);
typedef int (*funcptr_openat)(int, const char*, int);
Expand Down Expand Up @@ -81,6 +82,7 @@ typedef const char* (*funcptr_magic_file)(magic_t, const char* filename);

extern void* libc_open;
extern void* libc___open;
extern void* libc___open_2;
extern void* libc_open64;
extern void* libc___open64;
extern void* libc_openat;
Expand Down

0 comments on commit 23c6a08

Please sign in to comment.