-/* Like euidaccess, except that a pointer to a filled-in stat structure
- describing the file is provided instead of a filename.
- Because this function is almost guaranteed to fail on systems that
- use ACLs, a third argument *PATH may be used. If it is non-NULL,
- it is assumed to be the name of the file corresponding to STATP.
- Then, if the user is not running set-uid or set-gid, use access
- instead of attempting a manual and non-portable comparison. */
-
-static int
-eaccess_stat (statp, mode, path)
- const struct stat *statp;
- int mode;
- const char *path;
-{
- int granted;
-
- mode &= (X_OK | W_OK | R_OK); /* Clear any bogus bits. */
-
- if (mode == F_OK)
- return 0; /* The file exists. */
-
- if (have_ids == 0)
- {
- have_ids = 1;
- uid = getuid ();
- gid = getgid ();
- euid = geteuid ();
- egid = getegid ();
- }
-
- if (path && uid == euid && gid == egid)
- {
- return access (path, mode);
- }
-
- /* The super-user can read and write any file, and execute any file
- that anyone can execute. */
- if (euid == 0 && ((mode & X_OK) == 0
- || (statp->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))))
- return 0;