Bug 1013171 - rm gets concept of "write-protected" wrong
rm gets concept of "write-protected" wrong
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
21
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Pádraig Brady
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-27 20:08 EDT by JW
Modified: 2016-01-04 09:47 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-01 21:58:52 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description JW 2013-09-27 20:08:37 EDT
Description of problem:
When a root-owned write-protected file is encountered "rm" will silently remove it for user root only.

Version-Release number of selected component (if applicable):
oreutils-8.21

How reproducible:
Always

Steps to Reproduce:
1. touch testfile
2. chmod -w testfile
3. rm testfile

Actual results:
As a non-root user result is prompt "remove write-protected regular empty file 'testfile'".
For root user the result is silent removal of file.

Expected results:
root should also be prompted, just like an ordinary user

Additional info:
What is a "write-protected" file?  It is a file with write permission mode bits turned off.  The fact that root user is able to remove the file is neither here nor there. By turning off the write mode bits the "intent" is to write-protect the file. Therefore ALL users should be prompted to remove such a write-protected file. This is not only for consistency but also so as the obey the intent behind clearing the write mode bits.
Comment 1 Pádraig Brady 2013-09-27 22:10:34 EDT
I agree with this report.
I think this may have regressed in http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commit;h=1efda4fa (i.e. 6.9.90)
See the use of can_write_any_file() in src/remove.c there.
I'll look into this upstream. thanks
Comment 2 Pádraig Brady 2013-09-27 22:23:28 EDT
Actually looking a little deeper, the above commit does look like a valid optimization. The "write-protected" check is done with the more general access(2) call, rather than checking write bits. Therefore this would never be write-protected for root. Also while consistent with non root users, doing this would be a fairly big change in behavior that may impact various scripts.
I need to think about this a bit more.
Comment 3 Pádraig Brady 2013-11-15 13:33:26 EST
Closing this as I don't think we should be checking mode bits here.
There could be other ACLs etc. used to protect the data, so the
more general check is appropriate.

I.E. The check is essentially that, if the user can't modify the data,
then warn about unreferencing that data.

Since root can modify the data, the extra unreferencing check is not appropriate.
Comment 4 JW 2013-11-15 22:39:50 EST
I most vehemently disagree with your decision.

Supposing, for example, that one wanted to prevent a file from being deleted even by root. Well, not "prevent" but to make it a very visible decision that needs to be made.  How does one achieve that? The only real standard method is to turn off the write bits.

In all unix's I have ever encountered, or in all systems that claimed to be unix-like, root will ALWAYS be warned when attempting to remove a write-protected file. That is the whole point of write-protection.

Being root means being able to do anything, but that should not mean the removal of normal cautionary advice when deleting a write-protected file.

Your decision to do nothing makes the environment for root user on Linux a much more dangerous place. It is a very bad decision.

BTW how come you initially agreed with the report, only to back down and close the bug without any change. Too hard to change? And it took two months to "think about it". Or are you being pushed to close as many bugs as possible, preferably without any resolution, so as to meet latest (and ridiculous) impending 6-month deadline?
Comment 5 Pádraig Brady 2013-11-16 15:13:58 EST
Well the "whole point of write-protection", is preventing a user from opening a file in write mode. Since root can write to the file in various ways, adding the extra protection of a prompt here wouldn't help much I think. More importantly this would be a large change that could have backward compatibility issues for scripts.

I checked POSIX and it has no mention of this subject at all.

Now you can achieve what you want on most file systems by using `chattr +i file`
(and BSD has the equivalent chflags(1) command)
Comment 6 JW 2013-11-16 17:34:45 EST
That is correct. For example, if you open a write-protected file with "vi" then you get a warning "[readonly]". And if you go further and make changes you get another warning "W10: Warning: Changing a readonly file". And when you try to write it out another warning "E45: 'readonly' option is set (add ! to override)".

But, with "rm" you get nothing!!!!!!!!!!!!!!!!!!

See what the problem is?  Every application, EXCEPT rm, takes the business of readonly and write-protection seriously.

The problem is that rm is broken and it has become more lame and stupid in this area than any other application. It has also become overly complex, which is probably the fundamental cause of its brokenness.
Comment 7 Fedora End Of Life 2015-01-09 17:19:08 EST
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 8 Fedora End Of Life 2015-11-04 10:45:41 EST
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 9 Fedora End Of Life 2015-12-01 21:58:57 EST
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

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