From c2df294e9e4a8603fe7134b4f042e6641b07215a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 26 Mar 2019 19:09:35 +0000 Subject: [PATCH] Autoconf workaround for missing . glob.h is another missing facility in Android+Termux. The workaround is to condition out local wildcard support completely, so that PSFTP commands like 'mput *.txt' won't manage to do anything. But at least the program will compile. --- configure.ac | 2 +- unix/uxsftp.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index c44e1f0e..3d9c6873 100644 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,7 @@ AC_CHECK_LIB(X11, XOpenDisplay, AC_CHECK_FUNCS([getaddrinfo posix_openpt ptsname setresuid strsignal updwtmpx fstatat dirfd futimes setpwent endpwent]) AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include ]]) -AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h]) +AC_CHECK_HEADERS([sys/auxv.h asm/hwcap.h glob.h]) AC_SEARCH_LIBS([clock_gettime], [rt], [AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Define if clock_gettime() is available])]) AC_CACHE_CHECK([for SO_PEERCRED and dependencies], [x_cv_linux_so_peercred], [ diff --git a/unix/uxsftp.c b/unix/uxsftp.c index 69abf725..caf705e9 100644 --- a/unix/uxsftp.c +++ b/unix/uxsftp.c @@ -12,12 +12,15 @@ #include #include #include -#include #include "putty.h" #include "ssh.h" #include "psftp.h" +#if HAVE_GLOB_H +#include +#endif + /* * In PSFTP our selects are synchronous, so these functions are * empty stubs. @@ -358,6 +361,7 @@ int test_wildcard(const char *name, bool cmdline) */ return WCTYPE_NONEXISTENT; } else { +#if HAVE_GLOB_H glob_t globbed; int ret = WCTYPE_NONEXISTENT; @@ -368,12 +372,18 @@ int test_wildcard(const char *name, bool cmdline) } return ret; +#else + /* On a system without glob.h, we just have to return a + * failure code */ + return WCTYPE_NONEXISTENT; +#endif } } /* * Actually return matching file names for a local wildcard. */ +#if HAVE_GLOB_H struct WildcardMatcher { glob_t globbed; int i; @@ -400,6 +410,20 @@ void finish_wildcard_matching(WildcardMatcher *dir) { globfree(&dir->globbed); sfree(dir); } +#else +WildcardMatcher *begin_wildcard_matching(const char *name) +{ + return NULL; +} +char *wildcard_get_filename(WildcardMatcher *dir) +{ + unreachable("Can't construct a valid WildcardMatcher without "); +} +void finish_wildcard_matching(WildcardMatcher *dir) +{ + unreachable("Can't construct a valid WildcardMatcher without "); +} +#endif char *stripslashes(const char *str, bool local) {