Skip to content

Commit 32d10af

Browse files
authored
Merge pull request #1857 from giuseppe/fix-mounting-within-userns
linux: fix regression mounting within userns
2 parents 7c1246d + e486eea commit 32d10af

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)