From owner-freebsd-questions Thu Dec 6 5: 5:12 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 4118B37B41A for ; Thu, 6 Dec 2001 05:05:07 -0800 (PST) Received: from [212.238.194.207] (helo=tanya.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.33 #1) id 16ByD3-000ChP-00 for freebsd-questions@FreeBSD.ORG; Thu, 06 Dec 2001 13:05:05 +0000 Received: by tanya.raggedclown.net (tanya.raggedclown.net, from userid 500) id DB8C8111E; Thu, 6 Dec 2001 14:05:04 +0100 (CET) Date: Thu, 6 Dec 2001 14:05:04 +0100 From: Cliff Sarginson To: FreeBSD Questions Subject: Re: Modifying only certain bits with chmod Message-ID: <20011206130504.GA9605@raggedclown.net> References: <009101c17c12$649fe2e0$0a00000a@atkielski.com> <20011206122233.GB1111@raggedclown.net> <00bb01c17e52$96093b50$0a00000a@atkielski.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00bb01c17e52$96093b50$0a00000a@atkielski.com> User-Agent: Mutt/1.3.24i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Dec 06, 2001 at 01:36:10PM +0100, Anthony Atkielski wrote: > Cliff writes: > > > And pray nothing else that depends on standard > > chmod doesn't try to use it. > > The modification is backward-compatible. All I did was add an optional mask field to the the octal mode field, i.e., you can > specify "400:600" instead of just "400", meaning "set the owner's read bit and reset the owner's write bit on this file, and leave > the other bits alone." Unless a script or something depended on this specific format generating an _error_ message (a very unsafe > way to write a script), nothing will see the change. > > > If you are going to do this kind of thing you > > really should not do it in such a way that the > > "real" system program you are replacing is not > > somehow called if the caller expects it. > > If the change were not compatible with the "real" command, I would agree. However, I took care to make sure that this change is > indeed compatible. The only way any program could see it would be if it deliberately depended on receiving an error status from > chmod for the specific error of specifing "xxx:yyy" for the mode, where xxx and yyy are both valid octal numbers. I consider that > highly unlikely; hopefully nobody programs that badly. > What is highly unlikely often happens. > > For example, front-ending "rm" with a safe version > > which saves the rm'ed files somewhere - a common > > practise - is one thing. > > Is it? That sounds far less safe than the change I've made. A script or program using rm to free disk space would be useless if > the behavior of the command were changed in that way. You might see a disk fill in the middle of the night, which wouldn't be fun. > Well, you have obviously never been a system manager. Such a script (the front end) would be implemented by a System Manager. The latter would also be under his/her control and he/she would be aware of how to call the real rm in this case. Besides which System management practise would dictate you are given warnings of impending disk space shortage. > > All a mystery to me, you don't need to be Albert > > Einstein to learn the symbolic arguments for > > changing particular modes on a file. > > The symbolic arguments are far less intuitive for me, whereas bitwise operations are easy. > There are better ways of doing this than changing system program source code. -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message