diff -ruN openssh-1.2.2/bsd-login.c ossh-1.2.2n/bsd-login.c --- openssh-1.2.2/bsd-login.c Sat Dec 25 17:21:48 1999 +++ ossh-1.2.2n/bsd-login.c Thu Jan 27 00:42:24 2000 @@ -48,9 +48,7 @@ #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include #endif -#ifdef HAVE_UTMP_H -# include -#endif + #include #include diff -ruN openssh-1.2.2/bsd-login.h ossh-1.2.2n/bsd-login.h --- openssh-1.2.2/bsd-login.h Fri Dec 24 17:11:29 1999 +++ ossh-1.2.2n/bsd-login.h Thu Jan 27 00:42:24 2000 @@ -4,8 +4,6 @@ # include "config.h" # ifndef HAVE_LOGIN -# include - # if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include diff -ruN openssh-1.2.2/bsd-misc.c ossh-1.2.2n/bsd-misc.c --- openssh-1.2.2/bsd-misc.c Sat Jan 22 17:32:03 2000 +++ ossh-1.2.2n/bsd-misc.c Thu Jan 27 00:42:24 2000 @@ -239,3 +239,89 @@ return(setreuid(-1,euid)); } #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ + +/* putenv: + * implementation of putenv, from the comp.sys.next.programmers + * FAQ list and misc-source repository. I believe it comes + * from Thomas Funke . Includes + * some mods from Garance Drosehn . + */ +#if !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) +int putenv(char *s) +{ + int nlen; + char *cptr; + char **nenv, **eptr; + extern char **environ; + + /* first see if there is any environment setup. If not, + * create it with this single variable in it. + */ + if (environ == NULL) { + nenv = (char **) malloc(2 * sizeof(char *)); + if (nenv == NULL) + return -1; + environ = nenv; + *nenv = s; + nenv[1] = NULL; + return 0; + } + + /* If there is an environ setup, see if there is an existing + * 'name=value' with the same name as s. + */ + for (cptr = s; *cptr != '=' && *cptr != '\0'; cptr++) + ; + if (*cptr == '=' && cptr > s) { + nlen = cptr - s + 1; + for (eptr = environ; *eptr != NULL; eptr++) { + if (strncmp(*eptr, s, nlen) == 0) { + *eptr = s; + return 0; + } + } + } + + /* New name, so must change environ. + */ + for (eptr = environ; *eptr != NULL; eptr++) + ; + nenv = (char **) malloc((eptr - environ + 2) * sizeof(char *)); + if (nenv == NULL) + return -1; + eptr = environ; + environ = nenv; + while ((*nenv = *eptr) != NULL) + nenv++, eptr++; + *nenv = s; + nenv[1] = NULL; + return 0; +} /* end putenv() */ +#endif /* !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) */ + +#ifdef NEED_WAITPID +int +waitpid(pid, stat_loc, options) + int pid; + int *stat_loc; + int options; +{ + if (pid <= 0) + { + if (pid != -1) + { + errno = EINVAL; + return -1; + } + pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */ + } + return wait4(pid, (union wait *)stat_loc, options, NULL); +} +#endif /* NEED_WAITPID */ + +#ifdef NEED_SETSID +pid_t setsid(void) +{ + return setpgrp(0, getpid()); +} +#endif /* !NEED_SETSID */ diff -ruN openssh-1.2.2/bsd-misc.h ossh-1.2.2n/bsd-misc.h --- openssh-1.2.2/bsd-misc.h Thu Jan 6 03:28:41 2000 +++ ossh-1.2.2n/bsd-misc.h Thu Jan 27 00:42:24 2000 @@ -65,4 +65,16 @@ int seteuid(uid_t euid); #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ +#if !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) +int putenv(char *s); +#endif /* !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) */ + +#ifdef NEED_WAITPID +int waitpid(int pid,int *stat_loc,int options); +#endif /* NEED_WAITPID */ + +#ifdef NEED_SETSID +pid_t setsid(void); +#endif /* NEED_SETSID */ + #endif /* _BSD_MISC_H */ diff -ruN openssh-1.2.2/configure.in ossh-1.2.2n/configure.in --- openssh-1.2.2/configure.in Tue Jan 25 19:15:31 2000 +++ ossh-1.2.2n/configure.in Thu Jan 27 00:42:24 2000 @@ -78,6 +78,12 @@ dnl Check for some target-specific stuff case "$host" in +*-next-*) + AC_DEFINE(HAVE_NEXT) + AC_DEFINE(NEED_SETSID) + AC_DEFINE(NEED_WAITPID) + CFLAGS="$CFLAGS -posix" + ;; *-*-aix*) AFS_LIBS="-lld" AC_DEFINE(BROKEN_GETADDRINFO) @@ -427,6 +433,14 @@ [AC_DEFINE(HAVE_ID_IN_UTMP) AC_MSG_RESULT(yes); ], [AC_MSG_RESULT(no)] ) +AC_MSG_CHECKING([whether utmp.h has ut_user or ut_name field]) +AC_EGREP_HEADER(ut_user, utmp.h, + [AC_DEFINE(HAVE_USER_IN_UTMP) AC_MSG_RESULT(yes); ], + [AC_MSG_RESULT(no)] +AC_MSG_CHECKING([whether utmp.h has ut_type field]) +AC_EGREP_HEADER(ut_type, utmp.h, + [AC_DEFINE(HAVE_TYPE_IN_UTMP) AC_MSG_RESULT(yes); ], + [AC_MSG_RESULT(no)] AC_MSG_CHECKING([whether utmp.h has ut_addr field]) AC_EGREP_HEADER(ut_addr, utmp.h, [AC_DEFINE(HAVE_ADDR_IN_UTMP) AC_MSG_RESULT(yes); ], @@ -487,7 +501,7 @@ ], [ AC_MSG_CHECKING([location of lastlog file]) - for lastlog in /var/log/lastlog /var/adm/lastlog /etc/security/lastlog ; do + for lastlog in /var/log/lastlog /var/adm/lastlog /etc/security/lastlog /usr/adm/lastlog; do if test -f $lastlog ; then gotlastlog="file" break diff -ruN openssh-1.2.2/includes.h ossh-1.2.2n/includes.h --- openssh-1.2.2/includes.h Tue Jan 18 20:45:07 2000 +++ ossh-1.2.2n/includes.h Thu Jan 27 00:42:24 2000 @@ -32,8 +32,10 @@ #include #include -#include -#include +#ifndef HAVE_NEXT +# include +# include +#endif #include #include @@ -91,6 +93,23 @@ #endif #include "version.h" + +#ifdef HAVE_USER_IN_UTMP +# define UTMP_NAME wt.ut_user +#else +# define UTMP_NAME wt.ut_name +#endif + +/* NeXTism that are evil This is just for quick port reasons + I plan on attempting to sort out and deal with this stuff when I + have a chance to skim more of the header files. - Ben Lindstrom */ +#ifdef HAVE_NEXT +#define TCP_NODELAY IPTOS_LOWDELAY +#define IP_TOS 1 +#define IPTOS_LOWDELAY 0x10 /* TCP_NODELAY */ +#define IPTOS_THROUGHPUT 0x08 +#define MAIL_DIRECTORY "/usr/spool/mail" +#endif /* BSD function replacements */ #include "bsd-bindresvport.h" diff -ruN openssh-1.2.2/login.c ossh-1.2.2n/login.c --- openssh-1.2.2/login.c Tue Jan 25 18:04:48 2000 +++ ossh-1.2.2n/login.c Thu Jan 27 00:42:24 2000 @@ -23,9 +23,6 @@ #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) # include #endif -#ifdef HAVE_UTMP_H -# include -#endif #include "ssh.h" #ifdef HAVE_UTIL_H @@ -108,8 +105,10 @@ return 0; } +#ifdef HAVE_TYPE_IN_UTMP if ( wt.ut_type == USER_PROCESS) { - if ( !strncmp(logname, wt.ut_user, 8) ) { +#endif /* HAVE_TYPE_IN_UTMP */ + if ( !strncmp(logname, UTMP_NAME, 8) ) { t = (unsigned long) wt.ut_time; #ifdef HAVE_HOST_IN_UTMP if (bufsize > sizeof(wt.ut_host) + 1) @@ -120,7 +119,9 @@ buf[0] = 0; #endif /* HAVE_HOST_IN_UTMP */ } +#ifdef HAVE_TYPE_IN_UTMP } +#endif /* HAVE_TYPE_IN_UTMP */ if (lseek(fd1, (off_t)(0-2*sizeof(struct utmp)), SEEK_CUR) == -1) break; diff -ruN openssh-1.2.2/next-termios.c ossh-1.2.2n/next-termios.c --- openssh-1.2.2/next-termios.c Wed Dec 31 18:00:00 1969 +++ ossh-1.2.2n/next-termios.c Thu Jan 27 01:04:39 2000 @@ -0,0 +1,242 @@ +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)termios.c 8.2 (Berkeley) 2/21/94"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +int +tcgetattr(fd, t) + int fd; + struct termios *t; +{ + + return (ioctl(fd, TIOCGETA, t)); +} + +int +tcsetattr(fd, opt, t) + int fd, opt; + const struct termios *t; +{ + struct termios localterm; + + if (opt & TCSASOFT) { + localterm = *t; + localterm.c_cflag |= CIGNORE; + t = &localterm; + } + switch (opt & ~TCSASOFT) { + case TCSANOW: + return (ioctl(fd, TIOCSETA, t)); + case TCSADRAIN: + return (ioctl(fd, TIOCSETAW, t)); + case TCSAFLUSH: + return (ioctl(fd, TIOCSETAF, t)); + default: + errno = EINVAL; + return (-1); + } +} + +int tcsetpgrp(int fd, pid_t pgrp) +{ + int s; + + s = pgrp; + return (ioctl(fd, TIOCSPGRP, &s)); +} + +pid_t tcgetpgrp(int fd) +{ + int s; + + if (ioctl(fd, TIOCGPGRP, &s) < 0) + return ((pid_t)-1); + + return ((pid_t)s); +} +/* +speed_t cfgetispeed(const struct termios *); +speed_t cfgetospeed(const struct termios *); +*/ + +speed_t cfgetospeed(const struct termios *t) +{ + + return (t->c_ospeed); +} + +speed_t cfgetispeed(t) + const struct termios *t; +{ + + return (t->c_ispeed); +} + +/*int cfsetospeed(struct termios *, int);*/ +int +cfsetospeed(struct termios *t,int speed) +{ + + t->c_ospeed = speed; + return (0); +} + +int +cfsetispeed(t, speed) + struct termios *t; + speed_t speed; +{ + + t->c_ispeed = speed; + return (0); +} + +void +cfsetspeed(t, speed) + struct termios *t; + speed_t speed; +{ + + t->c_ispeed = t->c_ospeed = speed; +} + +/* + * Make a pre-existing termios structure into "raw" mode: character-at-a-time + * mode with no characters interpreted, 8-bit data path. + */ +void +cfmakeraw(t) + struct termios *t; +{ + + t->c_iflag &= +~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IGNPAR); + t->c_iflag |= IGNBRK; + t->c_oflag &= ~OPOST; + t->c_lflag &= +~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|TOSTOP|PENDIN); + t->c_cflag &= ~(CSIZE|PARENB); + t->c_cflag |= CS8|CREAD; + t->c_cc[VMIN] = 1; + t->c_cc[VTIME] = 0; +} + +int +tcsendbreak(fd, len) + int fd, len; +{ + struct timeval sleepytime; + + sleepytime.tv_sec = 0; + sleepytime.tv_usec = 400000; + if (ioctl(fd, TIOCSBRK, 0) == -1) + return (-1); + (void)select(0, 0, 0, 0, &sleepytime); + if (ioctl(fd, TIOCCBRK, 0) == -1) + return (-1); + return (0); +} + +int +tcdrain(fd) + int fd; +{ + + return (ioctl(fd, TIOCDRAIN, 0)); +} + +int +tcflush(fd, which) + int fd, which; +{ + int com; + + switch (which) { + case TCIFLUSH: + com = FREAD; + break; + case TCOFLUSH: + com = FWRITE; + break; + case TCIOFLUSH: + com = FREAD | FWRITE; + break; + default: + errno = EINVAL; + return (-1); + } + return (ioctl(fd, TIOCFLUSH, &com)); +} + +int +tcflow(fd, action) + int fd, action; +{ + struct termios term; + u_char c; + + switch (action) { + case TCOOFF: + return (ioctl(fd, TIOCSTOP, 0)); + case TCOON: + return (ioctl(fd, TIOCSTART, 0)); + case TCION: + case TCIOFF: + if (tcgetattr(fd, &term) == -1) + return (-1); + c = term.c_cc[action == TCIOFF ? VSTOP : VSTART]; + if (write(fd, &c, sizeof(c)) == -1) + return (-1); + return (0); + default: + errno = EINVAL; + return (-1); + } + /* NOTREACHED */ +}