- (dtucker) d_type is not mandated by POSIX, so add fallback code using

stat(), needed on at least cygwin.
This commit is contained in:
Darren Tucker 2009-10-07 18:56:10 +11:00
parent 4adeac764e
commit 538738d861
3 changed files with 23 additions and 5 deletions

View File

@ -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.

View File

@ -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 <fs/ffs/dir.h>
])
AC_CHECK_MEMBERS([struct dirent.d_type],,, [#include <dirent.h>])
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])

View File

@ -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);