edwards@uiucuxc.UUCP (09/23/83)
#N:uiucuxc:5500067:000:849 uiucuxc!edwards Sep 6 22:00:00 1983 The 4.1bsd manual states that access(2) uses a program's real id's to determine access permissions on files/paths, and that this is useful to set-UID programs. Well, It really depends on what you're checking. If a set-UID program wants to do things to privileged areas, then access(2) is NOT useful to those set-UID programs. For example: If your set-UID program wants to see if a directory exists in a privileged area "access to a set-UIDed program or user only," then you can't use access(2) because the real [ug]id of the process wouldn't have access anyway (the purpose for making it Set-UID.) Suggestion: eaccess(2) or equivalent to check for effective id's. What do you think about it? Nasty comments >> /dev/null Alan Edwards University of Illinois @ Urbana-Champaign (...pur-ee!uiucdcs!uiucuxc!edwards)
borman@decvax.UUCP (Dave Borman) (09/26/83)
Access(2) and open(2) should give you all you need. Almost all calls to access that I have seen are followed by an open. You check the permission by ruid with access, and then open the file. If you want to check permission via euid, then just open the file! If you can't access it, the open will fail. If you don't want the file open, you can always close it. If you want the permission bits, there is always stat(2) which will give you everything you ever wanted to know about a file. There is no sense adding a new syscall eaccess(), but if you really want it the function eaccess can be written by using open and stat. (Plus it'll be much more portable) -Dave Borman, decvax!borman (formerly stolaf!borman)