From: Eric Blake Date: Tue, 6 Oct 2009 18:03:58 +0000 (-0600) Subject: openat: fix GNU/Hurd bug in unlinkat X-Git-Tag: v0.1~5359 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=3cfa87074aacbe7975f7b019d652a97488173f02;p=gnulib.git 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 --- diff --git a/ChangeLog b/ChangeLog index 7ab913532..05a473067 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-06 Eric Blake + 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. diff --git a/doc/posix-functions/unlink.texi b/doc/posix-functions/unlink.texi index 1249c4286..1df1e30b3 100644 --- a/doc/posix-functions/unlink.texi +++ b/doc/posix-functions/unlink.texi @@ -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: diff --git a/doc/posix-functions/unlinkat.texi b/doc/posix-functions/unlinkat.texi index dfff9b9bc..1ec724e4e 100644 --- a/doc/posix-functions/unlinkat.texi +++ b/doc/posix-functions/unlinkat.texi @@ -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: diff --git a/m4/openat.m4 b/m4/openat.m4 index 42df3ee72..6b4f95c76 100644 --- 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_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.