Commit 1546f53 Add readlink-cannot-handle-recursive-symlinks test case

4 files Authored and Committed by mgahagan 2 years ago
Add readlink-cannot-handle-recursive-symlinks test case

    
 1 @@ -0,0 +1,64 @@
 2 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3 + #
 4 + #   Makefile of /CoreOS/coreutils/Sanity/bz510809-readlink-cannot-handle-recursive-symlink s
 5 + #   Description: Test for bz510809 (readlink cannot handle recursive symlinks)
 6 + #   Author: Jan Scotka <jscotka@redhat.com>
 7 + #
 8 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 9 + #
10 + #   Copyright (c) 2010 Red Hat, Inc. All rights reserved.
11 + #
12 + #   This copyrighted material is made available to anyone wishing
13 + #   to use, modify, copy, or redistribute it subject to the terms
14 + #   and conditions of the GNU General Public License version 2.
15 + #
16 + #   This program is distributed in the hope that it will be
17 + #   useful, but WITHOUT ANY WARRANTY; without even the implied
18 + #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 + #   PURPOSE. See the GNU General Public License for more details.
20 + #
21 + #   You should have received a copy of the GNU General Public
22 + #   License along with this program; if not, write to the Free
23 + #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 + #   Boston, MA 02110-1301, USA.
25 + #
26 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 + 
28 + export TEST=/CoreOS/coreutils/Sanity/bz510809-readlink-cannot-handle-recursive-symlinks
29 + export TESTVERSION=1.0
30 + 
31 + BUILT_FILES=
32 + 
33 + FILES=$(METADATA) runtest.sh Makefile PURPOSE
34 + 
35 + .PHONY: all install download clean
36 + 
37 + run: $(FILES) build
38 + »       ./runtest.sh
39 + 
40 + build: $(BUILT_FILES)
41 + »       chmod a+x runtest.sh
42 + 
43 + clean:
44 + »       rm -f *~ $(BUILT_FILES)
45 + 
46 + 
47 + include /usr/share/rhts/lib/rhts-make.include
48 + 
49 + $(METADATA): Makefile
50 + »       @echo "Owner:           Jan Scotka <jscotka@redhat.com>" > $(METADATA)
51 + »       @echo "Name:            $(TEST)" >> $(METADATA)
52 + »       @echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
53 + »       @echo "Path:            $(TEST_DIR)" >> $(METADATA)
54 + »       @echo "Description:     Test for bz510809 (readlink cannot handle recursive symlinks)" >> $(METADATA)
55 + »       @echo "Type:            Sanity" >> $(METADATA)
56 + »       @echo "TestTime:        5m" >> $(METADATA)
57 + »       @echo "RunFor:          coreutils" >> $(METADATA)
58 + »       @echo "Requires:        coreutils" >> $(METADATA)
59 + »       @echo "Priority:        Normal" >> $(METADATA)
60 + »       @echo "License:         GPLv2" >> $(METADATA)
61 + »       @echo "Confidential:    yes" >> $(METADATA)
62 + »       @echo "Destructive:     no" >> $(METADATA)
63 + »       @echo "Bug:             510809" >> $(METADATA)
64 + 
65 + »       rhts-lint $(METADATA)
 1 @@ -0,0 +1,55 @@
 2 + PURPOSE of /CoreOS/coreutils/Sanity/bz510809-readlink-cannot-handle-recursive-symlinks
 3 + Description: Test for bz510809 (readlink cannot handle recursive symlinks)
 4 + Author: Jan Scotka <jscotka@redhat.com>
 5 + Bug summary: readlink cannot handle recursive symlinks
 6 + Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=510809
 7 + 
 8 + Description:
 9 + 
10 + Description of problem:
11 + The readlink command fails with an error "Too many levels of symbolic links", even if there are only 2 levels.
12 + 
13 + The readlink command from RHEL 3 and RHEL 4 and from Fedora 11 all work fine.
14 + 
15 + Among other changes between RHEL 4 and RHEL 5, RHEL 5's coreutils added calls to cycle_check() in lib/canonicalize.c, but in upstream canonicalize.c (now in gnulib instead of coreutils), we see the comment:
16 +           /* Detect loops.  We cannot use the cycle-check module here,
17 +              since it's actually possible to encounter the same symlink
18 +              more than once in a given traversal.  However, encountering
19 +              the same symlink,NAME pair twice does indicate a loop.  */
20 + 
21 + http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/canonicalize.c;h=4f348398fd69ae516396313d18ac294a4ca3dde3;hb=b653eda3ac4864de205419d9f41eec267cb89eeb#l262
22 + 
23 + The latest canonicalize.c uses seen_triple() instead of cycle_check().
24 + 
25 + 
26 + Version-Release number of selected component (if applicable):
27 + coreutils-5.97-19.el5
28 + 
29 + How reproducible:
30 + every time
31 + 
32 + Steps to Reproduce:
33 + 1. Create a directory with a symlink to itself
34 +        mkdir /tmp/dir
35 +        cd /tmp/dir
36 +        ln -s ../dir dirlink
37 + 
38 + 2. Run readlink using the 'dirlink' symlink recursively
39 +        readlink -v -f dirlink
40 +        readlink -v -f dirlink/dirlink
41 +        readlink -v -f dirlink/dirlink/dirlink
42 +   
43 + Actual results:
44 + The first readlink command on just dirlink succeeds, but the 2nd and 3rd commands fail with 
45 +    readlink: dirlink/dirlink: Too many levels of symbolic links
46 + 
47 + Expected results:
48 + $ readlink -v -f dirlink
49 + /tmp/dir
50 + $ readlink -v -f dirlink/dirlink
51 + /tmp/dir
52 + $ readlink -v -f dirlink/dirlink/dirlink
53 + /tmp/dir
54 + 
55 + 
56 + Additional info:
 1 @@ -0,0 +1,60 @@
 2 + #!/bin/bash
 3 + # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
 4 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5 + #
 6 + #   runtest.sh of /CoreOS/coreutils/Sanity/bz510809-readlink-cannot-handle-recursive-symlinks
 7 + #   Description: Test for bz510809 (readlink cannot handle recursive symlinks)
 8 + #   Author: Jan Scotka <jscotka@redhat.com>
 9 + #
10 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 + #
12 + #   Copyright (c) 2010 Red Hat, Inc. All rights reserved.
13 + #
14 + #   This copyrighted material is made available to anyone wishing
15 + #   to use, modify, copy, or redistribute it subject to the terms
16 + #   and conditions of the GNU General Public License version 2.
17 + #
18 + #   This program is distributed in the hope that it will be
19 + #   useful, but WITHOUT ANY WARRANTY; without even the implied
20 + #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 + #   PURPOSE. See the GNU General Public License for more details.
22 + #
23 + #   You should have received a copy of the GNU General Public
24 + #   License along with this program; if not, write to the Free
25 + #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 + #   Boston, MA 02110-1301, USA.
27 + #
28 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 + 
30 + # Include rhts environment
31 + . /usr/bin/rhts-environment.sh
32 + . /usr/lib/beakerlib/beakerlib.sh
33 + 
34 + PACKAGE="coreutils"
35 + 
36 + rlJournalStart
37 +     rlPhaseStartSetup
38 +         rlAssertRpm $PACKAGE
39 +         rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
40 +         rlRun "pushd $TmpDir"
41 +         rlRun "mkdir link" 0 "Creating test directory"
42 +         rlRun "cd link" 0 "cd to this dir"
43 +         rlRun "ln -s ../link link" 0 "creating symlink to ../link -> link"
44 +     rlPhaseEnd
45 + 
46 +     rlPhaseStartTest
47 +         rlLog "Test of readlink up to 20 iteration"
48 +         export TMPVAR="link"
49 +         for foo in `seq 20`
50 +           do echo $TMPVAR
51 +             rlRun "readlink -v -f $TMPVAR" 0 "readlink of $TMPVAR"
52 +             TMPVAR="$TMPVAR/link"
53 +         done
54 +     rlPhaseEnd
55 + 
56 +     rlPhaseStartCleanup
57 +         rlRun "popd"
58 +         rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
59 +     rlPhaseEnd
60 + rlJournalPrintText
61 + rlJournalEnd
1 @@ -6,4 +6,4 @@
2     - classic
3     - container
4     roles:
5 -   - { role: standard-test-beakerlib, tests: [ test-basics ] }
6 +   - { role: standard-test-beakerlib, tests: [ test-basics, readlink-cannot-handle-recursive-symlinks ] }