[comp.sys.sun] minor problems in 4.0 ed

mp@allegra.att.com (01/07/89)

When you do a 'w' in 'ed', it does a stat() on the target file, and if the
file is a regular file with a link count of 1, does a create-a-temp-file/
change-mode/change-owner/unlink-target-file/rename-to-be-target-file
dance.  If the target is anything else, or if the temp file (created in
the same directory) can't be created, it just opens the target file for
writing/truncation.  This is a fine idea, except that this is basically
the System V 'ed', and it doesn't fare so well with three BSD-isms:

1) symbolic links.  I moved /usr/lib/aliases* into /usr/share/lib so that
all the clients of a fileserver, regardless of architecture, would see the
same aliases file.  I left symlinks in their place so that users and
sendmail.cf's with hardwired references to /usr/lib/aliases* would still
succeed.  But when I used 'ed' to edit /usr/lib/aliases (I'm one of those
users!), the 'w' command unlinked it and then recreated it as a normal
file, breaking the symbolic link, and of course not updating the shared
version.  The simplest fix would be to replace the stat() with an lstat(),
so that the ISREG() check fails.

2) directories with the sticky bit set: if I don't have the access to
unlink the target file in the containing directory, but can create the
temp file, the 'w' command will fail, even if I have write access to the
target file.

3) SunOS 4.0 doesn't support the System V chown(), in which any user can
"give away" a file to another user.  So if I edit a 1-link file that's
owned by someone else and is writable by me (and assuming I can unlink it
from the containing directory), the result when I write it out is a file
owned by me.

Finally, it's unsatisfactory for customers to fix the source code, because
Sun has cut out those parts dealing with encryption, so the resulting
binary will be deficient, even suspect: those of you with 3.0 source may
remember that when Sun hacked out the crypt code from vi, one source file
was left with a syntax error.  It's puzzling why they do this, yet include
the source code for libc encryption routines.

	Mark Plotnick
	allegra!mp