Skip to content

Commit e486eea

Browse files
committed
linux: fix regression mounting within userns
commit 4a27212 introduced the regression. Detect when running inside a user namespace and treat the mounts in the same way as they would be treated if creating a new user namespace. Closes: #1855 Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent 7c1246d commit e486eea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libcrun/linux.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,6 +4462,17 @@ prepare_and_send_mount_mounts (libcrun_container_t *container, pid_t pid, int sy
44624462

44634463
mount_fds = make_libcrun_fd_map (def->mounts_len);
44644464

4465+
/* If the container is already running in a user namespace, apply the same logic as if a new
4466+
user namespace was created as part of the container itself. */
4467+
if (! has_userns)
4468+
{
4469+
int is_in_userns = check_running_in_user_namespace (err);
4470+
if (UNLIKELY (is_in_userns < 0))
4471+
return is_in_userns;
4472+
4473+
has_userns = is_in_userns > 0;
4474+
}
4475+
44654476
for (i = 0; i < def->mounts_len; i++)
44664477
{
44674478
bool recursive = false;

0 commit comments

Comments
 (0)