On 11/06/2014 07:59 PM, Linda Walsh wrote:
Bernhard Voelker wrote:
On 11/07/2014 01:57 AM, John Andersen wrote:
- -- Explain again the part about rm -rf /
Just saw this in the signature. Actually this is not as scary as one might expect. (The braver ones among you may already have tried it in a snapshotted VM.)
POSIX mandates to skip operands that resolve to the root directory (as well as to "." and ".."). [0]
A good reason not to use POSIX compliant utilities.
W/R/T : rm --one-file-system -fr /tmp/.)
/tmp/root@ => / /tmp/mroot (mount -o bind / /tmp/mroot).
If you use the new posix 'rm' and the suggested workaround: "use *", as in "cd /tmp && rm --one-file-system -fr *" -- in both cases the symlink'ed dir is followed (as "rm" never sees the symlink which is resolved to the root file system before 'rm' ever sees it).
And "--one-file-system" won't protect either, as it only stops deletion if a sub-dir is on a different fs from the cmd-line arguments, but since you used "*", that will be pre-expanded to 'mroot' before 'rm' sees it. So again, no protection.
Used to be rm -fr dir/. was the safest way to clean out a directory, *w/o* deleting the directory. I used it all the time to delete tmp dir contents (not usually '/tmp', but others). Now, there is no easy way. You need to use some incarnation of 'find', with
find / -delete find /tmp/. delete
replacing the previous rm based "solutions".
Neat thing about find / -delete, is that it *seems* (not going to test it here!) to have no protections -- unlike "rm -fr /" where you had to specify some arg to override the default.
I Liked it better when we were discussing systemd rather than obsessing over my casual sig line. ;-) We are nothing if not pedantic around here these days. -- Explain again the part about rm -rf / -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org