Bug 1083

Summary: [PATCH] lndir doesn't handle symlink to directory right
Product: xorg Reporter: H.J. Lu <hjl>
Component: App/otherAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: high CC: esigra
Version: unspecified   
Hardware: x86 (IA32)   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 351    

Description H.J. Lu 2004-08-15 08:51:18 UTC
lndir handles symlink to directory differently, depending on when the
symlink is created:

[hjl@gnu-64 lndir]$ cat Makefile
LNDIR=lndir
 
all: bad good
 
bad:
        rm -fr 1 2
        mkdir 1
        ln -s . 1/foo
        mkdir 1/bar
        mkdir 2
        cd 2 && $(LNDIR) ../1
 
good:
        rm -fr 3 4
        mkdir 3
        mkdir 3/bar
        ln -s . 3/foo
        mkdir 4
        cd 4 && $(LNDIR) ../3
[hjl@gnu-64 lndir]$ make
rm -fr 1 2
mkdir 1
ln -s . 1/foo
mkdir 1/bar
mkdir 2
cd 2 && lndir ../1
../1/foo:
../../1/foo/foo:
../../../1/foo/foo/foo:
../../../../1/foo/foo/foo/foo:
../../../../../1/foo/foo/foo/foo/foo:
../../../../../../1/foo/foo/foo/foo/foo/foo:
../../../../../../../1/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo:
../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo:
../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../1/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../1/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../1/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo:
../../../../../../../../../../../../../../../../../../../../../../../../1/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../1/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../1
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo:../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../1/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/fo
o/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
Too many levels of symbolic links
../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../1/foo/foo/foo/foo/foo/foo/foo/foo/f
oo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/
foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/bar:
rm -fr 3 4
mkdir 3
mkdir 3/bar
ln -s . 3/foo
mkdir 4
cd 4 && lndir ../3
../3/bar:
[hjl@gnu-64 lndir]$
Comment 1 H.J. Lu 2004-08-15 08:52:52 UTC
This patch fixed the problem for me:

--- xc/config/util/lndir.c.symlink	2004-03-04 09:45:53.000000000 -0800
+++ xc/config/util/lndir.c	2004-08-13 12:43:02.008852729 -0700
@@ -194,7 +194,7 @@ dodir (char *fn,		/* name of "from" dire
 	strcpy (p, dp->d_name);
 
 	if (n_dirs > 0) {
-	    if (stat (buf, &sb) < 0) {
+	    if (lstat (buf, &sb) < 0) {
 		mperror (buf);
 		continue;
 	    }
Comment 2 Mike A. Harris 2004-08-18 05:09:58 UTC
Adding Red Hat bugzilla cross-reference:

    https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=129887
Comment 3 Mike A. Harris 2004-08-21 06:55:24 UTC
kem)

While this isn't mission critical per-se, I'm adding to blocker bug for
possible consideration for inclusion in 6.8.0.
Comment 4 Kevin E. Martin 2004-08-25 22:11:09 UTC
This patch was discussed on the release wranglers call and was accepted for this
release.  It has been checked in.  Closing.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.