RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1006221 - tail -F does not handle dead symlinks gracefully
Summary: tail -F does not handle dead symlinks gracefully
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils
Version: 6.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ondrej Oprala
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 1035219
TreeView+ depends on / blocked
 
Reported: 2013-09-10 09:17 UTC by Pushpendra Chavan
Modified: 2018-12-03 19:53 UTC (History)
8 users (show)

Fixed In Version: coreutils-8.4-28.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1035219 (view as bug list)
Environment:
Last Closed: 2013-11-21 20:57:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 467053 0 None None None Never
Red Hat Product Errata RHSA-2013:1652 0 normal SHIPPED_LIVE Low: coreutils security, bug fix, and enhancement update 2013-11-20 21:53:21 UTC

Description Pushpendra Chavan 2013-09-10 09:17:25 UTC
Description of problem:
The version of 'tail' that ships with RHEL6.4 appears to be mishandling dead symlinks. 

Version-Release number of selected component (if applicable):
coreutils-8.4-19.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
Please follow these precise steps in order to reproduce the errant behavior.  I've prefixed each command with T1 or T2, to indicate whether that command should be run in the first terminal (T1) or the second (T2).  The commands should be run in this precise order.

T1: touch logfile
T1: ln -s logfile logfile-link
T2: tail -F logfile-link
T1: echo "line 1" >> logfile
T2: observe "line 1" from tail
T1: rm logfile
T2: observe "tail: `logfile-link' has become inaccessible: No such file or directory"
T1: echo "line 2" >> logfile
T2: observe that tail is no longer tracking the contents of 'logfile'

Here is the terminal demonstration.

~~~~~~~~~~~~~~~~~~~~~
On Red Hat Enterprise Linux 5:
~~~~~~~~~~~~~~~~~~~~~

Terminal#1:

[root@dhcp223-183 ~]# mkdir /tmp/test
[root@dhcp223-183 ~]# cd /tmp/test
[root@dhcp223-183 test]# touch logfile
[root@dhcp223-183 test]# 
[root@dhcp223-183 test]# ln -s logfile logfile-link
[root@dhcp223-183 test]# echo "line 1" >> logfile
[root@dhcp223-183 test]# rm -rf logfile
[root@dhcp223-183 test]# echo "line 2" >> logfile

Terminal#2:

[root@dhcp223-183 ~]# cd /tmp/test/
[root@dhcp223-183 test]# tail -F logfile-link 
line 1
tail: `logfile-link' has become inaccessible: No such file or directory
line 2

It started appending the new lines.

~~~~~~~~~~~~~~~~~~~~~
Whereas on Red Hat Enterprise Linux 6:
~~~~~~~~~~~~~~~~~~~~~

Terminal#1:

[root@dhcp223-116 ~]# mkdir /tmp/test
[root@dhcp223-116 ~]# cd /tmp/test
[root@dhcp223-116 test]# touch logfile
[root@dhcp223-116 test]# ln -s logfile logfile-link
[root@dhcp223-116 test]# echo "line 1" >> logfile
[root@dhcp223-116 test]# rm logfile
rm: remove regular file `logfile'? y
[root@dhcp223-116 test]# echo "line 2" >> logfile
[root@dhcp223-116 test]# ls
logfile  logfile-link
[root@dhcp223-116 test]# echo "line 2" >> logfile
[root@dhcp223-116 test]# ll
total 4
-rw-r--r-- 1 root root 14 Sep  6 10:53 logfile
lrwxrwxrwx 1 root root  7 Sep  6 10:47 logfile-link -> logfile

Terminal#2:

[root@dhcp223-116 ~]# cd /tmp/test
[root@dhcp223-116 test]# tail -F logfile-link
line 1
tail: `logfile-link' has become inaccessible: No such file or directory


^C

Here the new incoming text was not appended in tail -F output on terminal 2.


Actual results:
Tail should notice when it's monitoring a dead symlink, and "wake up" when the symlink is no longer dead, and monitor the referent's content.

Expected results:
Its not monitoring it.

Additional info:
This works on Red Hat Enterprise Linux 5 as expected.

Comment 2 Paul Krizak 2013-09-10 16:23:30 UTC
(In reply to Pushpendra Chavan from comment #0)

> Actual results:
> Tail should notice when it's monitoring a dead symlink, and "wake up" when
> the symlink is no longer dead, and monitor the referent's content.
> 
> Expected results:
> Its not monitoring it.

The expected and actual results are backwards.  The actual result (in RHEL6) is that tail -F ignores updates to the referent of a symlink after the symlink is killed (the referent is removed).  The expected results are like in RHEL5: tail notices when the dead symlink is revived and resumes tailing the contents of the referent.

Comment 3 Ondrej Vasik 2013-09-11 11:09:32 UTC
The difference is that RHEL-6 is using inotify and RHEL-5 is using polling. You can kind of restore the RHEL-5 behaviour with using ---disable-inotify (intentionally undocumented option, as polling mode is considered deprecated). Still probably worth to fix in tail.
Issue still occurs even with coreutils-8.21.

Comment 9 errata-xmlrpc 2013-11-21 20:57:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-1652.html

Comment 10 Pádraig Brady 2014-09-04 11:50:18 UTC
Note the fix for this is too noisy, reporting the following "error" for any symlinks:
  https://www.centos.org/forums/viewtopic.php?f=14&t=48255

The upstream fix silently reverted to polling:
  http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=ba6582e

Comment 14 Pádraig Brady 2014-10-14 09:16:54 UTC
This is now public: https://bugzilla.redhat.com/show_bug.cgi?id=1006221#c10
Basically the downstream fix for that was too noisy.
Upstream doesn't bleat about this implementation detail.


Note You need to log in before you can comment on or make changes to this bug.