Subject: bug#8391: chmod setuid & setguid bits

From: Ondrej Vasik <[email-masked]>
Date: Mon, 04 Apr 2011 11:04:18 +0200

Hi,
On Thu, 2011-03-31 at 14:15 -0600, Eric Blake wrote:
> On 03/31/2011 01:58 PM, Christian wrote:
> > Hi Paul,
> > 
> > Am 31.03.2011 20:54, schrieb Paul Eggert:
> >> On 03/31/2011 11:25 AM, Christian wrote:
> >>> and using "0755" is explicit enough, isn't it ?
> >> Unfortunately it's not that simple, as having 0755 mean
> >> something different from 755 would violate the principle
> >> of least surprise.  Please see the thread starting at
> >> <http://lists.gnu.org/archive/html/bug-coreutils/2006-07/msg00124.html>.
> > I read it and I came to the conclusion
> > 755 should preserve s-bit: OK
> > 2755 sould set sbit. OK
> > 0755 should remove sbit, cause it is explicit wanted.
> > and not doing so is a "lemming behaviour".
> 
> No, 0755 is not explicit - it is ambiguous with people that are
> explicitly using printf %#3o to output a 3-digit octal string with
> leading 0 - I don't think we can change this.

I just want to mention recent RH bugzilla report about the same issue -
https://bugzilla.redhat.com/show_bug.cgi?id=691466 ... one of the ideas
in this bugzilla is that because of the ambiguity of the 0755 (and
similars) it would be very good to actually inform user in the case that
the special bit was not cleared (so only in the case that
SUID/SGID/sticky bits are set). Maybe only in verbose mode, but I think
it will be improvement for the current situation. What do you think?

> But my suggestion of 00755 _is_ explicit - after taking off the leading
> 0 for specifying octal, you are _still_ left with four octal digits
> which includes the sticky bit explicitly being set to 0.

I really like the 00XXX suggestion - do you plan to implement that
yourself? If you don't have time for writing it but this solution is
generally acceptable compromise, I could try to prepare a patch for
that.

Greetings,
         Ondrej Vasik