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

Previous Next

Package: coreutils;

Reported by: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>

Date: Sat, 6 Apr 2013 16:14:02 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14152 in the body.
You can then email your comments to 14152 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Sat, 06 Apr 2013 16:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 06 Apr 2013 16:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
To: bug-coreutils <at> gnu.org
Cc: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
Subject: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sat,  6 Apr 2013 14:23:59 +0200
'chmod -w' is not portable and breaks the build:

| WARNING: Cannot create proper 'hostid.1' man page, since perl is missing or
| WARNING: inadequate on this system.  Creating a stub man page instead.
| chmod: man/hostid.1-t: new permissions are r--rw-r--, not r--r--r--
| make[2]: *** [man/hostid.1] Error 1

Signed-off-by: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
---
 man/local.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/local.mk b/man/local.mk
index b5e6e21..53debad 100644
--- a/man/local.mk
+++ b/man/local.mk
@@ -192,5 +192,5 @@ man/yes.1:       src/yes
 		     --output=$$t/$$name.1 $$t/$$name			\
 	  && sed 's|$*\.td/||g' $$t/$$name.1 > $@-t			\
 	  && rm -rf $$t							\
-	  && chmod -w $@-t						\
+	  && chmod a-w $@-t						\
 	  && mv $@-t $@
-- 
1.8.1.4





Information forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Sat, 06 Apr 2013 19:02:02 GMT) Full text and rfc822 format available.

Message #8 received at 14152 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
Cc: 14152 <at> debbugs.gnu.org
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sat, 06 Apr 2013 19:58:26 +0100
On 04/06/2013 01:23 PM, Enrico Scholz wrote:
> 'chmod -w' is not portable and breaks the build:
> 
> | WARNING: Cannot create proper 'hostid.1' man page, since perl is missing or
> | WARNING: inadequate on this system.  Creating a stub man page instead.
> | chmod: man/hostid.1-t: new permissions are r--rw-r--, not r--r--r--
> | make[2]: *** [man/hostid.1] Error 1
> 
> Signed-off-by: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
> ---
>  man/local.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/man/local.mk b/man/local.mk
> index b5e6e21..53debad 100644
> --- a/man/local.mk
> +++ b/man/local.mk
> @@ -192,5 +192,5 @@ man/yes.1:       src/yes
>  		     --output=$$t/$$name.1 $$t/$$name			\
>  	  && sed 's|$*\.td/||g' $$t/$$name.1 > $@-t			\
>  	  && rm -rf $$t							\
> -	  && chmod -w $@-t						\
> +	  && chmod a-w $@-t						\
>  	  && mv $@-t $@
> 

I'll apply that fix.

What system does the build fail on as a matter of interest.

thanks!
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Sat, 06 Apr 2013 22:32:01 GMT) Full text and rfc822 format available.

Message #11 received at 14152 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: 14152 <at> debbugs.gnu.org
Cc: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sat, 6 Apr 2013 16:27:35 -0600
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.

> What system does the build fail on as a matter of interest.

This will occur on any system that has umask set to 022.  Here is an example:

  $ umask 022
  $ touch foo
  $ chmod ug+w foo
  $ chmod -w foo
  chmod: foo: new permissions are r--rw-r--, not r--r--r--
  $ echo $?
  1

Bob




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Sun, 07 Apr 2013 01:23:02 GMT) Full text and rfc822 format available.

Notification sent to Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>:
bug acknowledged by developer. (Sun, 07 Apr 2013 01:23:02 GMT) Full text and rfc822 format available.

Message #16 received at 14152-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Bob Proulx <bob <at> proulx.com>
Cc: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>,
	14152-done <at> debbugs.gnu.org
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sun, 07 Apr 2013 02:19:25 +0100
On 04/06/2013 11: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.
> 
>> What system does the build fail on as a matter of interest.
> 
> This will occur on any system that has umask set to 022.  Here is an example:
> 
>   $ umask 022
>   $ touch foo
>   $ chmod ug+w foo
>   $ chmod -w foo
>   chmod: foo: new permissions are r--rw-r--, not r--r--r--
>   $ echo $?
>   1

But if the umask is 022, then those write bits shouldn't be set anyway?
You're forcing g+w above.

thanks,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Sun, 07 Apr 2013 10:04:01 GMT) Full text and rfc822 format available.

Message #19 received at 14152-done <at> debbugs.gnu.org (full text, mbox):

From: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 14152-done <at> debbugs.gnu.org, Bob Proulx <bob <at> proulx.com>
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sun, 07 Apr 2013 11:59:52 +0200
Pádraig Brady <P <at> draigBrady.com> writes:

>>> What system does the build fail on as a matter of interest.
>> 
>> This will occur on any system that has umask set to 022.  Here is an example:
>> 
>>   $ umask 022
>>   $ touch foo
>>   $ chmod ug+w foo
>>   $ chmod -w foo
>>   chmod: foo: new permissions are r--rw-r--, not r--r--r--
>>   $ echo $?
>>   1
>
> But if the umask is 022, then those write bits shouldn't be set anyway?

These bits can be set due to various reasons; e.g.

$ mkdir /tmp/foo
$ setfacl -m d:m:rwx /tmp/foo

$ umask 022
$ touch /tmp/foo/x
$ chmod -w /tmp/foo/x
chmod: /tmp/foo/x: new permissions are r--rw-r--, not r--r--r--


I use such a setup (posix defaults acls) to build foreign software as a
special user while allowing working on the software (--> editing) as the
normal user.


Enrico




Information forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Sun, 07 Apr 2013 10:59:02 GMT) Full text and rfc822 format available.

Message #22 received at 14152 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>
Cc: 14152 <at> debbugs.gnu.org, Bob Proulx <bob <at> proulx.com>
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Sun, 07 Apr 2013 11:54:41 +0100
On 04/07/2013 10:59 AM, Enrico Scholz wrote:
> Pádraig Brady <P <at> draigBrady.com> writes:
> 
>>>> What system does the build fail on as a matter of interest.
>>>
>>> This will occur on any system that has umask set to 022.  Here is an example:
>>>
>>>   $ umask 022
>>>   $ touch foo
>>>   $ chmod ug+w foo
>>>   $ chmod -w foo
>>>   chmod: foo: new permissions are r--rw-r--, not r--r--r--
>>>   $ echo $?
>>>   1
>>
>> But if the umask is 022, then those write bits shouldn't be set anyway?
> 
> These bits can be set due to various reasons; e.g.
> 
> $ mkdir /tmp/foo
> $ setfacl -m d:m:rwx /tmp/foo
> 
> $ umask 022
> $ touch /tmp/foo/x
> $ chmod -w /tmp/foo/x
> chmod: /tmp/foo/x: new permissions are r--rw-r--, not r--r--r--
> 
> 
> I use such a setup (posix defaults acls) to build foreign software as a
> special user while allowing working on the software (--> editing) as the
> normal user.

Excellent, thanks for the clarification.
I've adjusted the commit message as follows:

    build: fix man page build failure with some permissions setups

    Use the more portable 'chmod a-w', instead of the 'chmod -w' form.
    The latter is not always supported.  Also its operation is
    dependent on umask controlling the permissions bits for new files,
    which is not the case in the presence of POSIX default ACLs for e.g.
    In that case, chmod may print a warning like the following, and
    exit with failure status:

    chmod: man/hostid.1-t: new permissions are r--rw-r--, not r--r--r--

    * man/local.mk: s/-w/a-w/

thanks,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14152; Package coreutils. (Mon, 08 Apr 2013 14:13:01 GMT) Full text and rfc822 format available.

Message #25 received at 14152 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Bob Proulx <bob <at> proulx.com>
Cc: Enrico Scholz <enrico.scholz <at> informatik.tu-chemnitz.de>,
	14152 <at> debbugs.gnu.org
Subject: Re: bug#14152: [PATCH] build: use 'chmod a-w' instead of 'chmod -w'
Date: Mon, 08 Apr 2013 08:09:05 -0600
[Message part 1 (text/plain, inline)]
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

[signature.asc (application/pgp-signature, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 07 May 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 51 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.