Hi,

Can you review the attached patch?  Currently kern_alternate_path follows
symbolic links which means it fails to return the alternate path if it's
a dead link.  This means syscalls like readlink and lstat fail on a dead
link that exists under /compat/linux but not under /.  I also think it's
better to report an error to applications that try to open such a path
instead of ignoring the link and trying the path under /.
Index: sys/kern/vfs_lookup.c
===================================================================
--- sys/kern/vfs_lookup.c	(revision 324614)
+++ sys/kern/vfs_lookup.c	(working copy)
@@ -1390,13 +1390,13 @@ kern_alternate_path(struct thread *td, const char *pre
 		for (cp = &ptr[len] - 1; *cp != '/'; cp--);
 		*cp = '\0';
 
-		NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+		NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
 		error = namei(&nd);
 		*cp = '/';
 		if (error != 0)
 			goto keeporig;
 	} else {
-		NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
+		NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf, td);
 
 		error = namei(&nd);
 		if (error != 0)
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-emulation
To unsubscribe, send any mail to "[email protected]"

Reply via email to