summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-05-29 03:11:59 +0100
committerPádraig Brady <P@draigBrady.com>2015-05-29 04:05:14 +0100
commitc79f3527498974c328404ed6807f9aaa5608832e (patch)
tree8d7beac69204f24c5f25f704aad1bfbd0987c4fc /m4
parente176ee0b5d8e90b0d3871ee778d290bc3d6abe96 (diff)
downloadgnulib-c79f3527498974c328404ed6807f9aaa5608832e.tar.gz
linkat: avoid OS X 10.10 trailing slash with symlink bug
On Darwin 14.3.0 linkat(,"path1",,"dangling_symlink/",) causes the symlink to be dereferenced, and if it points to a non existent file, that file will be created as a hard link to "path1". This fixes a test failure in test-linkat.c. * m4/linkat.m4 (gl_FUNC_LINKAT): Augment the test with this case. The existing workaround in linkat.c for trailing slash issues, suffices for this case. * doc/posix-functions/linkat.texi: Add OS X 10.10 to the list of platforms with trailing slash issues.
Diffstat (limited to 'm4')
-rw-r--r--m4/linkat.m414
1 files changed, 12 insertions, 2 deletions
diff --git a/m4/linkat.m4 b/m4/linkat.m4
index 567cb5dcaa..03cf23a2e4 100644
--- a/m4/linkat.m4
+++ b/m4/linkat.m4
@@ -52,7 +52,7 @@ AC_DEFUN([gl_FUNC_LINKAT],
AC_CACHE_CHECK([whether linkat handles trailing slash correctly],
[gl_cv_func_linkat_slash],
- [rm -rf conftest.a conftest.b conftest.c conftest.d
+ [rm -rf conftest.a conftest.b conftest.c conftest.d conftest.e conftest.s
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
@@ -83,6 +83,16 @@ AC_DEFUN([gl_FUNC_LINKAT],
if (linkat (AT_FDCWD, "conftest.a", AT_FDCWD, "conftest.d/",
AT_SYMLINK_FOLLOW) == 0)
result |= 8;
+
+ /* On OS X 10.10 a trailing "/" will cause the second path to be
+ dereferenced, and thus will succeed on a dangling symlink. */
+ if (symlink ("conftest.e", "conftest.s") == 0)
+ {
+ if (linkat (AT_FDCWD, "conftest.a", AT_FDCWD, "conftest.s/",
+ AT_SYMLINK_FOLLOW) == 0)
+ result |= 16;
+ }
+
return result;
]])],
[gl_cv_func_linkat_slash=yes],
@@ -93,7 +103,7 @@ AC_DEFUN([gl_FUNC_LINKAT],
*) gl_cv_func_linkat_slash="guessing no";;
esac
])
- rm -rf conftest.a conftest.b conftest.c conftest.d])
+ rm -rf conftest.a conftest.b conftest.c conftest.d conftest.e conftest.s])
case "$gl_cv_func_linkat_slash" in
*yes) gl_linkat_slash_bug=0 ;;
*) gl_linkat_slash_bug=1 ;;