[net.bugs.2bsd] Symlink

root@uokmet.UUCP.UUCP (07/11/86)

Subject: symlink bug
Index:	sys/sys3.c 2.9bsd

Description:
	Symlink() always creates a link to "something", even if the original
	file doesn't exist.

Repeat-By:
	ln -s xxx xxx [presto, a "funny" xxx file is created.]
	[Fortunately, nothing "fatal" happens.  Attempts to look at the
	file gives EWOULDBLOCK.]

Fix:
	In sys/sys3.c, function symlink(), after the line

		uap = (struct a *)u.u_ap;

	add

		ip = namei(uchar, LOOKUP, 1);
		if (ip == NULL)
			return;

	This is the exact same way link() does it in sys/sys2.c.

	Kevin W. Thomas
	Univ. of Oklahoma
	School of Meteorology
	Norman, OK

UUCP:	...!ihnp4!okstate!uokvax!uokmet!kwthomas

ddl@husc6.UUCP (07/14/86)

In article <1500018@uokmet.UUCP>, root@uokmet.UUCP writes:
> 
> Subject: symlink bug
> Index:	sys/sys3.c 2.9bsd
> 
> Description:
> 	Symlink() always creates a link to "something", even if the original
> 	file doesn't exist.
> 
	This is not a bug; do not apply the fix shown.  It is often
necessary/useful to create symlinks to files that do not (yet) exist.
We do it all the time for log files which can be removed by cron.  In
any event, the proposed fix would not prevent symlinks which point
at nothing as it is still possible to remove the pointed-to file
after the fact.  If you are really worried about this, modify ln(1)
to check for the source file, but don't bother posting the change.

					Dan Lanciani
					ddl@harvard.*

chris@umcp-cs.UUCP (07/14/86)

In article <1500018@uokmet.UUCP> root@uokmet.UUCP writes:
>Description:
>	Symlink() always creates a link to "something", even if the original
>	file doesn't exist.

This is not a bug.

>Fix:
>	add
>		ip = namei(uchar, LOOKUP, 1);
>		if (ip == NULL)
>			return;

You had better iput() the inode afterward---not that you should be
checking for existence of the `destination' string in the first place.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

root@uokmet.UUCP.UUCP (07/15/86)

I just discovered that the "bug fix" now creates major problems.  Accessing
the symbolic link cause the process to HANG ("ps" shows "inode").  It
looks like perhaps things like "iupdat" and "prele" may need to be called.
If anyone knows the specifics on this, let me (and the rest of the 2bsd
world) know, so the original problem can be fixed once and for all.

In the mean time, DON'T use the bug fix.

	Kevin W. Thomas
UUCP: ihnp4!okstate!uokvax!uokmet!kwthomas