Subject: Re: bug#8391: chmod setuid & setguid bits

From: Paul Eggert <[email-masked]>
Date: Fri, 24 Feb 2012 11:47:33 -0800

On 02/24/2012 11:33 AM, Ondrej Vasik wrote:
> Yes, but `chmod @755 DIR' approach will not let you to write a script
> which will work without modification on RHEL-4,RHEL-5 and RHEL-6
> machine...

None of these approaches will let you write a script that will work
without modification on any POSIX platform.  If one wants to be portable,
one must use the symbolic notation, not the octal.

None of these approaches will even let you write a script that will work
without modification on any RHEL platform.  This is because some RHEL
platforms use the newer coreutils.

Still, I take your point that the 5-or-more-digit approach will let you write
scripts that will run on all POSIX platforms without a diagnostic
(though perhaps not with the desired effect).  And these scripts will
run and have the desired effect if you know that your scripts will run
only on a particular subset of POSIX platforms, one where the effect is
the one desired.

How about this idea for a compromise?  Implement both notations, but
recommend leading '@' for future scripts.  It's more likely that a notation
like leading-'@' would be adopted by future POSIX versions, since it's a
pure extension, whereas the 5-or-more-digit approach is incompatible with
some POSIX systems now.  And if leading-'@' is adopted by POSIX, there would
eventually be a portable way to do what the requester wants.

Personally I'd be more inclined to go with a pure '@' solution, since
it's simpler and the portability gains of the compromise are not all
that great; but I guess the compromise would be OK too.