Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!husc6!necntc!frog!john From: john@frog.UUCP Newsgroups: comp.unix.questions Subject: Re: Why does access(2) use real user and group IDs? Message-ID: <1959@frog.UUCP> Date: Fri, 4-Dec-87 15:00:00 EST Article-I.D.: frog.1959 Posted: Fri Dec 4 15:00:00 1987 Date-Received: Wed, 9-Dec-87 21:08:15 EST References: <957@woton.UUCP> Organization: Superfrog Heaven [ CRDS, Framingham MA ] Lines: 33 Keywords: System V, access(2), real vs. effective IDs In article <957@woton.UUCP>, riddle@woton.UUCP (Prentiss Riddle ) writes: > A colleague of mine was tinkering with a program that runs in setuid > mode when she ran into the following little puzzle: > Why is it that in SVR2.1 (and maybe in other Unixes too) the access(2) > function uses the real user ID and group ID instead of the effective ones? > ...Of course, it wouldn't be hard to use stat(2) to write a substitute > routine called "eaccess()" which do the same thing using the effective > IDs, but that leaves the nagging question: is there a good reason for > access(2) to behave as it does? The short answer is that access() has always done that so that setuid-root programs can (try to) determine if you deserve access to a file (which root will, of course, be granted). The problem with an eaccess() routine (and with access() as well, really) is that there isn't any guarantee that, between the time that you check for permission to use a file and the time you actually hammer it, the access modes won't change so that you can't (shouldn't) be allowed to hammer the file. Since eaccess() tells you little, if anything, that you won't learn by actually DOING the operation and staring at errno when it fails, it seems to me that you might as well do it. access() is intended to let superuser programs restrain their might when needed :-). -- John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101 ...!decvax!frog!john, ...!mit-eddie!jfw, jfw@eddie.mit.edu "Cutting the space budget really restores my faith in humanity. It eliminates dreams, goals, and ideals and lets us get straight to the business of hate, debauchery, and self-annihilation." -- Johnny Hart