sftp client globbing problems on Solaris, Irix, etc
Damien Miller
djm at mindrot.org
Wed Mar 28 13:30:32 EST 2001
Could you please try the below diff if you have been experiencing
problems with the globbing support in the sftp client. There have been
a few reports that it doesn't work on Solaris, etc.
Index: ChangeLog
===================================================================
RCS file: /var/cvs/openssh/ChangeLog,v
retrieving revision 1.1022
diff -u -r1.1022 ChangeLog
--- ChangeLog 2001/03/28 03:03:42 1.1022
+++ ChangeLog 2001/03/28 03:28:37
@@ -2,6 +2,8 @@
- (djm) Reorder tests and library inclusion for Krb4/AFS to try to
resolve linking conflicts with libcrypto. Report and suggested fix
from Holger Trapp <Holger.Trapp at Informatik.TU-Chemnitz.DE>
+ - (djm) Work around Solaris' broken struct dirent. Diagnosis and suggested
+ fix from Philippe Levan <levan at epix.net>
20010327
- Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID)
Index: acconfig.h
===================================================================
RCS file: /var/cvs/openssh/acconfig.h,v
retrieving revision 1.108
diff -u -r1.108 acconfig.h
--- acconfig.h 2001/03/17 01:15:38 1.108
+++ acconfig.h 2001/03/28 03:28:37
@@ -308,6 +308,9 @@
/* Define if your system glob() function has gl_matchc options in glob_t */
#undef GLOB_HAS_GL_MATCHC
+/* Define in your struct dirent expects you to allocate extra space for d_name */
+#undef BROKEN_ONE_BYTE_DIRENT_D_NAME
+
@BOTTOM@
/* ******************* Shouldn't need to edit below this line ************** */
Index: configure.in
===================================================================
RCS file: /var/cvs/openssh/configure.in,v
retrieving revision 1.268
diff -u -r1.268 configure.in
--- configure.in 2001/03/28 03:03:42 1.268
+++ configure.in 2001/03/28 03:28:37
@@ -404,6 +404,20 @@
]
)
+AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
+AC_TRY_RUN(
+ [
+#include <sys/types.h>
+#include <dirent.h>
+int main(void){struct dirent d;return(sizeof(d.d_name)<=sizeof(char));}
+ ],
+ [AC_MSG_RESULT(yes)],
+ [
+ AC_MSG_RESULT(no)
+ AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
+ ]
+)
+
# Check whether user wants S/Key support
SKEY_MSG="no"
AC_ARG_WITH(skey,
Index: sftp-glob.c
===================================================================
RCS file: /var/cvs/openssh/sftp-glob.c,v
retrieving revision 1.3
diff -u -r1.3 sftp-glob.c
--- sftp-glob.c 2001/03/17 00:34:46 1.3
+++ sftp-glob.c 2001/03/28 03:28:37
@@ -65,7 +65,9 @@
struct dirent *fudge_readdir(struct SFTP_OPENDIR *od)
{
- static struct dirent ret;
+ /* Solaris needs sizeof(dirent) + path length (see below) */
+ static char buf[sizeof(struct dirent) + MAXPATHLEN];
+ struct dirent *ret = (struct dirent *)buf;
#ifdef __GNU_LIBRARY__
static int inum = 1;
#endif /* __GNU_LIBRARY__ */
@@ -73,22 +75,30 @@
if (od->dir[od->offset] == NULL)
return(NULL);
- memset(&ret, 0, sizeof(ret));
- strlcpy(ret.d_name, od->dir[od->offset++]->filename,
- sizeof(ret.d_name));
+ memset(buf, 0, sizeof(buf));
+ /*
+ * Solaris defines dirent->d_name as a one byte array and expects
+ * you to hack around it.
+ */
+#ifdef BROKEN_ONE_BYTE_DIRENT_D_NAME
+ strlcpy(ret->d_name, od->dir[od->offset++]->filename, MAXPATHLEN);
+#else
+ strlcpy(ret->d_name, od->dir[od->offset++]->filename,
+ sizeof(ret->d_name));
+#endif
#ifdef __GNU_LIBRARY__
/*
* Idiot glibc uses extensions to struct dirent for readdir with
* ALTDIRFUNCs. Not that this is documented anywhere but the
* source... Fake an inode number to appease it.
*/
- ret.d_ino = inum++;
+ ret->d_ino = inum++;
if (!inum)
inum = 1;
#endif /* __GNU_LIBRARY__ */
- return(&ret);
+ return(ret);
}
void fudge_closedir(struct SFTP_OPENDIR *od)
--
| Damien Miller <djm at mindrot.org> \ ``E-mail attachments are the poor man's
| http://www.mindrot.org / distributed filesystem'' - Dan Geer
More information about the openssh-unix-dev
mailing list