Skip to content

Commit ec2ffae

Browse files
committed
libct: Allow rel paths for idmap mounts
The idea was to make them strict on dest path from the beginning for idmap mounts, as runc would do that for all mounts in the future. But that is causing too many problems. For now, let's just allow relative paths for idmap mounts too. It just seems safer. Signed-off-by: Rodrigo Campos <[email protected]>
1 parent 19d26a6 commit ec2ffae

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libcontainer/rootfs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ func mountToRootfs(c *mountConfig, m mountEntry) error {
485485
if m.srcFD == nil {
486486
return fmt.Errorf("error creating mount %+v: idmapFD is invalid, should point to a valid fd", m)
487487
}
488-
if err := unix.MoveMount(*m.srcFD, "", -1, dest, unix.MOVE_MOUNT_F_EMPTY_PATH); err != nil {
488+
if err := unix.MoveMount(*m.srcFD, "", unix.AT_FDCWD, dest, unix.MOVE_MOUNT_F_EMPTY_PATH); err != nil {
489489
return fmt.Errorf("error on unix.MoveMount %+v: %w", m, err)
490490
}
491491

tests/integration/idmap.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ function teardown() {
7272
[[ "$output" == *"shared"* ]]
7373
}
7474

75+
@test "idmap mount with relative path" {
76+
update_config ' .mounts |= map((select(.source == "source-1/") | .destination = "tmp/mount-1") // .)'
77+
78+
runc run test_debian
79+
[ "$status" -eq 0 ]
80+
[[ "$output" == *"=0=0="* ]]
81+
}
82+
7583
@test "idmap mount with bind mount" {
7684
update_config ' .mounts += [
7785
{

0 commit comments

Comments
 (0)