Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!dayton!ems!mark From: mark@ems.UUCP (Mark H. Colburn) Newsgroups: comp.unix.questions Subject: Re: access(2) question Message-ID: <348@ems.UUCP> Date: Thu, 2-Jul-87 18:27:11 EDT Article-I.D.: ems.348 Posted: Thu Jul 2 18:27:11 1987 Date-Received: Sat, 4-Jul-87 08:41:45 EDT References: <530@applix.UUCP> <1341@xanth.UUCP> <1027@killer.UUCP> Reply-To: mark@ems.UUCP (Mark H. Colburn) Organization: EMS/McGraw-Hill, Eden Pairie, MN Lines: 50 Keywords: access permissions After all the discussion about an access call that uses EFFECTIVE user ids rather than real, including my own two cents worth, here is a copy of code that was written by one of the people here to resolve the exact problem that we have been talking about. The routine is called access in order to overlay the system access call when it is linked into the system, so that tempnam and tmpnam work as I wanted them to for the project. The code is trivial, but I thought that some of you might be interested. /* * McGraw-Hill Demo System, Version 2.0 * * access.c - determine accessibility of a file using "effective" user ID. * * Author: Andrew C. Esh, EMS/McGraw-Hill 06/23/86 * * HISTORY * */ #include #include #include unsigned short getuid(); access (path, amode) char *path; int amode; { struct stat buf; int tempmode = 0; if (stat(path, &buf) == -1) { return(-1); } if (geteuid() == buf.st_uid) tempmode = (buf.st_mode & 0x01c0) >> 6; if (getegid() == buf.st_gid) tempmode |= (buf.st_mode & 0x038) >> 3; tempmode |= buf.st_mode & 0x07; if ((amode & tempmode) != amode) { return(-1); } return(0); }