Subject: chmod(1) and '+X'
To: None <tech-userlevel@netbsd.org>
From: Jan Schaumann <jschauma@netmeister.org>
List: tech-userlevel
Date: 12/13/2003 11:47:49
--5vNYLRcllDrimb99
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

I just come across this discrepancy between the manual page and real
life:

chmod(1)'s manual page states:

	The perm symbols represent the portions of the mode bits as
	follows:

	X	The execute/search bits if the file is a
		directory or any of the execute/search bits are set
		in the original (unmodified) mode.  Operations with
		the perm symbol ``X'' are only meaningful in conjun-
		ction with the op symbol ``+'', and are ignored in
		all other cases.

$ ls -l
total 8
-rw-------  1 jschauma  wheel    0 Dec 13 11:07 baz
-rwx------  1 jschauma  wheel    0 Dec 13 11:07 blah
drwx------  2 jschauma  wheel  512 Dec 13 11:08 foo
$ chmod a=3DX *
$ ls -l
total 8
----------  1 jschauma  wheel    0 Dec 13 11:07 baz
---x--x--x  1 jschauma  wheel    0 Dec 13 11:07 blah
d--x--x--x  2 jschauma  wheel  512 Dec 13 11:08 foo
$ chmod o-x blah
$ ls -l
total 8
----------  1 jschauma  wheel    0 Dec 13 11:07 baz
---x--x---  1 jschauma  wheel    0 Dec 13 11:07 blah
d--x--x--x  2 jschauma  wheel  512 Dec 13 11:08 foo
$ chmod o-X *
$ ls -l
total 8
----------  1 jschauma  wheel    0 Dec 13 11:07 baz
---x--x--x  1 jschauma  wheel    0 Dec 13 11:07 blah
d--x--x--x  2 jschauma  wheel  512 Dec 13 11:08 foo
$

So, it seems that 'X' is not ignored, but instead the op symbol is
ignored if 'X' is specified and chmod(1) behaves as if '+' had been
given as the op symbol.

GNU chmod(1) doesn't say that 'X' is ignored unless the operator is '+',
and behaves as you would expect.  Irix' chmod man pages says that it
does ignore 'X' unless '+' is specified, but behaves as the GNU chmod.

So... should our chmod be changed to behave as GNU chmod?

-Jan

--=20
Life," said Marvin, "don't talk to me about life."

--5vNYLRcllDrimb99
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (NetBSD)

iD8DBQE/20K1fFtkr68iakwRAoKBAJ4sY4+2TMirbq2dTJZkJ16IPvyv2ACfR7Gg
08PSAQQA4UurOW23J/4o8Wc=
=o7pf
-----END PGP SIGNATURE-----

--5vNYLRcllDrimb99--