From esk@ira.uka.de  Tue Jan 16 10:46:23 2001
Return-Path: <esk@ira.uka.de>
Received: from iraun1.ira.uka.de (iraun1.ira.uka.de [129.13.10.90])
	by hub.freebsd.org (Postfix) with ESMTP id 7982D37B69F
	for <FreeBSD-gnats-submit@freebsd.org>; 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
Subject: Replacing old dir-symlinks when using /bin/ln
X-Send-Pr-Version: 3.2

>Number:         24390
>Category:       bin
>Synopsis:       ln(1) Replacing old dir-symlinks when using /bin/ln
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-standards
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 16 10:50:01 PST 2001
>Closed-Date:    Tue Apr 20 19:45:46 UTC 2010
>Last-Modified:  Tue Apr 20 19:45:46 UTC 2010
>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:
Responsible-Changed-From-To: freebsd-bugs->freebsd-standards 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 23:25:01 PDT 2003 
Responsible-Changed-Why:  
Assign to standards group to determine correct behaviour 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24390 
State-Changed-From-To: open->closed 
State-Changed-By: jilles 
State-Changed-When: Tue Apr 20 19:45:45 UTC 2010 
State-Changed-Why:  
Duplicate of standards/41576 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24390 
>Unformatted:
