summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-07-09 23:26:27 +1000
committerDamien Miller <djm@mindrot.org>2000-07-09 23:26:27 +1000
commit31abc9addbf23675eb094638c83c6279437b6a50 (patch)
treeac10a4aab8b155fef8dd81072a5213327496d347
parentf9b625c36e3dea521c02919e90ac2ddcfd19b06a (diff)
- (djm) More NeXT compatibility from Ben Lindstrom <mouring@pconline.com>
Including sigaction() et al. replacements
-rw-r--r--ChangeLog2
-rw-r--r--Makefile.in2
-rw-r--r--TODO7
-rw-r--r--bsd-sigaction.c102
-rw-r--r--bsd-sigaction.h102
-rw-r--r--configure.in4
-rw-r--r--loginrec.c12
-rw-r--r--next-posix.c46
-rw-r--r--next-posix.h34
-rw-r--r--openbsd-compat.h1
10 files changed, 226 insertions, 86 deletions
diff --git a/ChangeLog b/ChangeLog
index 88ae8b4ad..2c243eaa8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@
11 - (djm) Cleanup entropy collection code a little more. Split initialisation 11 - (djm) Cleanup entropy collection code a little more. Split initialisation
12 from seeding, perform intialisation immediatly at start, be careful with 12 from seeding, perform intialisation immediatly at start, be careful with
13 uids. Based on problem report from Jim Watt <jimw@peisj.pebio.com> 13 uids. Based on problem report from Jim Watt <jimw@peisj.pebio.com>
14 - (djm) More NeXT compatibility from Ben Lindstrom <mouring@pconline.com>
15 Including sigaction() et al. replacements
14 16
1520000708 1720000708
16 - (djm) Fix bad fprintf format handling in auth-pam.c. Patch from 18 - (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)
36 36
37LIBSSH_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 37LIBSSH_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
38 38
39LIBOPENBSD_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 39LIBOPENBSD_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
40 40
41SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o 41SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o
42 42
diff --git a/TODO b/TODO
index d79bd8aa9..6542e7000 100644
--- a/TODO
+++ b/TODO
@@ -9,3 +9,10 @@
9 9
10- Cleanup configure.in 10- Cleanup configure.in
11 11
12- Next now has sigaction() based on sigvec(). But it sill does not
13 seem to act correctly. Ctrl-C and Ctrl-Z don't return echo to the
14 underlying shell.
15
16- scp is broken under NeXT, and will need some TLC to be portable to
17 such an old platform. "struct dirent" does not exist, and under
18 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 @@
1/* $OpenBSD: sigaction.c,v 1.3 1999/06/27 08:14:21 millert Exp $ */
2
3/****************************************************************************
4 * Copyright (c) 1998 Free Software Foundation, Inc. *
5 * *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
13 * *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
16 * *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
28 * authorization. *
29 ****************************************************************************/
30
31/****************************************************************************
32 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
33 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
34 ****************************************************************************/
35
36#include <signal.h>
37#include "config.h"
38#include "bsd-sigaction.h"
39
40/* This file provides sigaction() emulation using sigvec() */
41/* Use only if this is non POSIX system */
42
43#if !HAVE_SIGACTION && HAVE_SIGVEC
44
45int
46sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact)
47{
48 return sigvec(sig, &(sigact->sv), &(osigact->sv));
49}
50
51int
52sigemptyset (sigset_t * mask)
53{
54 *mask = 0;
55 return 0;
56}
57
58int
59sigprocmask (int mode, sigset_t * mask, sigset_t * omask)
60{
61 sigset_t current = sigsetmask(0);
62
63 if (omask) *omask = current;
64
65 if (mode==SIG_BLOCK)
66 current |= *mask;
67 else if (mode==SIG_UNBLOCK)
68 current &= ~*mask;
69 else if (mode==SIG_SETMASK)
70 current = *mask;
71
72 sigsetmask(current);
73 return 0;
74}
75
76int
77sigsuspend (sigset_t * mask)
78{
79 return sigpause(*mask);
80}
81
82int
83sigdelset (sigset_t * mask, int sig)
84{
85 *mask &= ~sigmask(sig);
86 return 0;
87}
88
89int
90sigaddset (sigset_t * mask, int sig)
91{
92 *mask |= sigmask(sig);
93 return 0;
94}
95
96int
97sigismember (sigset_t * mask, int sig)
98{
99 return (*mask & sigmask(sig)) != 0;
100}
101
102#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 @@
1/* $OpenBSD: SigAction.h,v 1.2 1999/06/27 08:15:19 millert Exp $ */
2
3/****************************************************************************
4 * Copyright (c) 1998 Free Software Foundation, Inc. *
5 * *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
13 * *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
16 * *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
28 * authorization. *
29 ****************************************************************************/
30
31/****************************************************************************
32 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
33 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
34 ****************************************************************************/
35
36/*
37 * $From: SigAction.h,v 1.5 1999/06/19 23:00:54 tom Exp $
38 *
39 * This file exists to handle non-POSIX systems which don't have <unistd.h>,
40 * and usually no sigaction() nor <termios.h>
41 */
42
43#ifndef _SIGACTION_H
44#define _SIGACTION_H
45
46#if !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC)
47
48#undef SIG_BLOCK
49#define SIG_BLOCK 00
50
51#undef SIG_UNBLOCK
52#define SIG_UNBLOCK 01
53
54#undef SIG_SETMASK
55#define SIG_SETMASK 02
56
57/*
58 * <bsd/signal.h> is in the Linux 1.2.8 + gcc 2.7.0 configuration,
59 * and is useful for testing this header file.
60 */
61#if HAVE_BSD_SIGNAL_H
62# include <bsd/signal.h>
63#endif
64
65struct sigaction
66{
67 struct sigvec sv;
68};
69
70#define sigset_t _nc_sigset_t
71typedef unsigned long sigset_t;
72
73#undef sa_mask
74#define sa_mask sv_mask
75#undef sa_handler
76#define sa_handler sv_handler
77#undef sa_flags
78#define sa_flags sv_flags
79
80#undef sigaction
81#define sigaction _nc_sigaction
82#undef sigprocmask
83#define sigprocmask _nc_sigprocmask
84#undef sigemptyset
85#define sigemptyset _nc_sigemptyset
86#undef sigsuspend
87#define sigsuspend _nc_sigsuspend
88#undef sigdelset
89#define sigdelset _nc_sigdelset
90#undef sigaddset
91#define sigaddset _nc_sigaddset
92
93int sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact);
94int sigprocmask (int how, sigset_t *mask, sigset_t *omask);
95int sigemptyset (sigset_t *mask);
96int sigsuspend (sigset_t *mask);
97int sigdelset (sigset_t *mask, int sig);
98int sigaddset (sigset_t *mask, int sig);
99
100#endif /* !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC) */
101
102#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
108*-next-*) 108*-next-*)
109 # hardwire lastlog location (can't detect it on some versions) 109 # hardwire lastlog location (can't detect it on some versions)
110 conf_lastlog_location="/usr/adm/lastlog" 110 conf_lastlog_location="/usr/adm/lastlog"
111 conf_utmp_location=/etc/utmp
111 AC_DEFINE(HAVE_NEXT) 112 AC_DEFINE(HAVE_NEXT)
112 CFLAGS="$CFLAGS -I/usr/local/include" 113 CFLAGS="$CFLAGS -I/usr/local/include"
113 MAIL=/usr/spool/mail 114 MAIL=/usr/spool/mail
114 conf_utmp_location=/etc/utmp
115 AC_MSG_WARN([*** Tested: PA-RISC/m68k Untested: Sparc/Intel]) 115 AC_MSG_WARN([*** Tested: PA-RISC/m68k Untested: Sparc/Intel])
116 AC_MSG_WARN([*** Expect 'scp' to fail!]) 116 AC_MSG_WARN([*** Expect 'scp' to fail!])
117 AC_MSG_WARN([*** Please report any problems, thanks]) 117 AC_MSG_WARN([*** Please report any problems, thanks])
@@ -209,7 +209,7 @@ fi
209AC_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) 209AC_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)
210 210
211# Checks for library functions. 211# Checks for library functions.
212AC_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) 212AC_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)
213dnl checks for time functions 213dnl checks for time functions
214AC_CHECK_FUNCS(gettimeofday time) 214AC_CHECK_FUNCS(gettimeofday time)
215dnl checks for libutil functions 215dnl 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 @@
156 156
157#include "includes.h" 157#include "includes.h"
158 158
159#if HAVE_UTMP_H
160# include <utmp.h>
161#endif
162#if HAVE_UTMPX_H
163# include <utmpx.h>
164#endif
165#if HAVE_LASTLOG_H
166# include <lastlog.h>
167#endif
168
169#include "ssh.h" 159#include "ssh.h"
170#include "xmalloc.h" 160#include "xmalloc.h"
171#include "loginrec.h" 161#include "loginrec.h"
172 162
173RCSID("$Id: loginrec.c,v 1.15 2000/07/09 11:37:49 djm Exp $"); 163RCSID("$Id: loginrec.c,v 1.16 2000/07/09 13:26:28 djm Exp $");
174 164
175/** 165/**
176 ** prototypes for helper functions in this file 166 ** 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 @@
18#include <errno.h> 18#include <errno.h>
19#include <termios.h> 19#include <termios.h>
20#include <sys/wait.h> 20#include <sys/wait.h>
21#ifdef HAVE_STDDEF_H
22#include <stddef.h>
23#endif
24 21
25#include "xmalloc.h" 22#include "xmalloc.h"
26#include "ssh.h" 23#include "ssh.h"
@@ -99,50 +96,9 @@ cfsetospeed(struct termios *t,int speed)
99} 96}
100 97
101int 98int
102cfsetispeed(struct termios *t, speed_t speed) 99cfsetispeed(struct termios *t, int speed)
103{ 100{
104 t->c_ispeed = speed; 101 t->c_ispeed = speed;
105 return (0); 102 return (0);
106} 103}
107
108#if 0
109
110/*define sigset_t int*/
111
112/* This whole thing is insane. It's purely wrong, but it's a first
113 go a it. -bl */
114
115int sigemptyset(sigset_t *set)
116{
117 return 0;
118}
119
120int sigaddset(sigset_t *set, int signum)
121{
122 *set |= (1 << (signum - 1));
123 return set;
124}
125
126int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
127{
128 switch(how) {
129 case SIG_BLOCK:
130 return 0;
131 case SIG_UNBLOCK:
132 return ( 0 & ~ *set);
133 default:
134 return 0;
135 }
136}
137
138int sigsuspend(const sigset_t *mask)
139{
140}
141
142int sigaction(int signum,const struct sigaction *act, struct sigaction *oldact)
143{
144}
145
146#endif /* 0 */
147
148#endif /* HAVE_NEXT */ 104#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 @@
18#undef WIFSTOPPED 18#undef WIFSTOPPED
19#undef WIFSIGNALED 19#undef WIFSIGNALED
20 20
21#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */ 21#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */
22#define WIFEXITED(w) (!((_W_INT(w)) & 0377)) 22#define WIFEXITED(w) (!((_W_INT(w)) & 0377))
23#define WIFSTOPPED(w) ((_W_INT(w)) & 0100) 23#define WIFSTOPPED(w) ((_W_INT(w)) & 0100)
24#define WIFSIGNALED(w) (!WIFEXITED(x) && !WIFSTOPPED(x)) 24#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
25#define WEXITSTATUS(w) (int)(WIFEXITED(x) ? ((_W_INT(w) >> 8) & 0377) : -1) 25#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1)
26#define WTERMSIG(w) (int)(WIFSIGNALED(x) ? (_W_INT(w) & 0177) : -1) 26#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1)
27#define WCOREFLAG 0x80 27#define WCOREFLAG 0x80
28#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) 28#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG)
29 29
30int waitpid(int pid,int *stat_loc,int options); 30int waitpid(int pid,int *stat_loc,int options);
31#define getpgrp() getpgrp(0) 31#define getpgrp() getpgrp(0)
@@ -38,25 +38,5 @@ int tcsetpgrp(int fd, pid_t pgrp);
38speed_t cfgetospeed(const struct termios *t); 38speed_t cfgetospeed(const struct termios *t);
39speed_t cfgetispeed(const struct termios *t); 39speed_t cfgetispeed(const struct termios *t);
40int cfsetospeed(struct termios *t,int speed); 40int cfsetospeed(struct termios *t,int speed);
41
42/* Sig*() */
43typedef sigset_t;
44#define SIG_BLOCK 00
45#define SIG_UNBLOCK 01
46#define SIG_SETMASK 02
47#define SA_RESTART 00
48struct sigaction {
49 void (*sa_handler)();
50 sigset_t sa_mask;
51 int sa_flags;
52};
53
54int sigemptyset(sigset_t *set);
55int sigaddset(sigset_t *set, int signum);
56int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
57int sigsuspend(const sigset_t *mask);
58int sigaction(int signum,const struct sigaction *act, struct sigaction *oldact);
59
60#endif /* HAVE_NEXT */ 41#endif /* HAVE_NEXT */
61
62#endif /* _NEXT_POSIX_H */ 42#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 @@
13#include "bsd-snprintf.h" 13#include "bsd-snprintf.h"
14#include "bsd-daemon.h" 14#include "bsd-daemon.h"
15#include "bsd-base64.h" 15#include "bsd-base64.h"
16#include "bsd-sigaction.h"
16 17
17/* rfc2553 socket API replacements */ 18/* rfc2553 socket API replacements */
18#include "fake-getaddrinfo.h" 19#include "fake-getaddrinfo.h"