troubleshooting Question

POSIX file checking semantics

Avatar of perlperl
perlperl asked on
Unix OSLinuxC
6 Comments1 Solution548 ViewsLast Modified:
I am trying to understand why does POSIX behaves in this wierd manner.

1) I created two users "user_a" and "user_b" and both belongs to same "group"

2) sudo "user_a".
   a) Created a Dir /home/users/dir_1.  The owner is "user_a" and permission is 777.    
   b) Created a file /home/user/dir_1/file.txt with permission 644 and owner is "user_a"

3) sudo "user_b"
    a) cd /home/user/dir_1
    b) echo "test" >> file.txt     fails with "Permission Denied" as expected.
    c) vi file.txt opens the file warns its a "Read Only" mode. Then I write at the end of file and close vi with !wq.  BOOM, the write succeeded and I verified using cat that the write got commited to the disk.

Why on earth Unix allows to write using 3.c but fails during 3.b.
 3.c should have failed with "permission denied" but it does not
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros