Subject: bug#23853: chmod can unset sticky bits using octet format

From: Eric Blake <[email-masked]>
Date: Mon, 27 Jun 2016 08:13:20 -0600

On 06/26/2016 06:56 PM, westlake wrote:
> According to chmod's manpage,
> "chmod preserves a directory's set-user-ID and set-group-ID bits unless
> you explicitly specify otherwise.  You can set or clear the bits with
> symbolic modes like u+s and g-s, and you can set (but not clear) the
> bits with a numeric mode."
> 
> contrary to documentation, chmod can otherwise clear sticky bits using
> the octet notation but by using a 5th octal
> 
> commands used,
> mkdir abc
> chmod u+s,g+s abc
> chmod 0755 abc (no effect on the sticky bits)
> chmod 00755 abc (sticky bits cleared using the 5th octal position)

The behavior of the 5th octal to intentionally specify that the
otherwise leading 0 is intended to clear sticky bits is intentional, so
the only bug here is in the documentation for not making the intended
behavior more obvious.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org