In my C++ Carbon app, I need to be able to determine what file/
directory access permissions I have without actually doing
anything. There’s a Unix function named “access()” that does
exactly what I want…almost. My problem is that I’m running with a
different effective user id than the real user id because my setuid
bit is set. In this case, access() uses the real user id, but I
want information based on the effective user id. I tried using
setuid() to change the real user id to the effective user id, but
that call doesn’t do anything despite the fact that the man page
says that you can always change the real uid to the effective uid.
Access() doesn’t seem to be an option for me. SO…
How else can I determine the permissions that my process has in
relation to a particular directory or file? Are there Carbon
functions that will let me do this? Is there any sample code about
that will demonstrate how to do this? Alternatively, can anyone
tell me how to get the access() function to tell me about the
effective user’s permissions?
Is your eventual goal to determine, in advance, whether you would
actually be able to open or modify a file? If so, keep in mind that
this question is essentially unsolvable if you want a completely
reliable solution. There will always be some cases where an advance
test will fail. For example, with the introduction of access control
lists in Tiger, it might appear from the file's permissions that you
could open it, but you really wouldn't be able to. Or, even without
ACLs, if the file is on a server, its permissions might be changed
after you check the permissions but before you attempt to open the file.
The only truly reliable way to determine if you can open a file (or
read a directory, create a file, etc), is to just try the operation.
-eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden