Date: Tue, 16 Jan 2001 19:45:37 +0100 (CET) From: esk@ira.uka.de To: FreeBSD-gnats-submit@freebsd.org Subject: bin/24390: Replacing old dir-symlinks when using /bin/ln Message-ID: <200101161845.f0GIjbV02366@i30nb2.ira.uka.de>
next in thread | raw e-mail | index | archive | help
>Number: 24390 >Category: bin >Synopsis: Replacing old dir-symlinks when using /bin/ln >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Jan 16 10:50:01 PST 2001 >Closed-Date: >Last-Modified: >Originator: Espen Skoglund >Release: FreeBSD 4.2-STABLE i386 >Organization: Karlsruhe Inversity >Environment: >Description: I'm wondering about the semantics of the replacement functionality in `ln' when the file to be replaced is a symlink to a directory. I would have thought that this should behave in the same manner as if the target of `ln' was a normal file (i.e., the old symlink would be deleted, and a new link would be installed). This is, however, not the case. What happens is that `ln' follows the symlink into the directory and tries to install a symlink there instead. Is this really the desired behaviour? >How-To-Repeat: ; mkdir foo ; chmod a-w foo ; ln -sf foo bar ; ln -sf foo bar ln: bar/foo: Permission denied >Fix: --- /usr/src/bin/ln/ln.c Mon Sep 18 04:07:11 2000 +++ ln.c Tue Jan 16 19:27:41 2001 @@ -162,7 +162,8 @@ } /* If the source is a directory, append the target's name. */ - if (isdir || ((exists = !stat(source, &sb)) && S_ISDIR(sb.st_mode))) { + if ((isdir || ((exists = !stat(source, &sb)) && S_ISDIR(sb.st_mode))) + && !(!lstat(source, &sb) && S_ISLNK(sb.st_mode))) { if ((p = strrchr(target, '/')) == NULL) p = target; else >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200101161845.f0GIjbV02366>