Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!jsq From: karish@mindcraft.com (Chuck Karish) Newsgroups: comp.std.unix Subject: Re: Retaining file permissions Summary: Changing set-user-id bit on write Message-ID: <18349@cs.utexas.edu> Date: 5 Mar 91 23:46:58 GMT References: <6039@ptsfa.PacBell.COM> <1991Feb22.041826.201@athena.mit.edu> <1991Feb23.234242.812@am.sublink.org> <1991Feb26.153931.27251@athena.mit.edu> <18296@cs.utexas.edu> Sender: jsq@cs.utexas.edu Organization: Mindcraft, Inc. Lines: 28 Approved: jsq@cs.utexas.edu (Moderator, John S. Quarterman) X-Submissions: std-unix@uunet.uu.net Submitted-by: karish@mindcraft.com (Chuck Karish) In article <18296@cs.utexas.edu> alex@am.sublink.org (Alex Martelli) writes: >So, what DOES Posix say about this (open(), write(), >cat, shell redirection, and permission bits), and what SHOULD it say? POSIX.1 clause 5.6.1.2, descriptions of S_ISUID and S_ISGID bits: "On a regular file, this bit should be cleared on any write." Note the word "should". This is a recommendation to implementors, not a requirement. BSD 4.3 write(2) man page: "If the real user is not the super-user, then write() clears the set-user-id bit on a file." Interactive man pages for stat(2), write(2), and chmod(2) are silent on this issue. POSIX.2 is pretty much constrained to accept as valid behavior that's allowed/suggested by POSIX.1. I don't think there are any requirements that the utilities second-guess and defeat the file access policies that could legitimately be imposed by an underlying POSIX.1 operating system. Chuck Karish karish@mindcraft.com Mindcraft, Inc. (415) 323-9000 Volume-Number: Volume 22, Number 140