fchmod in SUN 3.0

Philip Budne budd at BU-CS.BU.EDU
Thu Aug 28 08:22:49 AEST 1986


SYMPTOM:
	fchmod(2) fails on unredirected stdin.

	The following program fails with "Not owner" under SUN 3.0,
	but works under VAX BSD 4.2;

	main() {
	    if( fchmod(0, 0777) < 0 )
		perror( "fchmod" );
	}

DIAGNOSIS:

	in vfs_syscalls the routine fdsetattr passes the credentials of
	the file desriptor (opened long ago by init):

		error = VOP_SETATTR(vp, vap, fp->f_cred);

	namesetattr (used by chmod) passes the user's credentials:

		error = VOP_SETATTR(vp, vap, u.u_cred);

	fdsetattr is called only by fchmod and fchown.  fchown requires super
	user, and thus never sees the problem.

CURE:
	always pass the user's credentials.



More information about the Comp.unix.wizards mailing list