diff --git a/ChangeLog b/ChangeLog index 3a7315b25..df6fba7aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -117,8 +117,10 @@ [regress/ssh2putty.sh] Add OpenBSD tag to make syncs easier - (dtucker) [regress/portnum.sh] Import new test. - - (dtucker) [configure.ac sftp-client.c] DOTTIF is in fs/ffs/dir.h on at + - (dtucker) [configure.ac sftp-client.c] DTOTIF is in fs/ffs/dir.h on at least dragonflybsd. + - (dtucker) d_type is not mandated by POSIX, so add fallback code using + stat(), needed on at least cygwin. 20091002 - (djm) [Makefile.in] Mention readconf.o in ssh-keysign's make deps. diff --git a/configure.ac b/configure.ac index 759047f10..80db43af1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $Id: configure.ac,v 1.428 2009/10/07 04:49:48 dtucker Exp $ +# $Id: configure.ac,v 1.429 2009/10/07 07:56:10 dtucker Exp $ # # Copyright (c) 1999-2004 Damien Miller # @@ -15,7 +15,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) -AC_REVISION($Revision: 1.428 $) +AC_REVISION($Revision: 1.429 $) AC_CONFIG_SRCDIR([ssh.c]) AC_CONFIG_HEADER(config.h) @@ -1137,6 +1137,8 @@ AC_CHECK_DECL(DTTOIF, #include ]) +AC_CHECK_MEMBERS([struct dirent.d_type],,, [#include ]) + AC_MSG_CHECKING([for /proc/pid/fd directory]) if test -d "/proc/$$/fd" ; then AC_DEFINE(HAVE_PROC_PID, 1, [Define if you have /proc/$pid/fd]) diff --git a/sftp-client.c b/sftp-client.c index b49e81b91..a9c895a0d 100644 --- a/sftp-client.c +++ b/sftp-client.c @@ -1454,6 +1454,20 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path, return status; } +static mode_t +dirent_to_mode(struct dirent *dp) +{ +#if defined(HAVE_STRUCT_DIRENT_D_TYPE) && defined(DTTOIF) + return DTTOIF(dp->d_type); +#else + struct stat sb; + + if (stat(dp->d_name, &sb) == -1) + return 0; + return sb.st_mode; +#endif +} + static int upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, int pflag, int printflag, int depth) @@ -1515,7 +1529,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, new_dst = path_append(dst, filename); new_src = path_append(src, filename); - if (S_ISDIR(DTTOIF(dp->d_type))) { + if (S_ISDIR(dirent_to_mode(dp))) { if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) continue; @@ -1523,7 +1537,7 @@ upload_dir_internal(struct sftp_conn *conn, char *src, char *dst, if (upload_dir_internal(conn, new_src, new_dst, pflag, depth + 1, printflag) == -1) ret = -1; - } else if (S_ISREG(DTTOIF(dp->d_type)) ) { + } else if (S_ISREG(dirent_to_mode(dp))) { if (do_upload(conn, new_src, new_dst, pflag) == -1) { error("Uploading of file %s to %s failed!", new_src, new_dst);