changeset 12051:01c9ffd58a51

link-follow: ensure correct result * m4/fcntl_h.m4 (gl_FCNTL_H): Clean up temporary file. * m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): Likewise, and distinguish between possible failures. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Tue, 22 Sep 2009 06:24:25 -0600
parents d1840b588599
children 7891d97ab77c
files ChangeLog m4/fcntl_h.m4 m4/link-follow.m4
diffstat 3 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-22  Eric Blake  <ebb9@byu.net>
+
+	link-follow: ensure correct result
+	* m4/fcntl_h.m4 (gl_FCNTL_H): Clean up temporary file.
+	* m4/link-follow.m4 (gl_FUNC_LINK_FOLLOWS_SYMLINK): Likewise, and
+	distinguish between possible failures.
+
 2009-09-21  Eric Blake  <ebb9@byu.net>
 
 	fts: avoid compiler warning
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,4 +1,4 @@
-# serial 4
+# serial 5
 # Configure fcntl.h.
 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -38,6 +38,7 @@
 	      if (symlink (".", sym) != 0
 		  || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
 		status |= 32;
+	      unlink (sym);
 	    }
 	    {
 	      static char const file[] = "confdefs.h";
--- a/m4/link-follow.m4
+++ b/m4/link-follow.m4
@@ -1,4 +1,4 @@
-# serial 14
+# serial 15
 dnl Run a program to determine whether link(2) follows symlinks.
 dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
 
@@ -47,16 +47,16 @@
 
 	  /* Create a symlink to the regular file. */
 	  if (symlink (file, sym))
-	    abort ();
+	    return 2;
 
 	  /* Create a hard link to that symlink.  */
 	  if (link (sym, hard))
-	    abort ();
+	    return 3;
 
 	  if (lstat (hard, &sb_hard))
-	    abort ();
+	    return 4;
 	  if (lstat (file, &sb_file))
-	    abort ();
+	    return 5;
 
 	  /* If the dev/inode of hard and file are the same, then
 	     the link call followed the symlink.  */
@@ -67,6 +67,7 @@
 	[gl_cv_func_link_follows_symlink=yes], dnl Followed link/compile failed
 	[gl_cv_func_link_follows_symlink=unknown] dnl We're cross compiling.
       )
+      rm -f conftest.file conftest.sym conftest.hard
     ])
     case $gl_cv_func_link_follows_symlink in
       yes) gl_link_follows_symlinks=1 ;;