Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Dec 2001 13:36:10 +0100
From:      "Anthony Atkielski" <anthony@freebie.atkielski.com>
To:        "Cliff Sarginson" <cliff@raggedclown.net>, "FreeBSD Questions" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Modifying only certain bits with chmod
Message-ID:  <00bb01c17e52$96093b50$0a00000a@atkielski.com>
References:  <009101c17c12$649fe2e0$0a00000a@atkielski.com> <Pine.GSO.4.31.0112061049360.6883-100000@mail.ilrt.bris.ac.uk> <20011206122233.GB1111@raggedclown.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00bb01c17e52$96093b50$0a00000a>