- (djm) Work around Solaris' broken struct dirent. Diagnosis and suggested

fix from Philippe Levan <levan@epix.net>
This commit is contained in:
Damien Miller 2001-03-28 14:35:30 +10:00
Родитель c79bc0d75b
Коммит 18bb473eb0
4 изменённых файлов: 38 добавлений и 9 удалений

Просмотреть файл

@ -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@Informatik.TU-Chemnitz.DE>
- (djm) Work around Solaris' broken struct dirent. Diagnosis and suggested
fix from Philippe Levan <levan@epix.net>
20010327
- Attempt sync with sshlogin.c w/ OpenBSD (mainly CVS ID)
@ -4730,4 +4732,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.1022 2001/03/28 03:03:42 djm Exp $
$Id: ChangeLog,v 1.1023 2001/03/28 04:35:30 djm Exp $

Просмотреть файл

@ -1,4 +1,4 @@
/* $Id: acconfig.h,v 1.108 2001/03/17 01:15:38 mouring Exp $ */
/* $Id: acconfig.h,v 1.109 2001/03/28 04:35:30 djm Exp $ */
#ifndef _CONFIG_H
#define _CONFIG_H
@ -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 ************** */

Просмотреть файл

@ -1,4 +1,4 @@
# $Id: configure.in,v 1.268 2001/03/28 03:03:42 djm Exp $
# $Id: configure.in,v 1.269 2001/03/28 04:35:30 djm Exp $
AC_INIT(ssh.c)
@ -404,6 +404,20 @@ AC_EGREP_CPP(FOUNDIT,
]
)
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,

Просмотреть файл

@ -65,7 +65,9 @@ void *fudge_opendir(const char *path)
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 @@ struct dirent *fudge_readdir(struct SFTP_OPENDIR *od)
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)