From 31abc9addbf23675eb094638c83c6279437b6a50 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 9 Jul 2000 23:26:27 +1000 Subject: - (djm) More NeXT compatibility from Ben Lindstrom Including sigaction() et al. replacements --- ChangeLog | 2 ++ Makefile.in | 2 +- TODO | 7 ++++ bsd-sigaction.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bsd-sigaction.h | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 4 +-- loginrec.c | 12 +------ next-posix.c | 46 +------------------------ next-posix.h | 34 ++++--------------- openbsd-compat.h | 1 + 10 files changed, 226 insertions(+), 86 deletions(-) create mode 100644 bsd-sigaction.c create mode 100644 bsd-sigaction.h diff --git a/ChangeLog b/ChangeLog index 88ae8b4ad..2c243eaa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,8 @@ - (djm) Cleanup entropy collection code a little more. Split initialisation from seeding, perform intialisation immediatly at start, be careful with uids. Based on problem report from Jim Watt + - (djm) More NeXT compatibility from Ben Lindstrom + Including sigaction() et al. replacements 20000708 - (djm) Fix bad fprintf format handling in auth-pam.c. Patch from diff --git a/Makefile.in b/Makefile.in index 50de2d973..9f1aea052 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 next-posix.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-sigaction.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/TODO b/TODO index d79bd8aa9..6542e7000 100644 --- a/TODO +++ b/TODO @@ -9,3 +9,10 @@ - Cleanup configure.in +- Next now has sigaction() based on sigvec(). But it sill does not + seem to act correctly. Ctrl-C and Ctrl-Z don't return echo to the + underlying shell. + +- scp is broken under NeXT, and will need some TLC to be portable to + such an old platform. "struct dirent" does not exist, and under + next those functions take a single integer input. diff --git a/bsd-sigaction.c b/bsd-sigaction.c new file mode 100644 index 000000000..d6966d4fd --- /dev/null +++ b/bsd-sigaction.c @@ -0,0 +1,102 @@ +/* $OpenBSD: sigaction.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */ + +/**************************************************************************** + * Copyright (c) 1998 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +#include +#include "config.h" +#include "bsd-sigaction.h" + +/* This file provides sigaction() emulation using sigvec() */ +/* Use only if this is non POSIX system */ + +#if !HAVE_SIGACTION && HAVE_SIGVEC + +int +sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) +{ + return sigvec(sig, &(sigact->sv), &(osigact->sv)); +} + +int +sigemptyset (sigset_t * mask) +{ + *mask = 0; + return 0; +} + +int +sigprocmask (int mode, sigset_t * mask, sigset_t * omask) +{ + sigset_t current = sigsetmask(0); + + if (omask) *omask = current; + + if (mode==SIG_BLOCK) + current |= *mask; + else if (mode==SIG_UNBLOCK) + current &= ~*mask; + else if (mode==SIG_SETMASK) + current = *mask; + + sigsetmask(current); + return 0; +} + +int +sigsuspend (sigset_t * mask) +{ + return sigpause(*mask); +} + +int +sigdelset (sigset_t * mask, int sig) +{ + *mask &= ~sigmask(sig); + return 0; +} + +int +sigaddset (sigset_t * mask, int sig) +{ + *mask |= sigmask(sig); + return 0; +} + +int +sigismember (sigset_t * mask, int sig) +{ + return (*mask & sigmask(sig)) != 0; +} + +#endif diff --git a/bsd-sigaction.h b/bsd-sigaction.h new file mode 100644 index 000000000..c968b0031 --- /dev/null +++ b/bsd-sigaction.h @@ -0,0 +1,102 @@ +/* $OpenBSD: SigAction.h,v 1.2 1999/06/27 08:15:19 millert Exp $ */ + +/**************************************************************************** + * Copyright (c) 1998 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ + +/**************************************************************************** + * Author: Zeyd M. Ben-Halim 1992,1995 * + * and: Eric S. Raymond * + ****************************************************************************/ + +/* + * $From: SigAction.h,v 1.5 1999/06/19 23:00:54 tom Exp $ + * + * This file exists to handle non-POSIX systems which don't have , + * and usually no sigaction() nor + */ + +#ifndef _SIGACTION_H +#define _SIGACTION_H + +#if !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC) + +#undef SIG_BLOCK +#define SIG_BLOCK 00 + +#undef SIG_UNBLOCK +#define SIG_UNBLOCK 01 + +#undef SIG_SETMASK +#define SIG_SETMASK 02 + +/* + * is in the Linux 1.2.8 + gcc 2.7.0 configuration, + * and is useful for testing this header file. + */ +#if HAVE_BSD_SIGNAL_H +# include +#endif + +struct sigaction +{ + struct sigvec sv; +}; + +#define sigset_t _nc_sigset_t +typedef unsigned long sigset_t; + +#undef sa_mask +#define sa_mask sv_mask +#undef sa_handler +#define sa_handler sv_handler +#undef sa_flags +#define sa_flags sv_flags + +#undef sigaction +#define sigaction _nc_sigaction +#undef sigprocmask +#define sigprocmask _nc_sigprocmask +#undef sigemptyset +#define sigemptyset _nc_sigemptyset +#undef sigsuspend +#define sigsuspend _nc_sigsuspend +#undef sigdelset +#define sigdelset _nc_sigdelset +#undef sigaddset +#define sigaddset _nc_sigaddset + +int sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact); +int sigprocmask (int how, sigset_t *mask, sigset_t *omask); +int sigemptyset (sigset_t *mask); +int sigsuspend (sigset_t *mask); +int sigdelset (sigset_t *mask, int sig); +int sigaddset (sigset_t *mask, int sig); + +#endif /* !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC) */ + +#endif /* !defined(_SIGACTION_H) */ diff --git a/configure.in b/configure.in index 4d0f6ea43..f496e3934 100644 --- a/configure.in +++ b/configure.in @@ -108,10 +108,10 @@ case "$host" in *-next-*) # hardwire lastlog location (can't detect it on some versions) conf_lastlog_location="/usr/adm/lastlog" + conf_utmp_location=/etc/utmp 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]) @@ -209,7 +209,7 @@ fi 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) +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 sigaction sigvec snprintf strlcat strlcpy vsnprintf vhangup _getpty __b64_ntop) dnl checks for time functions AC_CHECK_FUNCS(gettimeofday time) dnl checks for libutil functions diff --git a/loginrec.c b/loginrec.c index 1bf5eeb46..c4e6c4aa9 100644 --- a/loginrec.c +++ b/loginrec.c @@ -156,21 +156,11 @@ #include "includes.h" -#if HAVE_UTMP_H -# include -#endif -#if HAVE_UTMPX_H -# include -#endif -#if HAVE_LASTLOG_H -# include -#endif - #include "ssh.h" #include "xmalloc.h" #include "loginrec.h" -RCSID("$Id: loginrec.c,v 1.15 2000/07/09 11:37:49 djm Exp $"); +RCSID("$Id: loginrec.c,v 1.16 2000/07/09 13:26:28 djm Exp $"); /** ** prototypes for helper functions in this file diff --git a/next-posix.c b/next-posix.c index 247ba09a3..0ca241fdd 100644 --- a/next-posix.c +++ b/next-posix.c @@ -18,9 +18,6 @@ #include #include #include -#ifdef HAVE_STDDEF_H -#include -#endif #include "xmalloc.h" #include "ssh.h" @@ -99,50 +96,9 @@ cfsetospeed(struct termios *t,int speed) } int -cfsetispeed(struct termios *t, speed_t speed) +cfsetispeed(struct termios *t, int 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 index 2eb061ac7..511e04434 100644 --- a/next-posix.h +++ b/next-posix.h @@ -18,14 +18,14 @@ #undef WIFSTOPPED #undef WIFSIGNALED -#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */ -#define WIFEXITED(w) (!((_W_INT(w)) & 0377)) +#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) +#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w)) +#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1) +#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_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) @@ -38,25 +38,5 @@ 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 */ diff --git a/openbsd-compat.h b/openbsd-compat.h index bef9c852d..8fd85bc9d 100644 --- a/openbsd-compat.h +++ b/openbsd-compat.h @@ -13,6 +13,7 @@ #include "bsd-snprintf.h" #include "bsd-daemon.h" #include "bsd-base64.h" +#include "bsd-sigaction.h" /* rfc2553 socket API replacements */ #include "fake-getaddrinfo.h" -- cgit v1.2.3