GNU bug report logs - #50784
coreutils 9.0 sometimes gets spurious failures in chmod -R

Previous Next

Package: coreutils;

Reported by: Daniel Schepler <dschepler <at> gmail.com>

Date: Fri, 24 Sep 2021 18:23:01 UTC

Severity: normal

Merged with 50791, 53262

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


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

From: Pádraig Brady <P <at> draigBrady.com>
To: Chris Webb <chris <at> arachsys.com>, 50791 <at> debbugs.gnu.org
Subject: Re: bug#50791: Recursive chmod exit status in coreutils-9.0
Date: Fri, 24 Sep 2021 23:50:46 +0100
forcemerge 50791 50784
stop

On 24/09/2021 22:16, Chris Webb wrote:
> Since bbb19b, chmod has started returning EXIT_FAILURE after skipping a
> symlink during a recursive change. This affects chmod in the newly released
> coreutils-9.0 vs the previous coreutils-8.32 and older versions:
> 
>    # mkdir t
>    # cd t
>    # : > foo
>    # ln -s foo bar
> 
>    # chmod-8.32 -v -R u+r . ; echo "Exit status $?"
>    mode of '.' retained as 0755 (rwxr-xr-x)
>    neither symbolic link './bar' nor referent has been changed
>    mode of './foo' retained as 0644 (rw-r--r--)
>    Exit status 0
> 
>    # chmod-9.0 -v -R u+r . ; echo "Exit status $?"
>    mode of '.' retained as 0755 (rwxr-xr-x)
>    neither symbolic link './bar' nor referent has been changed
>    mode of './foo' retained as 0644 (rw-r--r--)
>    Exit status 1
> 
> The non-zero exit code is accompanied by no error message or diagnostic.
> 
> Success from process_file() in src/chmod.c is detected by
> 
>    ch.status >= CH_NO_CHANGE_REQUESTED
> 
> and the ordering for the possible outcomes in bbb19b puts CH_NOT_APPLIED in
> the failure range. However, we finish with CH_NOT_APPLIED if and only if a
> symlink has been (correctly) skipped.
> 
> I believe the simple reordering:
> 
> diff --git a/src/chmod.c b/src/chmod.c
> index 37b04f500..36894854f 100644
> --- a/src/chmod.c
> +++ b/src/chmod.c
> @@ -44,9 +44,9 @@ struct change_status
>     enum
>       {
>         CH_NO_STAT,
> -      CH_NOT_APPLIED,
>         CH_FAILED,
>         CH_NO_CHANGE_REQUESTED,
> +      CH_NOT_APPLIED,
>         CH_SUCCEEDED
>       }
>       status;
> 
> is sufficient to fix with no other side-effects.

Thanks for the analysis and patch.
I've already pushed a very similar patch at:
https://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=e8b56ebd5

sorry for the trouble,
Pádraig




This bug report was last modified 3 years and 129 days ago.

Previous Next


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