Skip to content

Commit 1079288

Browse files
author
Mrunal Patel
authored
Merge pull request #2902 from liusdu/checkpoint
checkpoint: resolve symlink for external bind mount
2 parents 245fe2b + da22625 commit 1079288

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

libcontainer/container_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,9 @@ const descriptorsFilename = "descriptors.json"
780780

781781
func (c *linuxContainer) addCriuDumpMount(req *criurpc.CriuReq, m *configs.Mount) {
782782
mountDest := strings.TrimPrefix(m.Destination, c.config.Rootfs)
783+
if dest, err := securejoin.SecureJoin(c.config.Rootfs, mountDest); err == nil {
784+
mountDest = dest[len(c.config.Rootfs):]
785+
}
783786
extMnt := &criurpc.ExtMountMap{
784787
Key: proto.String(mountDest),
785788
Val: proto.String(mountDest),

tests/integration/checkpoint.bats

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,18 @@ function simple_cr() {
126126
done
127127
}
128128

129-
@test "checkpoint and restore " {
129+
@test "checkpoint and restore" {
130+
simple_cr
131+
}
132+
133+
@test "checkpoint and restore (bind mount, destination is symlink)" {
134+
mkdir -p rootfs/real/conf
135+
ln -s /real/conf rootfs/conf
136+
update_config ' .mounts += [{
137+
source: ".",
138+
destination: "/conf",
139+
options: ["bind"]
140+
}]'
130141
simple_cr
131142
}
132143

0 commit comments

Comments
 (0)