Skip to content
Open
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
12 changes: 7 additions & 5 deletions src/test/mount_ns_exec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ int main(int argc, char* argv[]) {
return 0;
}

if (-1 == try_setup_ns(CLONE_NEWNS)) {
atomic_puts("EXIT-SUCCESS");
return 0;
}

// Read /proc/self/exe before unsharing: afterwards the kernel renders it from
// the old namespace's root, which differs from ours if we were chrooted.
char exe_buf[PATH_MAX+1];
memset(exe_buf, 0, sizeof(exe_buf));
ssize_t nread = readlink("/proc/self/exe", exe_buf, sizeof(exe_buf)-1);
test_assert(nread != -1);

if (-1 == try_setup_ns(CLONE_NEWNS)) {
atomic_puts("EXIT-SUCCESS");
return 0;
}

char *exe_name = strrchr(exe_buf, '/');
*exe_name = '\0';
exe_name += 1;
Expand Down
Loading