5 # lxc: linux Container library
8 # Serge Hallyn <serge.hallyn@ubuntu.com>
10 # This is a regression test for symbolic links
16 lxcpath
=/var
/lib
/lxcsym1
19 lxc-destroy
-P $lxcpath -f -n symtest1 || true
21 rmdir $dirname || true
26 trap cleanup EXIT SIGHUP SIGINT SIGTERM
32 lxc-start
-P $lxcpath -n symtest1
-l trace
-o $lxcpath/log || pass
="fail"
33 [ $pass = "pass" ] && lxc-wait
-P $lxcpath -n symtest1
-t 10 -s RUNNING || pass
="fail"
34 if [ "$pass" != "$expected" ]; then
35 echo "Test $run: expected $expected but container did not. Start log:"
37 echo "FAIL: Test $run: expected $expected but container did not."
40 lxc-stop
-P $lxcpath -n symtest1
-k || true
43 # make lxcpath a symlink - this should NOT cause failure
44 ln -s /var
/lib
/lxc
$lxcpath
46 lxc-destroy
-P $lxcpath -f -n symtest1 || true
47 lxc-create
-P $lxcpath -t busybox
-n symtest1
49 cat >> /var
/lib
/lxc
/symtest
1/config
<< EOF
50 lxc.mount.entry = $dirname opt/xxx/dir none bind,create=dir
51 lxc.mount.entry = $fname opt/xxx/file none bind,create=file
52 lxc.mount.entry = $fname2 opt/xxx/file2 none bind
53 lxc.mount.entry = $dirname /var/lib/lxc/symtest1/rootfs/opt/xxx/dir2 none bind,create=dir
56 # Regular - should succeed
57 mkdir
-p /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx
58 touch /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx
/file2
61 # symlink - should fail
62 rm -rf /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx
63 mkdir
-p /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx2
64 ln -s /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx2
/var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx
65 touch /var
/lib
/lxc
/symtest
1/rootfs
/opt
/xxx
/file2
68 # final final symlink - should fail
69 rm -rf $lxcpath/symtest
1/rootfs
/opt
/xxx
70 mkdir
-p $lxcpath/symtest
1/rootfs
/opt
/xxx
71 mkdir
-p $lxcpath/symtest
1/rootfs
/opt
/xxx
/dir
72 touch $lxcpath/symtest
1/rootfs
/opt
/xxx
/file
73 touch $lxcpath/symtest
1/rootfs
/opt
/xxx
/file2src
74 ln -s $lxcpath/symtest
1/rootfs
/opt
/xxx
/file2src
$lxcpath/symtest
1/rootfs
/opt
/xxx
/file2
77 # Ideally we'd also try a loop device, but that won't work in nested containers
80 # what about /proc itself
82 rm -rf $lxcpath/symtest
1/rootfs
/opt
/xxx
83 mkdir
-p $lxcpath/symtest
1/rootfs
/opt
/xxx
84 touch $lxcpath/symtest
1/rootfs
/opt
/xxx
/file2
85 mv $lxcpath/symtest
1/rootfs
/proc
$lxcpath/symtest
1/rootfs
/proc1
86 ln -s $lxcpath/symtest
1/rootfs
/proc1
$lxcpath/symtest
1/rootfs
/proc
89 echo "all tests passed"