GNU bug report logs - #50791
Recursive chmod exit status in coreutils-9.0

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Chris Webb <chris@HIDDEN>; merged with #50784; dated Fri, 24 Sep 2021 22:26:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Forcibly Merged 50784 50791. Request was from Pádraig Brady <P@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 50791 <at> debbugs.gnu.org:


Received: (at 50791) by debbugs.gnu.org; 24 Sep 2021 22:50:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 24 18:50:55 2021
Received: from localhost ([127.0.0.1]:59457 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTu1v-0004yI-9V
	for submit <at> debbugs.gnu.org; Fri, 24 Sep 2021 18:50:55 -0400
Received: from mail-wr1-f45.google.com ([209.85.221.45]:34584)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <pixelbeat@HIDDEN>)
 id 1mTu1t-0004xw-Bb; Fri, 24 Sep 2021 18:50:53 -0400
Received: by mail-wr1-f45.google.com with SMTP id t8so31908138wri.1;
 Fri, 24 Sep 2021 15:50:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=vrmKrZYDq7h8ahH+NhTunrtuYaFKDK1g+Y6PGH5emic=;
 b=Ja7gL1onibyrn7RiRNp0z2SMjIfYKcZHme6KmLIiDeJF21HP4RAEMY/8q7JgxkwsWw
 xCja9jL9M6SfleZ5h9rtu9QX7dIIAHU8QD/NXxe9nQunFjNdEhNoM08N3EtCE5eQcstZ
 4oiXffAzBVDFDH3xFeUwmKkw6G3VgvXmDjQbIty7bWqtODKXitzjcQe/24cOEYEydmej
 Sg6nOMhwWe3LrmIy8Ap3bpFTB28xjTZ82hKIKDzUwxxES7eA4ZimQKsSI5lKPOG8WRkl
 xVtTkPOpeF5fejwGCvac6VTrcyj7AeBQYr7+qPPyFgf2iHzRH/C7/jJWLBbaY6ruywlD
 UUtA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=vrmKrZYDq7h8ahH+NhTunrtuYaFKDK1g+Y6PGH5emic=;
 b=e1eFNOC1bzZRL76FVuHmpNJ55KImv5M8H+BU7MhRqVy9YDiVRKBCRUD1cxeAHxUvMU
 aIjQ616LSC7n+wjezo+hlWRbdANNlAqU6ftrgddIds1xI8UXASFnEV1bQn+9NhQwLYna
 gSBHKClxPzdfJM1Ri1kE593A70x4BUfw7iDM6CkFJhuqbBRSe6E1a+rTblPg23oZhcj6
 EKudOuj/1asytSrRnfUF6RgHU0X0Z4BzgCwAsdd1cepCg2tTq7XFDPyDXTcBjx6GMTLK
 f5seqYA4KNEv+w++w8r5TZsKNBT76WuyRMymLN7rA7cdXhUqW2rjDDGfQwc23jk5kYg0
 VYqg==
X-Gm-Message-State: AOAM5301iPsu9J1jOf9c+oV4jiHUknEaQL1YBwVakqmfYQvjswBmPQLh
 gTtGmw/kV4ch/tOYoM3fq4fp196OpZL4H95+
X-Google-Smtp-Source: ABdhPJybWoyVwoDAViR2FH5z87Jp7E8NVVPVd5BP+uBqYMS1AVPwpX7+nPYfwANvWngb2iiUwzb5oQ==
X-Received: by 2002:a05:6000:162f:: with SMTP id
 v15mr14412799wrb.118.1632523847251; 
 Fri, 24 Sep 2021 15:50:47 -0700 (PDT)
Received: from localhost.localdomain
 (86-44-211-219-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.219])
 by smtp.googlemail.com with UTF8SMTPSA id
 d5sm9671057wra.38.2021.09.24.15.50.46
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 24 Sep 2021 15:50:46 -0700 (PDT)
Subject: Re: bug#50791: Recursive chmod exit status in coreutils-9.0
To: Chris Webb <chris@HIDDEN>, 50791 <at> debbugs.gnu.org
References: <20210924211616.GA6822@HIDDEN>
From: =?UTF-8?Q?P=c3=a1draig_Brady?= <P@HIDDEN>
Message-ID: <e8449c84-f19f-6ed3-15f8-51d7b7648962@HIDDEN>
Date: Fri, 24 Sep 2021 23:50:46 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101
 Thunderbird/84.0
MIME-Version: 1.0
In-Reply-To: <20210924211616.GA6822@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: 50791
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.6 (/)

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




Information forwarded to bug-coreutils@HIDDEN:
bug#50791; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Sep 2021 22:25:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 24 18:25:17 2021
Received: from localhost ([127.0.0.1]:59402 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTtd3-00048B-IO
	for submit <at> debbugs.gnu.org; Fri, 24 Sep 2021 18:25:17 -0400
Received: from lists.gnu.org ([209.51.188.17]:34022)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <chris@HIDDEN>) id 1mTsYY-00066W-Ld
 for submit <at> debbugs.gnu.org; Fri, 24 Sep 2021 17:16:30 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34634)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <chris@HIDDEN>)
 id 1mTsYY-0004ji-60
 for bug-coreutils@HIDDEN; Fri, 24 Sep 2021 17:16:30 -0400
Received: from cdw.me.uk ([91.203.57.136]:43329)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <chris@HIDDEN>) id 1mTsYV-0004gC-W6
 for bug-coreutils@HIDDEN; Fri, 24 Sep 2021 17:16:29 -0400
Received: from chris by delta.arachsys.com with local (Exim 4.80)
 (envelope-from <chris@HIDDEN>) id 1mTsYK-0001oN-9b
 for bug-coreutils@HIDDEN; Fri, 24 Sep 2021 22:16:16 +0100
Date: Fri, 24 Sep 2021 22:16:16 +0100
From: Chris Webb <chris@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: Recursive chmod exit status in coreutils-9.0
Message-ID: <20210924211616.GA6822@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.20 (2009-06-14)
Received-SPF: pass client-ip=91.203.57.136; envelope-from=chris@HIDDEN;
 helo=cdw.me.uk
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 24 Sep 2021 18:25:12 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

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.

Best wishes,
Chris.




Acknowledgement sent to Chris Webb <chris@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#50791; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 24 Sep 2021 23:00:02 UTC

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