develooper Front page | perl.perl5.porters | Postings from June 2008

Re: [PATCH] File::Copy & permission bits.

Thread Previous | Thread Next
June 10, 2008 01:16
Re: [PATCH] File::Copy & permission bits.
Message ID:
On Mon, Jun 09, 2008 at 03:34:23PM +0200, Aristotle Pagaltzis wrote:
> * Craig A. Berry <> [2008-06-09 15:05]:
> > Before Abigail's patch, the Unix copy() did roughly what the
> > VMS and Win32 syscopy() implementations do: it followed "new
> > file" semantics and created the target file with permissions
> > inherited from the target environment.
> Except, there is no such thing as permissions inherited from the
> target environment on Unix. Maybe you could consider the exec
> bits on the directories that are part of a file’s path some kind
> of permission inheritance, but even that is a bit of a stretch.

Well, one could argue that the umask is "permissions inherited from the
target environment". And that is what still happens after my patch as
well. The difference is that before my patch, the permissions of the
new file *only* depend on umask, it's 0666 & ~umask. After my patch,
it uses the permissions bits of the source file itstead of 0666, but
still masks them with ~umask.

My hope was that there were no effects at all for environments that
don't have permissions bits, but I've no non-Unix environment to test
that, nor any significant experience on non-Unix platforms to make any
predictions, nor was perlport of any help of predicting the behaviour
on non-Unix systems. (My thought was, if the platform doesn't have
permissions, it doesn't really matter what the third argument of sysopen

> > I don't like the fact that copying from a handle now gives
> > different behavior permissions-wise than copying from a
> > filename, but that inconsistency could be ironed out pretty
> > easily.

I am surprised about this. My patch takes the permissions bit from the
file handle (either the one passed to copy, or the one after opening
the source file), and there are tests that check whether the permission
bits are set correctly when copying from a file handle.

> I always argued that the code to preserve permissions should go
> into `syscopy` on Unix, not `copy`.
> If, as Charles seems to have been suggesting, `cp` was aliased
> depending on platform to *either* `copy` *or* `syscopy` such that
> it emulated the platform copy program, that would be ideal.
> Then people could explicitly ask for either behaviour when they
> mean it, or could use the DWIM alias (which is also shortest to
> type) when upgrading scripts from sh/CMD.EXE/DCL/whatever.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About