Debian Bug report logs - #497514
coreutils: chmod, chown, and chgrp change ctime even when no change was necessary

version graph

Package: coreutils; Maintainer for coreutils is Michael Stone <[email protected]>; Source for coreutils is src:coreutils (PTS, buildd, popcon).

Reported by: Erik Rossen <[email protected]>

Date: Tue, 2 Sep 2008 09:33:07 UTC

Severity: wishlist

Found in version coreutils/5.97-5.3

Full log


Message #30 received at [email protected] (full text, mbox, reply):

Received: (at 497514) by bugs.debian.org; 2 Sep 2008 18:56:58 +0000
From [email protected] Tue Sep 02 18:56:58 2008
X-Spam-Checker-Version: SpamAssassin 3.1.4-bugs.debian.org_2005_01_02 
	(2006-07-26) on rietz.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.7 required=4.0 tests=BAYES_00,FORGED_RCVD_HELO,
	FOURLA,HAS_BUG_NUMBER,MURPHY_DRUGS_REL8 autolearn=no 
	version=3.1.4-bugs.debian.org_2005_01_02
Return-path: <[email protected]>
Received: from relay4-v.mail.gandi.net ([217.70.178.78])
	by rietz.debian.org with esmtp (Exim 4.63)
	(envelope-from <[email protected]>)
	id 1Kab3i-0005F7-4x
	for [email protected]; Tue, 02 Sep 2008 18:56:58 +0000
Received: from localhost (mfilter6-d.gandi.net [217.70.178.40])
	by relay4-v.mail.gandi.net (Postfix) with ESMTP id 998CDBA2B;
	Tue,  2 Sep 2008 20:56:51 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter6-v.mgt.gandi.net
Received: from relay4-v.mail.gandi.net ([217.70.178.78])
	by localhost (mfilter6-v.mgt.gandi.net [217.70.178.40]) (amavisd-new, port 10024)
	with ESMTP id UdRlM6q9T40t; Tue,  2 Sep 2008 20:56:49 +0200 (CEST)
Received: from smtp.lan.rossen.ch (cix-adsl-c38-p084.vtx.ch [212.147.38.84])
	by relay4-v.mail.gandi.net (Postfix) with ESMTP id 0E1BBBA17;
	Tue,  2 Sep 2008 20:56:48 +0200 (CEST)
Received: from localhost (durian.lan.rossen.ch [192.168.71.253])
	by smtp.lan.rossen.ch (Postfix) with ESMTP id 8BA1C14041EF;
	Tue,  2 Sep 2008 20:56:48 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at rossen.ch
Received: from smtp.lan.rossen.ch ([192.168.71.253])
	by localhost (durian.lan.rossen.ch [192.168.71.253]) (amavisd-new, port 10024)
	with ESMTP id 6oWnGsJWlIpg; Tue,  2 Sep 2008 20:56:48 +0200 (CEST)
Received: from smtp.lan.rossen.ch (durian.lan.rossen.ch [192.168.71.253])
	by SA-filtered (Postfix) with ESMTP id 92AFC14041F0;
	Tue,  2 Sep 2008 20:56:44 +0200 (CEST)
Received: from mango (durian.lan.rossen.ch [192.168.71.253])
	by smtp.lan.rossen.ch (Postfix) with SMTP id 6DDF814041EF;
	Tue,  2 Sep 2008 20:56:43 +0200 (CEST)
Received: by mango (sSMTP sendmail emulation); Tue, 02 Sep 2008 20:56:43 +0200
Date: Tue, 2 Sep 2008 20:56:43 +0200
From: Erik Rossen <[email protected]>
To: Jim Meyering <[email protected]>
Cc: [email protected], Michael Stone <[email protected]>,
	[email protected]
Subject: Re: Bug#497514: coreutils: chmod, chown, and chgrp change ctime even  when no change was necessary
Message-ID: <[email protected]>
References: <[email protected]> <[email protected]> <[email protected]> <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <[email protected]>
User-Agent: Mutt/1.5.13 (2006-08-11)
On Tue, Sep 02, 2008 at 08:06:51PM +0200, Jim Meyering wrote:
> Good idea.
> At least for chmod, it is not only possible, but the optimization
> would be essentially free, since chmod already has the required stat data.

Yeah, I thought it was a good idea too.

> AFAICS POSIX
> (http://www.opengroup.org/onlinepubs/007908775/xsh/chmod.html)
> allows the behavior you propose.  That same feature was even
> requested a few years ago, but no one implemented it.

Thanks for the lead - I had no idea where to go looking for POSIX specs.
But you got the wrong URL.  The URL above refers to chmod() the
function.  What we needed was chmod the utility.  Here it is:

	http://www.opengroup.org/onlinepubs/007908799/xcu/chmod.html

And, if one wants to be REALLY pedantic, it looks like the file node is
supposed to be changed each time.  For example, here is an extract:

	+
	    If perm is not specified, the + operation will not change
	    the file mode bits. If who is not specified, the file mode
	    bits represented by perm for the owner, group and other
	    permissions, except for those with corresponding bits in the
	    file mode creation mask of the invoking process, will be
	    set. Otherwise, the file mode bits represented by the
	    specified who and perm values will be set.

Here it says that the bits will be set.  Unfortunately, they do not say
something like "set unless already set".  If the feature is to added, it
will be a non-standard option.

> A patch would be welcome.

I totally agree.

> If you're not interested, let me know in any case and
> I'll add it to the TODO list.

I think I will let you add it to the TODO list. :-)

> For chgrp (probably chown, too, at least in some cases), it's not
> as obvious, since the current implementation does not stat files
> before changing permissions.  So, to do what you want would involve
> adding a stat call per file to get owner/group in order to avoid(maybe)
> the offending ownership-changing syscall.  That would not be an
> improvement.

As far as speed is concerned, you are right that an extra stat() would
usually not improve matters.  (Would it be an enormous penalty?  I doubt
it.)  But users of file integrity checking systems like myself will be
grateful for the change of behavior.

-- 
Erik Rossen                               OpenPGP key: 2935D0B9
[email protected]                          If you do not know what
http://people.linux-gull.ch/rossen        to do, start with RTFM.




Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 11:30:39 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.