coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [coreutils] feature request: make chown/chmod/chgrp --verbose/--chan


From: Jim Meyering
Subject: Re: [coreutils] feature request: make chown/chmod/chgrp --verbose/--changes additionally show original property
Date: Wed, 18 Aug 2010 16:55:44 +0200

William Plusnick wrote:
> On Mon, Aug 2, 2010 at 6:32 AM, marcel partap <address@hidden> wrote:
>
>     Dear coreutil hackers,
>     as anyone doing *n*x housework regularly, i also am using these tools on a
>     regular basis, in scripts and manually. What i often miss (especially when
>     invoking actions recursively with -Rc, and regretting part of the
>     modifications shortly after) is the output of the original state the file
>     was in. Example:
>
>         changed ownership of `robots.txt' to www-data:www-data
>
>     Well i am glad about that, but who was it owned by before? It would be 
> nice
>     to have this shown as one of
>
>         changed ownership of `robots.txt' to www-data:www-data (from 
> root:root)
>         changed ownership of `robots.txt' from root:root to www-data:www-data
>         changed ownership of `robots.txt' root:root > www-data:www-data
>
>     While this example is not of much importance.. well consider this (made
>     up):
>
>         mode of `/var/www/drupal-hfopi/files/temp/._/._/._/._/._/.shell.pl'
>         changed to 0666 (rw-rw-rw-)
>
>     Mmmkay, ack that file shouldn't be +x... but what would be of real
>     interest: WAS it executable before? Same proposal mockup:
>
>         mode of `/var/www/drupal-hfopi/files/temp/._/._/._/._/._/.shell.pl'
>         changed to 0666 (rw-rw-rw-)  (from 0777 (rwxrwxrwx))
>         mode of `/var/www/drupal-hfopi/files/temp/._/._/._/._/._/.shell.pl'
>         changed from 0777 (rwxrwxrwx) to 0666 (rw-rw-rw-)
>         mode of `/var/www/drupal-hfopi/files/temp/._/._/._/._/._/.shell.pl'
>         changed: 0777 (rwxrwxrwx) > 0666 (rw-rw-rw-)
>
>     To not break any scripts, this could be implemented as
>     --print-original-state additional option to -v/-c. And please forgive for
>     not attaching a finished patch ;)
>     best regards,
>     marcel.
>
> I know this is an old post, but is there any objections to this feature? If
> not, what exact mechanics do you think it should take? Assuming there are no
> objections, I would like to take this on.

Thanks for the suggestion.

>From a user perspective, I can see the attraction of this functionality
(and generally of --verbose), but from an implementation perspective,
even --verbose is not welcome because it adds a nontrivial amount of
logic (and the threat of a large performance hit) for only marginal gain.
The worst part is that must of what ch??? --verbose prints is not even
guaranteed to be true, so it cannot be used reliably to infer prior state.
While working on ch???.c over the years, --verbose support has turned
out be the source of enough hassles that I have seriously considered
deprecating-then-removing the option.  Thus, the relatively-new
chcon.c (which is very similar to the other ch*.c programs) does *not*
provide a --verbose option.

Here's a big part of the problem:

  - what chown/chgrp/chmod --verbose reports with your proposed
    addition may not be true.  There is a guaranteed race: the
    original owner/group/mode may be changed between when the
    tool records it and when it comes time to actually change it.
    It could end up not being changed at all, or it could be changed
    from some other value than the one printed in the diagnostic.

With that, you get a feel for why I'm tempted to remove --verbose
support.  Even existing --verbose output may be inaccurate due to
this implicit race condition.  For example, if I run chgrp --verbose G f,
it may print "changed group of `f' to G", while in actuality it may not
have changed the group at all, due to the unavoidable race when using
--verbose.

If you really want the prior state, you should simply record it
separately, rather than hoping to get something consistent and
usable from --verbose.

In summary I'd rather remove --verbose from ch???



reply via email to

[Prev in Thread] Current Thread [Next in Thread]