Commit 33e98104 authored by Ramon Nou's avatar Ramon Nou
Browse files

fix(client): preserve external path resolution and CI formatting

parent afbd67d2
Loading
Loading
Loading
Loading
Loading
+3 −20
Changes for src/client/preload_context.cpp: 3 added lines, 20 removed lines.
Original line number Diff line number Diff line
@@ -834,26 +834,9 @@ PreloadContext::relativize_path(const char* raw_path,
        return false;
    }

    if(raw_path[0] == gkfs::path::separator) {
        const size_t mlen = mountdir_.size();
        if(strncmp(raw_path, mountdir_.c_str(), mlen) != 0) {
            if(strstr(raw_path, "..") == nullptr) {
                return false;
            }
        } else {
            char next = raw_path[mlen];
            if(next != '\0' && next != gkfs::path::separator) {
                if(strstr(raw_path, "..") == nullptr) {
                    return false;
                }
            }
        }
    } else if(!cwd_is_internal_) {
        if(strstr(raw_path, "..") == nullptr) {
            return false;
        }
    }

    // External paths must also populate relative_path: callers use the
    // resolved path when forwarding operations such as stat() and chdir().
    // Keep resolution here so external symlinks can still enter the mount.
    std::string path;

    if(raw_path != nullptr) {
+27 −0
Changes for tests/integration/syscalls/test_interceptor_runtime_bypass.py: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
import os
from pathlib import Path

import pytest


@pytest.mark.parametrize("shell_fixture", ["gkfs_shell", "gkfs_shellLibc"])
def test_external_paths_preserve_resolution(shell_fixture, request,
                                           gkfs_daemon, tmp_path):
    """External stat and chdir must receive the resolved, nonempty path."""
    shell = request.getfixturevalue(shell_fixture)
    external = tmp_path / "external"
    external.mkdir()
    child = external / "child"
    cmd = shell.script(
        f"""
        set -eu
        test -d '{external}'
        cd '{external}'
        test "$(pwd)" = '{external}'
        mkdir -p child/nested
        test -d child/nested
        cd child
        test "$(pwd)" = '{child}'
        """,
        timeout=10,
    )
    assert cmd.exit_code == 0, cmd.stderr.decode(errors="replace")
    assert (child / "nested").is_dir()


def test_preload_bypasses_mpi_runtime_paths(gkfs_daemon, gkfs_shell):
    """MPI/PMIx runtime files must not enter GekkoFS path hooks.
+2 −2

File changed.

Contains only whitespace changes.

+2 −2

File changed.

Contains only whitespace changes.