Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
Description of problem:
if use "sed -i " edit a symbolic link, will change this link to a regular file and no longer a symbolic link. sed version is 4.2.1.
Version-Release number of selected component (if applicable):
How reproducible:
On RHEL 6.2:
# touch a
# ln -s a b
# ll b
lrwxrwxrwx 1 root root 1 May 9 01:06 b -> a
# sed -i '/test/d' b
# ll b
-rw-r--r-- 1 root root 0 May 9 01:06 b
# sed --version
GNU sed version 4.2.1
On RHEL 5.4:
# touch a
# ln -s a b
# ll b
lrwxrwxrwx 1 root root 1 May 9 17:09 b -> a
# sed -i '/test/d' b
sed: ck_follow_symlink: couldn't lstat b/a: Not a directory
# sed -i '/test/d' $PWD/b
# ll b
lrwxrwxrwx 1 root root 1 May 9 17:09 b -> a
# sed --version
GNU sed version 4.1.5
Steps to Reproduce:
1.
2.
3.
Actual results:
sed -i should edit target file of symbolic link.
Expected results:
Additional info:
I'm reopening this bug as this is bad.
e.g. someone could unknowingly do a sed -i edit on /etc/grub.conf
And the link is removed and file replaced.
Now when kernel is updated form a patch.
It does a readlink
grubConfig=$(readlink -f /etc/grub.conf 2>/dev/null)
But seems to work fine on regular file.
And hence /boot/grub/grub.conf is not updated.
So on reboot you don't boot to the patched kernel.
Fixing the link and reboot resolves the issue but this seems bad in my view.
I think the default handling of sed -i on links should error out mentioning to run the sed -i on the target and or use the --follow-symlinks
TBH, I don't think this should be changed in RHEL 6 - given the fact we are now in production phase 2. It is change in behaviour and can potentially break something. In addition, behaviour is still the same in RHEL 7.
I agree with Ondrej. I understand Dave's opinion but it is somthing what could be fixed in rawhide after discussion with upstream. For me it's similar to gzip, which by default removes original file when --keep option isn't used.
I know, it's not same, but point says that you should read manual at first. And really, if this is sou expected behaviour, shouldn't be this fixed rather by some alias for root like e.g. "rm" uses "-i"? Yes, this is ugly solution too. But to be honest, not uglier than above.
We should'n just change behaviour because we expect user will not read manual, otherwise we can "redesign" half of system.
When Red Hat shipped 6.8 on May 10, 2016 RHEL 6 entered Production Phase 2.
https://access.redhat.com/support/policy/updates/errata#Production_2_Phase
That means only "Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released"
This BZ is now going to be closed as it does not appear to meet Phase 2 criteria.
If this BZ is deemed critical please open a support case in the Red Hat Customer Portal and as that this BZ be re-opened so it can be re-evaluated for 6.9.