changeset 12128:a92e67f6c6f1

openat: fix GNU/Hurd bug in unlinkat unlinkat(fd,"file/",0) mistakenly succeeded. * m4/openat.m4 (gl_FUNC_OPENAT): Replace unlinkat if unlink is broken. * doc/posix-functions/unlink.texi (unlink): Document this. * doc/posix-functions/unlinkat.texi (unlinkat): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Tue, 06 Oct 2009 12:03:58 -0600
parents bda9467a9d66
children 8e8f0292e99f
files ChangeLog doc/posix-functions/unlink.texi doc/posix-functions/unlinkat.texi m4/openat.m4
diffstat 4 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-10-06  Eric Blake  <ebb9@byu.net>
 
+	openat: fix GNU/Hurd bug in unlinkat
+	* m4/openat.m4 (gl_FUNC_OPENAT): Replace unlinkat if unlink is
+	broken.
+	* doc/posix-functions/unlink.texi (unlink): Document this.
+	* doc/posix-functions/unlinkat.texi (unlinkat): Likewise.
+
 	fdopendir: fix GNU/Hurd bug
 	* m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Check for Hurd bug in
 	allowing non-directory fds.
--- a/doc/posix-functions/unlink.texi
+++ b/doc/posix-functions/unlink.texi
@@ -10,7 +10,7 @@
 @itemize
 @item
 Some systems mistakenly succeed on @code{unlink("file/")}:
-Solaris 9.
+GNU/Hurd, Solaris 9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/unlinkat.texi
+++ b/doc/posix-functions/unlinkat.texi
@@ -15,7 +15,7 @@
 But the replacement function is not safe to be used in libraries and is not multithread-safe.
 @item
 Some systems mistakenly succeed on @code{unlinkat(fd,"file/",flag)}:
-Solaris 9.
+GNU/Hurd, Solaris 9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/m4/openat.m4
+++ b/m4/openat.m4
@@ -1,4 +1,4 @@
-# serial 24
+# serial 25
 # See if we need to use our replacement for Solaris' openat et al functions.
 
 dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
@@ -27,8 +27,14 @@
   AC_CHECK_FUNCS_ONCE([lchmod])
   AC_REPLACE_FUNCS([fchmodat fstatat mkdirat openat unlinkat])
   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
+  AC_REQUIRE([gl_FUNC_UNLINK])
   case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in
-  yes+yes) ;;
+  yes+yes)
+    # GNU/Hurd has unlinkat, but it has the same bug as unlink.
+    if test $REPLACE_UNLINK = 1; then
+      AC_LIBOBJ([unlinkat])
+      REPLACE_UNLINKAT=1
+    fi ;;
   yes+*)
     # Solaris 9 has *at functions, but uniformly mishandles trailing
     # slash in all of them.