Usefulness of access(2) - (nf)

mark at laidbak.UUCP mark at laidbak.UUCP
Fri Sep 23 15:42:30 AEST 1983


NOTE: This is in response to an article in net.bugs, asking for an
      eaccess() system call to check permissions based on effective
      user- and group-ids. I've added net.unix-wizards to the news
      group list, since it belongs there, but shouldn't be stranded
      from the original article.

Rather than another application-specific system call, how about a
more general solution:

	int permiss(path, uid, gid)
	char	*path;
	int	uid;
	int	gid;

Permiss() determines filesystem permissions to 'path' by user 'uid' in
group 'gid'. Returns a value built up from 04 for read-, 02 for write-
and 01 for execute-access.

Permiss() could even replace access(), with a compatibility function
in libc:

extern int
access(path, mode)
char	*path;
int	mode;
{
	return ((permiss(path, getuid(), getgid()) & mode) == 0 ? -1 : 0);
}

This is still a partially-baked idea, but I believe it to be "cleaner"
than access(), and preferable to adding yet another system call.

			Mark Brukhartz
			..!{allegra,ihnp4,ittvax,trsvax}!laidbak!mark



More information about the Comp.unix.wizards mailing list