@@ -343,3 +343,63 @@ function test_mount_order() {
343343@test " runc run [mount order, container idmap source] (userns)" {
344344 test_mount_order userns,idmap
345345}
346+
347+ @test " runc run [bind mount through a dangling symlink to a file]" {
348+ rm -rf rootfs/etc/hosts rootfs/tmp/hosts
349+ ln -s ../tmp/hosts rootfs/etc/hosts
350+ update_config ' .mounts += [{
351+ source: "./config.json",
352+ destination: "/etc/hosts",
353+ options: ["bind"]
354+ }]
355+ | .process.args |= ["ls", "/tmp/hosts"]'
356+
357+ runc run test_busybox
358+ [ " $status " -eq 0 ]
359+ [[ " ${lines[0]} " == * ' /tmp/hosts' * ]]
360+ }
361+
362+ @test " runc run [bind mount through a dangling symlink to a dir]" {
363+ mkdir -p rootfs/a rootfs/tmp/bind
364+ ln -s ../tmp/bind rootfs/a/bind
365+ update_config ' .mounts += [{
366+ source: ".",
367+ destination: "/a/bind",
368+ options: ["bind"]
369+ }]
370+ | .process.args |= ["ls", "/tmp/bind/config.json"]'
371+
372+ runc run test_busybox
373+ [ " $status " -eq 0 ]
374+ [[ " ${lines[0]} " == * ' /tmp/bind/config.json' * ]]
375+ }
376+
377+ @test " runc run [bind mount through a dangling symlink to a dir/file]" {
378+ rm -rf rootfs/var/log rootfs/tmp/log
379+ ln -s ../tmp/log rootfs/var/log
380+ update_config ' .mounts += [{
381+ source: "./config.json",
382+ destination: "/var/log/nginx/error.log",
383+ options: ["bind"]
384+ }]
385+ | .process.args |= ["ls", "-alh", "/tmp/log/nginx/error.log"]'
386+
387+ runc run test_busybox
388+ [ " $status " -eq 0 ]
389+ [[ " ${lines[0]} " == * ' /tmp/log/nginx/error.log' * ]]
390+ }
391+
392+ @test " runc run [bind mount through a dangling symlink to a dir/subdir]" {
393+ mkdir -p rootfs/a rootfs/tmp/bind
394+ ln -s ../tmp/bind rootfs/a/bind
395+ update_config ' .mounts += [{
396+ source: ".",
397+ destination: "/a/bind/subdir",
398+ options: ["bind"]
399+ }]
400+ | .process.args |= ["ls", "/tmp/bind/subdir/config.json"]'
401+
402+ runc run test_busybox
403+ [ " $status " -eq 0 ]
404+ [[ " ${lines[0]} " == * ' /tmp/bind/subdir/config.json' * ]]
405+ }
0 commit comments