Skip to content

Commit

Permalink
Unshare container need at least mount ns
Browse files Browse the repository at this point in the history
  • Loading branch information
Moe-hacker committed Nov 22, 2024
1 parent 544e7ef commit f2259f6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/unshare.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ static pid_t init_unshare_container(struct RURI_CONTAINER *_Nonnull container)
// unshare_pid in forked process is 0.
pid_t unshare_pid = INIT_VALUE;
// Create namespaces.
if (unshare(CLONE_NEWNS) == -1 && !container->no_warnings) {
ruri_warning("{yellow}Warning: seems that mount namespace is not supported on this device QwQ{clear}\n");
if (unshare(CLONE_NEWNS) == -1) {
ruri_error("{red}Unshare container need at least mount ns support QwQ\n");
}
if (unshare(CLONE_NEWUTS) == -1 && !container->no_warnings) {
ruri_warning("{yellow}Warning: seems that uts namespace is not supported on this device QwQ{clear}\n");
Expand Down Expand Up @@ -173,8 +173,8 @@ static pid_t join_ns(struct RURI_CONTAINER *_Nonnull container)
}
}
ns_fd = open(mount_ns_file, O_RDONLY | O_CLOEXEC);
if (ns_fd < 0 && !container->no_warnings) {
ruri_warning("{yellow}Warning: seems that mount namespace is not supported on this device QwQ{clear}\n");
if (ns_fd < 0) {
ruri_error("{red}Unshare container need at least mount ns support QwQ\n");
} else {
usleep(1000);
if (setns(ns_fd, CLONE_NEWNS) == -1) {
Expand Down

0 comments on commit f2259f6

Please sign in to comment.