bugs in access(2) ?

Guy Harris guy at sun.uucp
Sun Jun 16 14:26:17 AEST 1985


> Bug #1)  A call to "access" root" with multiple permission checks
> on a file on a read-only disk will return an incorrect result.
> 
> Example:
> 	i = access("/ro/foo", 022)
> 	and foo is on a read-only disk, the routine returns a 0
> 	(implied "true").

"access" is always called with IREAD, IWRITE, or IEXEC as its second
argument; it shouldn't be called with a mode like 022, as it shifts the mode
right by 0, 3 or 6 positions, depending on whether you're the owner, not the
owner but in the group that owns the file, or none of the above.

> Bug #2)  Root is shown as having "execute" access to everything.
> 	 This isn't correct for files which are not executable.

In V6, the super-user didn't have execute access unless the appropriate
execute bit was set.  This was changed before V7 came out, so that the
super-user would have search permission on all directories.  In both 4.2 and
S5R2, the "exec" system call requires "access(ip, IEXEC)" to return 0,
requires that the file be a plain file, *and* requires that at least one of
the execute permission bits be set; since the code is almost identical, I
assume that this dates back to when the change was made.  As such, root has
execute access to all files which are executable; this requires that
somebody must have execute permission on the file, so even "root" can't
execute a file with mode rw-r--r--, for instance.

	Guy Harris



More information about the Comp.bugs.4bsd.ucb-fixes mailing list