diff --git a/CREDITS b/CREDITS index 8d7014bbf..977129388 100644 --- a/CREDITS +++ b/CREDITS @@ -8,6 +8,7 @@ Andre Lucas - new login code, many fixes Andrew McGill - SCO fixes Andy Sloane - bugfixes Arkadiusz Miskiewicz - IPv6 compat fixes +Ben Lindstrom - NeXT support Ben Taylor - Solaris debugging and fixes Bratislav ILICH - Configure fix Chip Salzenberg - Assorted patches diff --git a/ChangeLog b/ChangeLog index b367ddc40..aa62aede5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ Martin Petrak - (djm) Include sys/types.h when including netinet/in.h in configure tests. Patch from Jun-ichiro itojun Hagino + - (djm) Started merge of Ben Lindstrom's NeXT support - OpenBSD CVS updates: - deraadt@cvs.openbsd.org 2000/06/17 09:58:46 [channels.c] diff --git a/Makefile.in b/Makefile.in index 4037bfe8a..b18444d3d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -36,7 +36,7 @@ TARGETS=ssh sshd ssh-add ssh-keygen ssh-agent scp $(EXTRA_TARGETS) LIBSSH_OBJS=atomicio.o authfd.o authfile.o aux.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o dispatch.o dsa.o fingerprint.o hmac.o hostfile.o key.o kex.o log.o match.o mpaux.o nchan.o packet.o radix.o entropy.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o uuencode.o xmalloc.o -LIBOPENBSD_COMPAT_OBJS=bsd-base64.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o fake-getaddrinfo.o fake-getnameinfo.o +LIBOPENBSD_COMPAT_OBJS=bsd-base64.o bsd-bindresvport.o bsd-daemon.o bsd-misc.o bsd-mktemp.o bsd-rresvport.o bsd-setenv.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o fake-getaddrinfo.o fake-getnameinfo.o next-posix.o SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o diff --git a/acconfig.h b/acconfig.h index 0a08ee6af..6e92e962a 100644 --- a/acconfig.h +++ b/acconfig.h @@ -6,6 +6,9 @@ @TOP@ +/* Define if you are on NeXT */ +#undef HAVE_NEXT + /* Define if you want to disable PAM support */ #undef DISABLE_PAM @@ -153,6 +156,8 @@ #undef HAVE_SOCKLEN_T #undef HAVE_SIZE_T #undef HAVE_SSIZE_T +#undef HAVE_MODE_T +#undef HAVE_PID_T #undef HAVE_STRUCT_SOCKADDR_STORAGE #undef HAVE_STRUCT_ADDRINFO #undef HAVE_STRUCT_IN6_ADDR diff --git a/configure.in b/configure.in index f0edebacc..3671f50cf 100644 --- a/configure.in +++ b/configure.in @@ -102,6 +102,17 @@ case "$host" in *-*-netbsd*) need_dash_r=1 ;; +*-next-*) + # hardwire lastlog location (can't detect it on some versions) + conf_lastlog_location="/usr/adm/lastlog" + AC_DEFINE(HAVE_NEXT) + CFLAGS="$CFLAGS -I/usr/local/include" + MAIL=/usr/spool/mail + conf_utmp_location=/etc/utmp + AC_MSG_WARN([*** Tested: PA-RISC/m68k Untested: Sparc/Intel]) + AC_MSG_WARN([*** Expect 'scp' to fail!]) + AC_MSG_WARN([*** Please report any problems, thanks]) + ;; *-*-solaris*) CFLAGS="$CFLAGS -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib -L/usr/ucblib -R/usr/ucblib" @@ -178,7 +189,7 @@ if test -z "$no_libnsl" ; then fi # Checks for header files. -AC_CHECK_HEADERS(bstring.h endian.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h util.h utmp.h utmpx.h) +AC_CHECK_HEADERS(bstring.h endian.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h util.h utmp.h utmpx.h) # Checks for library functions. AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid snprintf strlcat strlcpy vsnprintf vhangup _getpty __b64_ntop) @@ -491,6 +502,34 @@ if test "x$ac_cv_have_ssize_t" = "xyes" ; then AC_DEFINE(HAVE_SSIZE_T) fi +AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [ + AC_TRY_COMPILE( + [ +#include + ], + [ pid_t foo; foo = 1235; ], + [ ac_cv_have_pid_t="yes" ], + [ ac_cv_have_pid_t="no" ] + ) +]) +if test "x$ac_cv_have_pid_t" = "xyes" ; then + AC_DEFINE(HAVE_PID_T) +fi + +AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [ + AC_TRY_COMPILE( + [ +#include + ], + [ mode_t foo; foo = 1235; ], + [ ac_cv_have_mode_t="yes" ], + [ ac_cv_have_mode_t="no" ] + ) +]) +if test "x$ac_cv_have_mode_t" = "xyes" ; then + AC_DEFINE(HAVE_MODE_T) +fi + AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [ AC_TRY_COMPILE( diff --git a/defines.h b/defines.h index 871adbf4f..974f1bad4 100644 --- a/defines.h +++ b/defines.h @@ -30,6 +30,11 @@ #ifdef HAVE_SYS_SYSMACROS_H # include /* For MIN, MAX, etc */ #endif +#ifdef HAVE_SYS_STAT_H +# include /* For S_* constants and macros */ +#endif + +#include /* For STDIN_FILENO, etc */ /* Constants */ @@ -61,6 +66,37 @@ enum # endif /* PATH_MAX */ #endif /* MAXPATHLEN */ +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +#ifndef S_ISREG +# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) +# define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) +#endif /* S_ISREG */ + +#ifndef S_IXUSR +# define S_IXUSR 0000100 /* execute/search permission, */ +# define S_IXGRP 0000010 /* execute/search permission, */ +# define S_IXOTH 0000001 /* execute/search permission, */ +# define _S_IWUSR 0000200 /* write permission, */ +# define S_IWUSR _S_IWUSR /* write permission, owner */ +# define S_IWGRP 0000020 /* write permission, group */ +# define S_IWOTH 0000002 /* write permission, other */ +# define S_IRUSR 0000400 /* read permission, owner */ +# define S_IRGRP 0000040 /* read permission, group */ +# define S_IROTH 0000004 /* read permission, other */ +# define S_IRWXU 0000700 /* read, write, execute */ +# define S_IRWXG 0000070 /* read, write, execute */ +# define S_IRWXO 0000007 /* read, write, execute */ +#endif /* S_IXUSR */ + /* Types */ /* If sys/types.h does not supply intXX_t, supply them ourselves */ @@ -151,6 +187,16 @@ typedef int ssize_t; # define HAVE_SSIZE_T #endif /* HAVE_SSIZE_T */ +#ifndef HAVE_PID_T +typedef int pid_t; +# define HAVE_PID_T +#endif /* HAVE_PID_T */ + +#ifndef HAVE_MODE_T +typedef int mode_t; +# define HAVE_MODE_T +#endif /* HAVE_MODE_T */ + #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) # define ss_family __ss_family #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ @@ -327,5 +373,4 @@ typedef int ssize_t; /** end of login recorder definitions */ - #endif /* _DEFINES_H */ diff --git a/includes.h b/includes.h index 31b7f349f..716d02f31 100644 --- a/includes.h +++ b/includes.h @@ -21,10 +21,11 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #include "config.h" +#include "next-posix.h" + #include #include #include -#include #include #include #include @@ -44,7 +45,6 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #include #include #include -#include #include #include diff --git a/next-posix.c b/next-posix.c new file mode 100644 index 000000000..247ba09a3 --- /dev/null +++ b/next-posix.c @@ -0,0 +1,148 @@ +#include "config.h" + +#ifdef HAVE_NEXT +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_STDDEF_H +#include +#endif + +#include "xmalloc.h" +#include "ssh.h" +#include "next-posix.h" + +int +waitpid(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); +} + +pid_t setsid(void) +{ + return setpgrp(0, getpid()); +} + +int +tcgetattr(int fd, struct termios *t) +{ + return (ioctl(fd, TIOCGETA, t)); +} + +int +tcsetattr(int fd, int 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)); +} + +speed_t cfgetospeed(const struct termios *t) +{ + return (t->c_ospeed); +} + +speed_t cfgetispeed(const struct termios *t) +{ + return (t->c_ispeed); +} + +int +cfsetospeed(struct termios *t,int speed) +{ + t->c_ospeed = speed; + return (0); +} + +int +cfsetispeed(struct termios *t, speed_t speed) +{ + t->c_ispeed = speed; + return (0); +} + +#if 0 + +/*define sigset_t int*/ + +/* This whole thing is insane. It's purely wrong, but it's a first + go a it. -bl */ + +int sigemptyset(sigset_t *set) +{ + return 0; +} + +int sigaddset(sigset_t *set, int signum) +{ + *set |= (1 << (signum - 1)); + return set; +} + +int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) +{ + switch(how) { + case SIG_BLOCK: + return 0; + case SIG_UNBLOCK: + return ( 0 & ~ *set); + default: + return 0; + } +} + +int sigsuspend(const sigset_t *mask) +{ +} + +int sigaction(int signum,const struct sigaction *act, struct sigaction *oldact) +{ +} + +#endif /* 0 */ + +#endif /* HAVE_NEXT */ diff --git a/next-posix.h b/next-posix.h new file mode 100644 index 000000000..2eb061ac7 --- /dev/null +++ b/next-posix.h @@ -0,0 +1,62 @@ +/* + * Defines and prototypes specific to NeXT system + */ + +#ifndef _NEXT_POSIX_H +#define _NEXT_POSIX_H + +#ifdef HAVE_NEXT + +#include +#include + +/* FILE */ +#define O_NONBLOCK 00004 /* non-blocking open */ + +/* WAITPID */ +#undef WIFEXITED +#undef WIFSTOPPED +#undef WIFSIGNALED + +#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */ +#define WIFEXITED(w) (!((_W_INT(w)) & 0377)) +#define WIFSTOPPED(w) ((_W_INT(w)) & 0100) +#define WIFSIGNALED(w) (!WIFEXITED(x) && !WIFSTOPPED(x)) +#define WEXITSTATUS(w) (int)(WIFEXITED(x) ? ((_W_INT(w) >> 8) & 0377) : -1) +#define WTERMSIG(w) (int)(WIFSIGNALED(x) ? (_W_INT(w) & 0177) : -1) +#define WCOREFLAG 0x80 +#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) + +int waitpid(int pid,int *stat_loc,int options); +#define getpgrp() getpgrp(0) +pid_t setsid(void); + +/* TC */ +int tcgetattr(int fd,struct termios *t); +int tcsetattr(int fd,int opt,const struct termios *t); +int tcsetpgrp(int fd, pid_t pgrp); +speed_t cfgetospeed(const struct termios *t); +speed_t cfgetispeed(const struct termios *t); +int cfsetospeed(struct termios *t,int speed); + +/* Sig*() */ +typedef sigset_t; +#define SIG_BLOCK 00 +#define SIG_UNBLOCK 01 +#define SIG_SETMASK 02 +#define SA_RESTART 00 +struct sigaction { + void (*sa_handler)(); + sigset_t sa_mask; + int sa_flags; +}; + +int sigemptyset(sigset_t *set); +int sigaddset(sigset_t *set, int signum); +int sigprocmask(int how, const sigset_t *set, sigset_t *oldset); +int sigsuspend(const sigset_t *mask); +int sigaction(int signum,const struct sigaction *act, struct sigaction *oldact); + +#endif /* HAVE_NEXT */ + +#endif /* _NEXT_POSIX_H */