summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2015-07-17 12:52:34 +1000
committerDarren Tucker <dtucker@zip.com.au>2015-07-17 12:58:02 +1000
commitd3e2aee41487d55b8d7d40f538b84ff1db7989bc (patch)
treecbe43672e70bc3fdcaf47c311dfabc8d282cacd5 /configure.ac
parent25b14610dab655646a109db5ef8cb4c4bf2a48a0 (diff)
Check if realpath works on nonexistent files.
On some platforms the native realpath doesn't work with non-existent files (this is actually specified in some versions of POSIX), however the sftp spec says its realpath with "canonicalize any given path name". On those platforms, use realpath from the compat library. In addition, when compiling with -DFORTIFY_SOURCE, glibc redefines the realpath symbol to the checked version, so redefine ours to something else so we pick up the compat version we want. bz#2428, ok djm@
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac27
1 files changed, 26 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 2240c725..9b05c30f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1674,7 +1674,6 @@ AC_CHECK_FUNCS([ \
pstat \
readpassphrase \
reallocarray \
- realpath \
recvmsg \
rresvport_af \
sendmsg \
@@ -1891,6 +1890,32 @@ AC_CHECK_FUNCS([setresgid], [
)
])
+AC_CHECK_FUNCS([realpath], [
+ dnl the sftp v3 spec says SSH_FXP_REALPATH will "canonicalize any given
+ dnl path name", however some implementations of realpath (and some
+ dnl versions of the POSIX spec) do not work on non-existent files,
+ dnl so we use the OpenBSD implementation on those platforms.
+ AC_MSG_CHECKING([if realpath works with non-existent files])
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+#include <limits.h>
+#include <stdlib.h>
+#include <errno.h>
+ ]], [[
+ char buf[PATH_MAX];
+ if (realpath("/opensshnonexistentfilename1234", buf) == NULL)
+ if (errno == ENOENT)
+ exit(1);
+ exit(0);
+ ]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_DEFINE([BROKEN_REALPATH], [1],
+ [realpath does not work with nonexistent files])
+ AC_MSG_RESULT([no])],
+ [AC_MSG_WARN([cross compiling: assuming working])]
+ )
+])
+
dnl Checks for time functions
AC_CHECK_FUNCS([gettimeofday time])
dnl Checks for utmp functions