From owner-freebsd-bugs Tue Jan 16 10:50:27 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B97D037B6A3 for ; Tue, 16 Jan 2001 10:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f0GIo1f96376; Tue, 16 Jan 2001 10:50:01 -0800 (PST) (envelope-from gnats) Received: from iraun1.ira.uka.de (iraun1.ira.uka.de [129.13.10.90]) by hub.freebsd.org (Postfix) with ESMTP id 7982D37B69F for ; Tue, 16 Jan 2001 10:46:22 -0800 (PST) Received: from i30nb2.ira.uka.de by iraun1 (PP) with ESMTP; Tue, 16 Jan 2001 19:45:42 +0100 Received: (from esk@localhost) by i30nb2.ira.uka.de (8.11.1/8.11.1) id f0GIjbV02366; Tue, 16 Jan 2001 19:45:37 +0100 (CET) (envelope-from esk) Message-Id: <200101161845.f0GIjbV02366@i30nb2.ira.uka.de> Date: Tue, 16 Jan 2001 19:45:37 +0100 (CET) From: esk@ira.uka.de Reply-To: esk@ira.uka.de To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/24390: Replacing old dir-symlinks when using /bin/ln Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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