[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: chmod --cheap option
From: |
Hrubák , András |
Subject: |
Fwd: chmod --cheap option |
Date: |
Wed, 25 May 2016 08:31:54 +0200 |
Hi Eric and Coreutils Members,
I know about the risk of race condition. It would be just an option.
If you tell about
it in usage help, users will be notified about the risks and decide
according to it.
There are several usecases when this race condition is acceptable.
Without this internal logic in chmod, scripters must write their own
logic in upper level (eg. shell script: compute numeric mode from
symbolic mode notation -> stat the file -> test the current mode
against the old one -> call chmod conditionally, etc.), which means
bigger probability of race condition.
So I would state the risks of this option in help text, explaining the
meaning of '--cheap', and of course make it NOT default.
You can find the patch in attachment.
2016-05-24 16:38 GMT+02:00, Eric Blake <address@hidden>:
> On 05/24/2016 06:42 AM, Hrubák, András wrote:
>> Dear Coreutils Dev Team,
>>
>> I made a patch for chmod.
>> It introduces an option `--cheap' to avoid real chmod (fchmodat) call
>> if the new mode seems equivalent to the old one.
>> It not only saves IO time, but also leaves ctime unchanged. While
>> ctime often plays role in updating/backuping/cleaning mechanisms, I
>> needed such a feature.
>> Please see it here: https://github.com/coreutils/coreutils/pull/6
>
> Please post patches to this list, rather than making us chase pull
> requests.
>
> That said, it is unlikely that your patch will be applied, as it is
> fundamentally a TOCTTOU race - there is no race-free way to determine a
> file's current mode to know that the changed mode will not be different,
> because a concurrent operation can occur between your check and the
> (potentially-skipped) chmod; so we prefer to always do the chmod.
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>
chmod.diff
Description: Text document