coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] RFC for adding file creation mode feature into touch uti


From: Pádraig Brady
Subject: Re: [coreutils] RFC for adding file creation mode feature into touch utility.
Date: Fri, 07 Jan 2011 16:23:39 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 07/01/11 15:23, Eric Blake wrote:
> On 01/07/2011 02:01 AM, Rakib Mullick wrote:
>> Hello list,
>>
>> This is a Request For Comment for adding a new feature into touch
>> utility. touch is basically an utility to modify a file's timestamps
>> and it is also used for file creation vastly. We can create a file by
>> just doing 'touch filename'. There are lot of cases where we need to
>> change file's permission after creation. To do that we need to
>> separately do 'chmod -/+ mode filename'. Now, my proposal is to adding
>> mode changing feature to the touch utility, it will help us to create
>> a file by just doing 'touch --mode xxx filename'. It will create a
>> file with specified mode.
>>
>> Hope to get some response.
> 
> Hmm - mkdir already supports -m/--mode, so it does sound like making
> touch support the same option might be a useful enhancement.  Of course,
> if the file exists, the --mode option would be ignored.  And POSIX
> requires that if the --mode option is not provided but a file is
> created, that the file have mode 0666 as modified by umask.  We can't
> use -m, though (POSIX already requires it for mtime).

Why does mkdir have this option rather than relying on umask?
My guess is to close security races with sticky bits etc.
and that creating a file will not have the same issues?

...
> I'm 70:30 for adding this idea, and it's rather simple to do, as well
> (would still need doc, NEWS, and test additions).

I'm a little less enthused to diverge from POSIX for this.

> Note that 'touch -r a b' must still use mode 0666-umask for b, rather
> than copying a's permissions, because -r is mandated by POSIX; but
> 'touch -r a -M + b' is a great way to create b with the same permissions
> as a (assuming b didn't exist).

Note also the related `cp --attr old new` which will create a file
with the perms of 'old'. Also it's more general in that it will
copy any extended attributes. Timestamps are not copied since
that's not usually wanted, and one can always do a subsequent `touch -r`

cheers,
Pádraig.



reply via email to

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