ntang (ntang) wrote,
ntang
ntang

  • Mood:

Holy shit, batman

gnu vi/bash are fucked up and buggy, check this crap out.

As root:

cd /tmp
mkdir foo; cd foo
mkdir bar; cd bar
cat "this is a test" > foo.txt
chown [your username] foo.txt
chmod go-rwx ../bar
chmod go-rwx ../../foo
su [your username]
vi foo.txt

what happens? No, not permission denied, as it should do. It says "new file". Why? strace it. The stupid program CHANGES INTO YOUR HOME DIRECTORY without warning and does it in there. HELLO?!

The proper response: "permission denied".

To elaborate: as user [you], you have rw access to foo.txt. However, the directory it's in (/tmp/foo/bar), and its parent directory (/tmp/foo) you have neither read nor execute permissions for. So you can't actually change directories to get to that file or take a directory listing to see it. But because you su'd without the dash, it leaves you in the directory you have no access to. A sun box will correctly tell you "permission denied". A linux box (the ones I've tested anyway) will silently change directory into your home directory when you try to vi the file, but only for vi. So vi will be operating out of your home directory while your pwd is still /tmp/foo/bar. That is SO STUPID.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment