On Wed, 1 Jan 2003 14:08:22 +0200, Christoph Bugel <[EMAIL PROTECTED]> wrote:
> >
> > The point of using `cp' (or `cat >') is to keep the current (old) file
> > permissions. Using `rm + cp' or `mv' create the new file with your
> > default permissions or the moved file permissions.
>
> Good point.
>
> BTW, I looked in the cp manpage, and found that cp -f will
> succeed even if text file busy: If necessary, it will first
> unlink the file.
>
> strace snippet of cp -f:
>
> open("mysleep", O_WRONLY|O_TRUNC|O_LARGEFILE) = -1 ETXTBSY (Text file busy)
> unlink("mysleep") = 0
> open("mysleep", O_WRONLY|O_CREAT|O_LARGEFILE, 0100755) = 4
But it does NOT keep permissions (I've just checked).
There are ways to overcome this by first copying the OLD (target)
file to a temp name with `cp -p', then copying the NEW file onto
it with cp (NO -p!) and then copying the temp file back onto the
OLD one with `cp -f'.
The problem with this way (as opposed to direct cp) is that it may
require more privileges than the direct `cp'. An example is a file:
-rwsrwxr-x 1 root sys 11612 Jan 1 14:17 example
This file can be easily overwritten by anyone of `sys' group without
changing the `root' ownership (but losing the `sticky' bit). If she
tries to use the `cp -p' method, she puts the file under her ownership.
Ehud.
--
Ehud Karni Tel: +972-3-7966-561 /"\
Mivtach - Simon Fax: +972-3-7966-667 \ / ASCII Ribbon Campaign
Insurance agencies (USA) voice mail and X Against HTML Mail
http://www.mvs.co.il FAX: 1-815-5509341 / \
mailto:[EMAIL PROTECTED] Better Safe Than Sorry
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]