Subject: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'

From: Eric Blake <[email-masked]>
Date: Mon, 08 Apr 2013 08:09:05 -0600

On 04/06/2013 04:27 PM, Bob Proulx wrote:
> Pádraig Brady wrote:
>>> -	  && chmod -w $@-t						\
>>> +	  && chmod a-w $@-t						\
>>
>> I'll apply that fix.
> 
> I think it is always a good idea to use 'a' when there isn't any other
> specific reason to do anything different.  Or put the reverse way,
> whenever I see a naken "-[rwx]" then I am suspicious of the action.
> Because it masks with umask and is almost never what is desired.

Actually, POSIX says that:

chmod -w foo

is undefined (that is, an argument with a leading - is interpreted as an
option rather than as a mode string, but chmod is NOT required to
support a -w option, even though many implementations support it as an
extension).  Meanwhile, POSIX requires that

chmod -- -w foo

is required to mask with umask.  In fact, in coreutils, we exploit the
fact that chmod -[rwx] is undefined, in order to emit warnings if the
resulting change did not disable all bits.  Using a-w instead of the
undefined '-w' or the well-defined but confusing '-- -w' is indeed the
right way to fix things.

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