readlink bugs

Bernhard Fischer rep.nop at aon.at
Sat Oct 21 15:50:06 UTC 2006


On Fri, Oct 20, 2006 at 08:35:54PM +0200, Denis Vlasenko wrote:
>On Friday 20 October 2006 12:20, Bernhard Fischer wrote:
>> A few observations about the current readlink (bugs):
>> $ rm -f no ../no ; touch yep
>> $ for i in '' ./busybox;do $i readlink no;echo ret=$?;done
>> ret=1
>> readlink: no: No such file or directory
>> ret=1
>> $ emits wrong perror (see comment in the patch)
>> 
>> $ for i in '' ./busybox;do $i readlink yep;echo ret=$?;done
>> ret=1
>> readlink: yep: Invalid argument
>> ret=1
>> $ again, emits perror wrongly
>
>Fixing.... LOGMODE_NONE will help in both cases.

Ah, thanks for the hint.

>> $ for i in '' ./busybox;do $i readlink -f no;echo ret=$?;done
>> /tmp/busybox/no
>> ret=0
>> ret=1
>> $ does not emit nor normalize fname (see comment)
>
>One from coreutils-5.2.1 doesn't either.
>Maybe your shell has readlink builtin which is different?

No, it's the one from coreutils
$ dpkg -S /bin/readlink 
coreutils: /bin/readlink
$ dpkg -l coreutils | tail -n 1
ii  coreutils      5.97-5         The GNU core utilities

$ /bin/readlink -f /tmp/no_such_file;echo $?
/tmp/no_such_file
0
$ /bin/readlink --version /tmp/no_such_file;echo $?
readlink (GNU coreutils) 5.97
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the
terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Dmitry V. Levin.
0

Since several scripts use -f, i think it's worthwile to fix this case.
Otherwise the applet is not really useable. So.. any better idea on how
to fix this for good? There could be more applets that potentially need
to normalize pathes (i.e. collaps them), didn't look which these may be,
though.

Thoughts?

>> $ for i in '' ./busybox;do $i readlink -f ../no;echo ret=$?;done
>> /tmp/no
>> ret=0
>> ret=1
>> $ same as for ./no
>
>Thanks for the bug report and patch.
>I am going to commit attached.

Thanks!



More information about the busybox mailing list