[PATCH] binutils: Attempt to retain permissions on copying file

Siddhesh Poyarekar siddhesh@gotplt.org
Wed Feb 24 10:27:10 GMT 2021


On 2/23/21 5:26 PM, Alan Modra wrote:
> On Tue, Feb 23, 2021 at 12:22:59PM +0530, Siddhesh Poyarekar wrote:
>> Writing into an existing file clears its S_ISUID and S_ISGID bits.
>> Attempt to restore those permission bits but don't fail if it doesn't
>> work.
>>
>> Also, since the output file always exists (all callers create an empty
>> file before calling smart_rename), open the file without any
>> permission hints or O_CREAT.
>>
>> binutils/
>>
>> 	* rename.c (simple_copy): Don't use O_CREAT.
>> 	(simple_copy)[!defined (_WIN32) || defined (__CYGWIN32__)]:
>> 	Attempt to retain permission bits.
> 
> Thanks, I'll fold this into a followup patch of mine that makes use of
> the temp file descriptor in smart_rename rather than reopening the
> file.  I don't believe there is a security issue in reopening the
> file, but this way there is one less directory operation.  I'm also
> going to make use of the target_stat we already have rather than
> calling stat again.

I just tested tip and it looks in good shape.  I suppose this ought to 
go into 2.36 too since the simple_copy patch went in there too.

Thanks,
Siddhesh


More information about the Binutils mailing list