Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!budd@BU-CS.BU.EDU From: budd@BU-CS.BU.EDU (Philip Budne) Newsgroups: net.unix-wizards Subject: fchmod in SUN 3.0 Message-ID: <3362@brl-smoke.ARPA> Date: Wed, 27-Aug-86 18:22:49 EDT Article-I.D.: brl-smok.3362 Posted: Wed Aug 27 18:22:49 1986 Date-Received: Thu, 28-Aug-86 21:32:28 EDT Sender: news@brl-smoke.ARPA Lines: 27 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.