Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!bu-cs!budd From: budd@bu-cs.BU.EDU (Philip Budne) Newsgroups: net.unix-wizards Subject: fchmod(2) under SUN 3.0 Message-ID: <1126@bu-cs.bu-cs.BU.EDU> Date: Wed, 27-Aug-86 18:21:56 EDT Article-I.D.: bu-cs.1126 Posted: Wed Aug 27 18:21:56 1986 Date-Received: Wed, 27-Aug-86 21:48:42 EDT Organization: Boston U. Comp. Sci. Lines: 27 Keywords: sun fchmod credentials 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.