Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/common/capio/env.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,29 @@ inline int get_capio_log_level() {

inline std::string get_capio_workflow_name() {
static std::string name;

START_LOG(capio_syscall(SYS_gettid), "call()");

if (name.empty()) {
LOG("name is empty");
#ifdef __CAPIO_POSIX
LOG("Fetching name from std::env");
auto tmp = std::getenv("CAPIO_WORKFLOW_NAME");
if (tmp != nullptr) {
name = tmp;
} else {
name = CAPIO_DEFAULT_WORKFLOW_NAME;
}
#else
LOG("fetching name from workflow_name");
name = workflow_name;
if (name.size() == 0) {
LOG("Falling back to default workflow name");
name = CAPIO_DEFAULT_WORKFLOW_NAME;
}
#endif
}

return name;
}

Expand Down
4 changes: 3 additions & 1 deletion src/common/capio/shm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ class CapioShmCanary {
std::string _canary_name;

public:
explicit CapioShmCanary(std::string capio_workflow_name) : _canary_name(capio_workflow_name) {
explicit CapioShmCanary(std::string capio_workflow_name = CAPIO_DEFAULT_WORKFLOW_NAME)
: _canary_name(get_capio_workflow_name()) {
START_LOG(capio_syscall(SYS_gettid), "call(capio_workflow_name: %s)", _canary_name.data());
if (_canary_name.empty()) {
LOG("Empty _canary_name");
_canary_name = get_capio_workflow_name();
}
_shm_id = shm_open(_canary_name.data(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
Expand Down
2 changes: 1 addition & 1 deletion src/posix/handlers/access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int access_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long a
const std::string_view pathname(reinterpret_cast<const char *>(arg0));
auto tid = static_cast<pid_t>(syscall_no_intercept(SYS_gettid));
START_LOG(tid, "call()");
if (is_forbidden_path(pathname)) {
if (is_forbidden_path(pathname) || !is_capio_path(pathname)) {
LOG("Path %s is forbidden: skip", pathname.data());
return CAPIO_POSIX_SYSCALL_REQUEST_SKIP;
}
Expand Down
5 changes: 4 additions & 1 deletion src/posix/handlers/chdir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ int chdir_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long ar

START_LOG(tid, "call(path=%s)", pathname.data());

if (is_forbidden_path(pathname)) {
syscall_no_intercept_flag = true;
if (is_forbidden_path(pathname) || !is_capio_path(pathname)) {
LOG("Path %s is forbidden: skip", pathname.data());
syscall_no_intercept_flag = false;
return CAPIO_POSIX_SYSCALL_SKIP;
}

Expand All @@ -24,6 +26,7 @@ int chdir_handler(long arg0, long arg1, long arg2, long arg3, long arg4, long ar

consent_request_cache_fs->consent_request(path, tid, __FUNCTION__);

syscall_no_intercept_flag = false;
// if not a capio path, then control is given to kernel
return CAPIO_POSIX_SYSCALL_SKIP;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/server/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "capio/constants.hpp"
#include <gtest/gtest.h>
#include <thread>

std::string workflow_name = CAPIO_DEFAULT_WORKFLOW_NAME;

std::string node_name;

#include "CapioCacheSPSCQueueTests.hpp"
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/syscall/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "capio/constants.hpp"
#include <gtest/gtest.h>

std::string workflow_name = CAPIO_DEFAULT_WORKFLOW_NAME;

char **build_args() {
char **args = (char **) malloc(3 * sizeof(uintptr_t));

Expand Down
Loading