Re: maybe a bug in copy files



Hi,

> [...] As it can be
> seen the patch posted by Andrew calls chmod() on the target
> file only if "preserve attributes" is set. However, it has to
> be called in both cases since the destination file is created
> with mode 600 initially due to security concerns - more info
> can be found in file.c .

I think this is overcomplicated... open() does not create the file with the
permission taken from its third argument, it masks it with umask. So
currently the file is not created with mode 600, but with mode (600 &
^umask).

What's wrong with the following simple solution?

When creating the file, pass the permissions of the old file to the open()
call. This way it will have no more permissions than the original file, and
no more permission than umask suggests.

When copying is finished, call chmod() only if preserve attributes is set.



-- 
Egmont



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