LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   When can access("blah", R_OK) succeed and open("blah", O_RDONLY) fail? (http://www.linuxquestions.org/questions/programming-9/when-can-access-blah-r_ok-succeed-and-open-blah-o_rdonly-fail-823963/)

cyent 08-03-2010 07:14 PM

When can access("blah", R_OK) succeed and open("blah", O_RDONLY) fail?
 
Here are two sequential lines of an strace of evince.
access("/home/me/.Xauthority", R_OK) = 0
open("/home/me/.Xauthority", O_RDONLY) = -1 EACCES (Permission denied)

Very strangely the corresponding snippet of any other X program I run has...
access("/home/me/.Xauthority", R_OK) = 0
open("/home/me/.Xauthority", O_RDONLY) = 4

Reading The Fine Man pages I cannot understand how access() can succeed and open() fail.

kakaka 08-03-2010 07:33 PM

The interpretation of the *_OK modes can be affected by what sort of User, and the kernel version. Also if the file system is NFS
mounted, NFS can have it's own access mechanisms.

So we could use some additional info. to try to help you.

Does the User "me" or whatever User is using the home directory "/home/me", have root privileges?
Is the kernel version newer than version 2.6.3?
Is "/home/me" on an NFS mounted file system?

cyent 08-03-2010 09:53 PM

Both programs are run as user "me", and the file is owned by me, and has permissions -rw------- and the file system is ext4 on a Lucid Ubuntu system.

cyent 08-03-2010 10:01 PM

Meh! I have found it.

apparmor is to blame.

I had moved my home directory off the smaller solid state root disk to a 500gb harddrive and mounted at it via a symlink.

ie. My home dir is really /disk_1/home/me and I have a symnik /home/me -> /disk_1/home/me

The solution is to run
sudo dpkg-reconfigure apparmor


All times are GMT -5. The time now is 09:05 PM.