Add truncate() emulation to address Bug 208

This commit is contained in:
Tim Rice 2002-05-07 19:51:31 -07:00
parent f762a4bea5
commit 4bd2a19890
4 changed files with 31 additions and 5 deletions

View File

@ -1,3 +1,7 @@
20020507
- (tim) [configure.ac openbsd-compat/bsd-misc.c openbsd-compat/bsd-misc.h]
Add truncate() emulation to address Bug 208
20020506 20020506
- (djm) Unbreak auth-passwd.c for PAM and SIA - (djm) Unbreak auth-passwd.c for PAM and SIA
- (djm) Unbreak PAM auth for protocol 1. Report from Pekka Savola - (djm) Unbreak PAM auth for protocol 1. Report from Pekka Savola
@ -535,4 +539,4 @@
- (stevesk) entropy.c: typo in debug message - (stevesk) entropy.c: typo in debug message
- (djm) ssh-keygen -i needs seeded RNG; report from markus@ - (djm) ssh-keygen -i needs seeded RNG; report from markus@
$Id: ChangeLog,v 1.2095 2002/05/08 02:27:55 djm Exp $ $Id: ChangeLog,v 1.2096 2002/05/08 02:51:31 tim Exp $

View File

@ -1,4 +1,4 @@
# $Id: configure.ac,v 1.53 2002/04/25 18:17:05 stevesk Exp $ # $Id: configure.ac,v 1.54 2002/05/08 02:51:32 tim Exp $
AC_INIT AC_INIT
AC_CONFIG_SRCDIR([ssh.c]) AC_CONFIG_SRCDIR([ssh.c])
@ -572,7 +572,7 @@ AC_CHECK_FUNCS(arc4random b64_ntop bcopy bindresvport_sa \
realpath recvmsg rresvport_af sendmsg setdtablesize setegid \ realpath recvmsg rresvport_af sendmsg setdtablesize setegid \
setenv seteuid setlogin setproctitle setresgid setreuid setrlimit \ setenv seteuid setlogin setproctitle setresgid setreuid setrlimit \
setsid setvbuf sigaction sigvec snprintf socketpair strerror \ setsid setvbuf sigaction sigvec snprintf socketpair strerror \
strlcat strlcpy strmode strsep sysconf tcgetpgrp utimes \ strlcat strlcpy strmode strsep sysconf tcgetpgrp truncate utimes \
vhangup vsnprintf waitpid __b64_ntop _getpty) vhangup vsnprintf waitpid __b64_ntop _getpty)
dnl IRIX and Solaris 2.5.1 have dirname() in libgen dnl IRIX and Solaris 2.5.1 have dirname() in libgen

View File

@ -24,7 +24,7 @@
#include "includes.h" #include "includes.h"
RCSID("$Id: bsd-misc.c,v 1.5 2001/10/10 20:38:56 mouring Exp $"); RCSID("$Id: bsd-misc.c,v 1.6 2002/05/08 02:51:32 tim Exp $");
char *get_progname(char *argv0) char *get_progname(char *argv0)
{ {
@ -99,3 +99,22 @@ int utimes(char *filename, struct timeval *tvp)
return(utime(filename, &ub)); return(utime(filename, &ub));
} }
#endif #endif
#ifndef HAVE_TRUNCATE
int truncate (const char *path, off_t length)
{
int fd, ret, saverrno;
fd = open(path, O_WRONLY);
if (fd < 0)
return -1;
ret = ftruncate(fd, length);
saverrno = errno;
(void) close (fd);
if (ret == -1)
errno = saverrno;
return(ret);
}
#endif /* HAVE_TRUNCATE */

View File

@ -22,7 +22,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* $Id: bsd-misc.h,v 1.3 2001/04/09 14:50:56 stevesk Exp $ */ /* $Id: bsd-misc.h,v 1.4 2002/05/08 02:51:32 tim Exp $ */
#ifndef _BSD_MISC_H #ifndef _BSD_MISC_H
#define _BSD_MISC_H #define _BSD_MISC_H
@ -72,5 +72,8 @@ struct timeval {
int utimes(char *filename, struct timeval *tvp); int utimes(char *filename, struct timeval *tvp);
#endif /* HAVE_UTIMES */ #endif /* HAVE_UTIMES */
#ifndef HAVE_TRUNCATE
int truncate (const char *path, off_t length);
#endif /* HAVE_TRUNCATE */
#endif /* _BSD_MISC_H */ #endif /* _BSD_MISC_H */