From owner-freebsd-questions Thu Dec 6 4:36:31 2001 Delivered-To: freebsd-questions@freebsd.org Received: from freebie.atkielski.com (ASt-Lambert-101-2-1-14.abo.wanadoo.fr [193.251.59.14]) by hub.freebsd.org (Postfix) with ESMTP id 7D5A737B416 for ; Thu, 6 Dec 2001 04:36:25 -0800 (PST) Received: from contactdish (contactdish.atkielski.com [10.0.0.10]) by freebie.atkielski.com (8.11.3/8.11.3) with SMTP id fB6CaAx09182; Thu, 6 Dec 2001 13:36:10 +0100 (CET) (envelope-from anthony@freebie.atkielski.com) Message-ID: <00bb01c17e52$96093b50$0a00000a@atkielski.com> From: "Anthony Atkielski" To: "Cliff Sarginson" , "FreeBSD Questions" References: <009101c17c12$649fe2e0$0a00000a@atkielski.com> <20011206122233.GB1111@raggedclown.net> Subject: Re: Modifying only certain bits with chmod Date: Thu, 6 Dec 2001 13:36:10 +0100 Organization: Anthony's Home Page (development site) MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 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 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. > 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. > 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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message