On Tue, 2007-01-02 at 11:08 -0600, Mikkel L. Ellertson wrote:
>
> While I'd expect an editor to normally write back to the original
> file to maintain symlinks, ownership and modes in the case where
> the file is writable, this sounds exactly right and what the
> user would do manually himself in case write access is denied
> and the user has issued the :w! directive. Without the '!' it
> should give a 'file is read-only' error.
>
> Set the sticky bit on the directory if you don't want people
> who don't have write permission on the file to be able to delete
> it. Then they will be forced to save under a different name.
>
Symlinks are maintained as long as the name is the same. Hard links
are another story. I have seen a lot of editors and word processors
that use the write to a new file, and then rename/delete the
original file. It tends to protect your work - the original file is
there in case something goes wrong during the same process. That
way, the worst you lose is the current edits. But as you have
noticed, it does not work out as well when editing shared files.
That's reasonable behavior for a word processor, but not for a
text editor that you are likely to use for system files where
maintaining all attributes is important. There are many situations
where it is impossible for a user with write permission on a file
to recreate its ownership and modes in a different file. And if
you have gone to the trouble of creating hard links it was probably
specifically to ensure that all names reference the same contents.
--
Les Mikesell
lesmikesell(a)gmail.com