[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#226722: fails to create symlink



Package: busybox-cvs
Version: 20040101-1
Severity: grave

ln fails if the destination of the link does not exist relative to
the working directory.  It should be interpreted relative to the
directory in which the link will be created, not relative to the
working directory.

This breaks debian-installer.

Here is a test case:

 mkdir foo
 touch foo/bar
 ln -s bar foo/baz

A patch that fixes it is attached.

-- 
Matt Kraai                                         kraai@ftbfs.org
diff -ru busybox-cvs-20040101-old/coreutils/ln.c busybox-cvs-20040101/coreutils/ln.c
--- busybox-cvs-20040101-old/coreutils/ln.c	2004-01-07 14:52:51.000000000 -0800
+++ busybox-cvs-20040101/coreutils/ln.c	2004-01-07 15:35:36.000000000 -0800
@@ -62,6 +62,8 @@
 	}
 
 	do {
+		char *dest, *src_copy;
+
 		src_name = NULL;
 		src = last;
 
@@ -74,12 +76,16 @@
 			src_name = src;
 		}
 
-		if (stat(*argv, &statbuf)) {
+		src_copy = bb_xstrdup(src);
+		dest = concat_path_file(dirname(src_copy), *argv);
+		if (stat(dest, &statbuf)) {
 			bb_perror_msg(*argv);
 			status = EXIT_FAILURE;
 			free(src_name);
 			continue;
 		}
+		free(src_copy);
+		free(dest);
 
 		if (flag & LN_FORCE) {
 			unlink(src);

Reply to: