Description of problem: The readlink command fails with an error "Too many levels of symbolic links", even if there are only 2 levels. The readlink command from RHEL 3 and RHEL 4 and from Fedora 11 all work fine. 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: /* Detect loops. We cannot use the cycle-check module here, since it's actually possible to encounter the same symlink more than once in a given traversal. However, encountering the same symlink,NAME pair twice does indicate a loop. */ http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/canonicalize.c;h=4f348398fd69ae516396313d18ac294a4ca3dde3;hb=b653eda3ac4864de205419d9f41eec267cb89eeb#l262 The latest canonicalize.c uses seen_triple() instead of cycle_check(). Version-Release number of selected component (if applicable): coreutils-5.97-19.el5 How reproducible: every time Steps to Reproduce: 1. Create a directory with a symlink to itself mkdir /tmp/dir cd /tmp/dir ln -s ../dir dirlink 2. Run readlink using the 'dirlink' symlink recursively readlink -v -f dirlink readlink -v -f dirlink/dirlink readlink -v -f dirlink/dirlink/dirlink Actual results: The first readlink command on just dirlink succeeds, but the 2nd and 3rd commands fail with readlink: dirlink/dirlink: Too many levels of symbolic links Expected results: $ readlink -v -f dirlink /tmp/dir $ readlink -v -f dirlink/dirlink /tmp/dir $ readlink -v -f dirlink/dirlink/dirlink /tmp/dir Additional info:
Created attachment 351304 [details] patch to fix readlink I've backported the changes from upstream to use seen_triple() instead of cycle_check().
This request was evaluated by Red Hat Product Management for inclusion, but this component is not scheduled to be updated in the current Red Hat Enterprise Linux release. If you would like this request to be reviewed for the next minor release, ask your support representative to set the next rhel-x.y flag to "?".
pm_ack for RHEL 5.4.z.
(In reply to comment #1) > Created an attachment (id=351304) [details] > patch to fix readlink The patch looks good and solves the problem for me.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: When a directory contained a symbolic link to itself, the readlink command incorrectly gave the following error message when attempting to read the value of the symbolic link : "Too many levels of symbolic links". With this update, readlink is once again able to correctly resolve the value of the recursive symbolic links to containing directories, or "directory loops".
Technical note updated. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. Diffed Contents: @@ -1 +1 @@ -When a directory contained a symbolic link to itself, the readlink command incorrectly gave the following error message when attempting to read the value of the symbolic link : "Too many levels of symbolic links". With this update, readlink is once again able to correctly resolve the value of the recursive symbolic links to containing directories, or "directory loops".+When a directory contained a symbolic link to itself, the readlink command incorrectly gave the following error message: "Too many levels of symbolic links". With this update, the readlink command is able to correctly resolve values of recursive symbolic links to directories and no error messages are given.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-1074.html