Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This one made me LOL:

   My mistake on SunOS (with OpenWindows) was to try and clean up all the
   '.*' directories in /tmp. Obviously "rm -rf /tmp/*" missed these, so I
   was very careful and made sure I was in /tmp and then executed
   "rm -rf ./.*".

   I will never do this again. If I am in any doubt as to how a wildcard
   will expand I will echo it first.
I read this, and just had to go try it because I couldn't picture it in my brain. Here it is:

   $ echo ./.*
   ./. ./..
So if you're in /tmp/ and do 'rm -rf ./.*', it's

  rm -rf ./. ./..
and ./.. is .. which from tmp is /. Thankfully we have protections against this now. Back then, not so much.


As a brand-new UNIX user around 1991 and coming from MSDOS, I was used to being 'God' on my machine so I thought it would be a good idea to login always as 'root'. I couldn't understand why long-time users of UNIX knew that to be a very bad idea, and always advised against it.

Like the SunOS person, I had lots of dot-directories in /tmp. So I duplicated his actions almost perfectly.

Also like he did, I was wondering why an 'instantaneous' action was taking so long. I had to do a complete re-installation.

Ever since then, I've always logged in as a 'normal user'. My reign as 'God' in a UNIX environment lasted about 2-3 weeks in total.


Huh, what do you know. I thought modern rm only protected against deleting / by absolute path, but it looks like it'll protect you from deleting your parent regardless:

    $ docker run --rm -ti debian:11  # sandbox the danger...
    root@c70dde9f38a3:/# cd /tmp
    root@c70dde9f38a3:/tmp# rm -rf ./.
    rm: refusing to remove '.' or '..' directory: skipping './.'
    root@c70dde9f38a3:/tmp# mkdir -p /tmp/1/2/3/4/5
    root@c70dde9f38a3:/tmp# cd /tmp/1/2/3/4/5
    root@c70dde9f38a3:/tmp/1/2/3/4/5# rm -rf ./.
    rm: refusing to remove '.' or '..' directory: skipping './.'


Interestingly

  $ bash -c 'cd /var/empty; echo .*'
  . ..
but

  $ ksh -c 'cd /var/empty; echo .*'
  .*
Seems some ksh dev got bitten and restricted this ...


Actually this is exactly what Oracle installer did in 93-94 after a jr sysadmin tried to install it from /tmp.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: