openat: fix GNU/Hurd bug in unlinkat
authorEric Blake <ebb9@byu.net>
Tue, 6 Oct 2009 18:03:58 +0000 (12:03 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 7 Oct 2009 04:09:49 +0000 (22:09 -0600)
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>
ChangeLog
doc/posix-functions/unlink.texi
doc/posix-functions/unlinkat.texi
m4/openat.m4

index 7ab9135..05a4730 100644 (file)
--- 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.
index 1249c42..1df1e30 100644 (file)
@@ -10,7 +10,7 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 Some systems mistakenly succeed on @code{unlink("file/")}:
-Solaris 9.
+GNU/Hurd, Solaris 9.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index dfff9b9..1ec724e 100644 (file)
@@ -15,7 +15,7 @@ glibc 2.3.6, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX
 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:
index 42df3ee..6b4f95c 100644 (file)
@@ -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_DEFUN([gl_FUNC_OPENAT],
   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.