Commit 1b3feefc authored by Ramon Nou's avatar Ramon Nou Committed by Ramon Nou
Browse files

Adding call to hook_chdir (missing for cd, in libc)

parent 074338f1
Loading
Loading
Loading
Loading
+6 −15
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <cstdarg>
#include <client/gkfs_libc.hpp>
#include <client/user_functions.hpp>
#include <client/hooks.hpp>
#include <atomic>
#include <client/preload_context.hpp>
#include <client/preload.hpp>
@@ -708,7 +709,6 @@ dlsym_exit(int status) {
// File/Directory Metadata API
int
dlsym_chdir(char* path) {
    debug_info("[SYSCALL_PROXIES] [dlsym_chdir] >> Begin\n");

    if(real_chdir == NULL) {
        real_chdir = (int (*)(char*)) dlsym(RTLD_NEXT, "chdir");
@@ -716,7 +716,6 @@ dlsym_chdir(char* path) {

    int ret = real_chdir((char*) path);

    debug_info("[SYSCALL_PROXIES] [dlsym_chdir] >> End\n");

    return ret;
}
@@ -981,7 +980,6 @@ open64(const char* path, int flags, ...) {

int
openat(int dirfd, const char* path, int flags, ...) {
    debug_info("[BYPASS] >> openat.... %s %o\n", path, flags);
    int ret, fd;
    va_list ap;
    mode_t mode = 0;
@@ -1007,19 +1005,9 @@ openat(int dirfd, const char* path, int flags, ...) {
                // Try normal open.
                break;
        }
    } else {
        std::string p = path;

        debug_info("[BYPASS] >> Begin openat. ERROR...%s\n", path);
        if(p.find("mnt") != std::string::npos) {
            gkfs::preload::init_environment();
            CTX->enable_interception();
            debug_info("[BYPASS] >> Reinited. ERROR...%s %d\n", path,
                       CTX->interception_enabled());
            return openat(dirfd, (char*) path, flags, mode);
        }
    }


    ret = dlsym_openat(dirfd, (char*) path, flags, mode);
    va_end(ap);

@@ -1852,6 +1840,8 @@ chdir(const char* path) {
    int ret = -1;
    initializeGekko();
    // is the path from gekkofs
    return gkfs::hook::hook_chdir(path);
    /*
    if(CTX->interception_enabled()) {
        std::string resolved;

@@ -1862,7 +1852,7 @@ chdir(const char* path) {
                return -ENOTDIR;

            case gkfs::preload::RelativizeStatus::internal:
                return -ENOTDIR;
                return (

            default:
                // Try normal open.
@@ -1874,6 +1864,7 @@ chdir(const char* path) {
    ret = dlsym_chdir((char*) path);

    debug_info("[BYPASS] << After chdir()\n");
    */

    return ret;
}
+12 −12
Original line number Diff line number Diff line
@@ -495,43 +495,43 @@ destroy_libc() {

void
at_fork() {
    printf("%d ->At fork, %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d ->At fork, %d\n", gettid(), CTX->interception_enabled());
    destroy_libc();
}
void
at_parent() {
    printf("%d ->At fork parent %d\n", gettid(), CTX->interception_enabled());
 //   printf("%d ->At fork parent %d\n", gettid(), CTX->interception_enabled());
    init_libc();
    printf("%d -> x At fork parent %d\n", gettid(),
           CTX->interception_enabled());
  //  printf("%d -> x At fork parent %d\n", gettid(),
  //         CTX->interception_enabled());
}

void
at_child() {

    printf("%d ->At fork child %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d ->At fork child %d\n", gettid(), CTX->interception_enabled());
    init_libc();
    printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
}


void
at_fork_syscall() {
    printf("%d ->At fork, %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d ->At fork, %d\n", gettid(), CTX->interception_enabled());
    destroy_preload();
}
void
at_parent_syscall() {
    printf("%d ->At fork parent %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d ->At fork parent %d\n", gettid(), CTX->interception_enabled());
    init_preload();
    printf("%d -> x At fork parent %d\n", gettid(),
           CTX->interception_enabled());
   // printf("%d -> x At fork parent %d\n", gettid(),
     //      CTX->interception_enabled());
}

void
at_child_syscall() {

    printf("%d ->At fork child %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d ->At fork child %d\n", gettid(), CTX->interception_enabled());
    init_preload();
    printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
  //  printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
}