summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Makefile.in2
-rw-r--r--bsd-misc.h5
-rw-r--r--bsd-waitpid.c48
-rw-r--r--bsd-waitpid.h47
-rw-r--r--configure.in2
-rw-r--r--news4-posix.c39
-rw-r--r--news4-posix.h18
-rw-r--r--next-posix.c18
-rw-r--r--next-posix.h19
-rw-r--r--openbsd-compat.h1
11 files changed, 106 insertions, 97 deletions
diff --git a/ChangeLog b/ChangeLog
index d902bd62f..0e5113cd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,9 @@
7 [deattack.c] 7 [deattack.c]
8 so that large packets do not wrap "n"; from netbsd 8 so that large packets do not wrap "n"; from netbsd
9 - (bal) rijndel.c - fix up RCSID to match OpenBSD tree 9 - (bal) rijndel.c - fix up RCSID to match OpenBSD tree
10 - (bal) auth2-skey.c - Checked in. Missing from portable tree 10 - (bal) auth2-skey.c - Checked in. Missing from portable tree.
11 - (bal) Reworked NEWS-OS and NeXT ports to extract waitpid() and
12 setsid() into more common files
11 13
1220001029 1420001029
13 - (stevesk) Fix typo in auth.c: USE_PAM not PAM 15 - (stevesk) Fix typo in auth.c: USE_PAM not PAM
diff --git a/Makefile.in b/Makefile.in
index c55352635..c03b46cb8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -37,7 +37,7 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-agen
37 37
38LIBSSH_OBJS=atomicio.o authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o cli.o compat.o compress.o crc32.o cygwin_util.o deattack.o dispatch.o dsa.o hmac.o hostfile.o key.o kex.o log.o match.o mpaux.o nchan.o packet.o radix.o rijndael.o entropy.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o util.o uuencode.o xmalloc.o 38LIBSSH_OBJS=atomicio.o authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o cli.o compat.o compress.o crc32.o cygwin_util.o deattack.o dispatch.o dsa.o hmac.o hostfile.o key.o kex.o log.o match.o mpaux.o nchan.o packet.o radix.o rijndael.o entropy.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o util.o uuencode.o xmalloc.o
39 39
40LIBOPENBSD_COMPAT_OBJS=bsd-arc4random.o bsd-base64.o bsd-bindresvport.o bsd-daemon.o bsd-getcwd.o bsd-inet_aton.o bsd-inet_ntoa.o bsd-misc.o bsd-mktemp.o bsd-realpath.o bsd-rresvport.o bsd-setenv.o bsd-sigaction.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bsd-strsep.o bsd-strtok.o bsd-vis.o bsd-setproctitle.o fake-getaddrinfo.o fake-getnameinfo.o next-posix.o 40LIBOPENBSD_COMPAT_OBJS=bsd-arc4random.o bsd-base64.o bsd-bindresvport.o bsd-daemon.o bsd-getcwd.o bsd-inet_aton.o bsd-inet_ntoa.o bsd-misc.o bsd-mktemp.o bsd-realpath.o bsd-rresvport.o bsd-setenv.o bsd-sigaction.o bsd-snprintf.o bsd-strlcat.o bsd-strlcpy.o bsd-strsep.o bsd-strtok.o bsd-vis.o bsd-setproctitle.o bsd-waitpid.o fake-getaddrinfo.o fake-getnameinfo.o next-posix.o
41 41
42SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o 42SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o
43 43
diff --git a/bsd-misc.h b/bsd-misc.h
index 0546ef1fe..ae2b3ffff 100644
--- a/bsd-misc.h
+++ b/bsd-misc.h
@@ -27,6 +27,11 @@
27 27
28#include "config.h" 28#include "config.h"
29 29
30#ifndef HAVE_SETSID
31#define setsid() setpgrp(0, getpid())
32#endif /* !HAVE_SETSID */
33
34
30#ifndef HAVE_SETENV 35#ifndef HAVE_SETENV
31int setenv(const char *name, const char *value, int overwrite); 36int setenv(const char *name, const char *value, int overwrite);
32#endif /* !HAVE_SETENV */ 37#endif /* !HAVE_SETENV */
diff --git a/bsd-waitpid.c b/bsd-waitpid.c
new file mode 100644
index 000000000..fb17063a5
--- /dev/null
+++ b/bsd-waitpid.c
@@ -0,0 +1,48 @@
1/*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions
4 * are met:
5 * 1. Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * 2. Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 *
11 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
13 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
17 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
18 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 */
22
23#include "includes.h"
24
25#ifndef HAVE_WAITPID
26#include <errno.h>
27#include <sys/wait.h>
28#include <bsd-waitpid.h>
29
30pid_t
31waitpid(int pid, int *stat_loc, int options)
32{
33 union wait statusp;
34 pid_t wait_pid;
35
36 if (pid <= 0) {
37 if (pid != -1) {
38 errno = EINVAL;
39 return -1;
40 }
41 pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */
42 }
43 wait_pid = wait4(pid, &statusp, options, NULL);
44 stat_loc = (int *)statusp.w_status;
45 return wait_pid;
46}
47
48#endif /* !HAVE_WAITPID */
diff --git a/bsd-waitpid.h b/bsd-waitpid.h
new file mode 100644
index 000000000..25c6e9c86
--- /dev/null
+++ b/bsd-waitpid.h
@@ -0,0 +1,47 @@
1/*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that the following conditions
4 * are met:
5 * 1. Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * 2. Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 *
11 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
12 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
13 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
14 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
17 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
18 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 */
23
24#ifndef _BSD_WAITPID_H
25#define _BSD_WAITPID_H
26
27#ifndef HAVE_WAITPID
28/* Clean out any potental issues */
29#undef WIFEXITED
30#undef WIFSTOPPED
31#undef WIFSIGNALED
32
33/* Define required functions to mimic a POSIX look and feel */
34#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */
35#define WIFEXITED(w) (!((_W_INT(w)) & 0377))
36#define WIFSTOPPED(w) ((_W_INT(w)) & 0100)
37#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
38#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1)
39#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1)
40#define WCOREFLAG 0x80
41#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG)
42
43/* Prototype */
44pid_t waitpid(int pid, int *stat_loc, int options);
45
46#endif /* !HAVE_WAITPID */
47#endif /* _BSD_WAITPID_H */
diff --git a/configure.in b/configure.in
index 6f27c3b99..888cd91ce 100644
--- a/configure.in
+++ b/configure.in
@@ -287,7 +287,7 @@ fi
287AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.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 sys/un.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h vis.h) 287AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.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 sys/un.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h vis.h)
288 288
289dnl Checks for library functions. 289dnl Checks for library functions.
290AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getnameinfo getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setenv seteuid setlogin setproctitle setreuid setrlimit sigaction sigvec snprintf strerror strlcat strlcpy strsep strtok_r vsnprintf vhangup vis _getpty __b64_ntop) 290AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getnameinfo getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setenv seteuid setlogin setproctitle setreuid setrlimit setsid sigaction sigvec snprintf strerror strlcat strlcpy strsep strtok_r vsnprintf vhangup vis waitpid _getpty __b64_ntop)
291dnl Checks for time functions 291dnl Checks for time functions
292AC_CHECK_FUNCS(gettimeofday time) 292AC_CHECK_FUNCS(gettimeofday time)
293dnl Checks for libutil functions 293dnl Checks for libutil functions
diff --git a/news4-posix.c b/news4-posix.c
deleted file mode 100644
index b1a289f7a..000000000
--- a/news4-posix.c
+++ /dev/null
@@ -1,39 +0,0 @@
1#include "config.h"
2
3#ifdef HAVE_NEWS4
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <errno.h>
8#include <unistd.h>
9
10#include <sys/types.h>
11#include <sys/stat.h>
12#include <fcntl.h>
13
14#include <sys/fcntl.h>
15#include <sys/ioctl.h>
16#include <sys/time.h>
17#include <sys/file.h>
18#include <errno.h>
19#include <termios.h>
20#include <sys/wait.h>
21
22#include "xmalloc.h"
23#include "ssh.h"
24#include "news4-posix.h"
25
26int
27waitpid(int pid, int *stat_loc, int options)
28{
29 if (pid <= 0) {
30 if (pid != -1) {
31 errno = EINVAL;
32 return -1;
33 }
34 pid = 0; /* wait4() expects pid=0 for indiscriminate wait. */
35 }
36 return wait4(pid, (union wait *)stat_loc, options, NULL);
37}
38
39#endif /* HAVE_NEWS4 */
diff --git a/news4-posix.h b/news4-posix.h
index 874067934..af1cac3f6 100644
--- a/news4-posix.h
+++ b/news4-posix.h
@@ -6,7 +6,6 @@
6#define _NEWS4_POSIX_H 6#define _NEWS4_POSIX_H
7 7
8#ifdef HAVE_NEWS4 8#ifdef HAVE_NEWS4
9
10#include <sys/wait.h> 9#include <sys/wait.h>
11 10
12typedef long clock_t; 11typedef long clock_t;
@@ -14,22 +13,5 @@ typedef long clock_t;
14/* FILE */ 13/* FILE */
15#define O_NONBLOCK 00004 /* non-blocking open */ 14#define O_NONBLOCK 00004 /* non-blocking open */
16 15
17/* WAITPID */
18#undef WIFEXITED
19#undef WIFSTOPPED
20#undef WIFSIGNALED
21
22#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */
23#define WIFEXITED(w) (!((_W_INT(w)) & 0377))
24#define WIFSTOPPED(w) ((_W_INT(w)) & 0100)
25#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
26#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1)
27#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1)
28#define WCOREFLAG 0x80
29#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG)
30
31int waitpid(int pid,int *stat_loc,int options);
32#define setsid() setpgrp(0, getpid())
33
34#endif /* HAVE_NEWS4 */ 16#endif /* HAVE_NEWS4 */
35#endif /* _NEWS4_POSIX_H */ 17#endif /* _NEWS4_POSIX_H */
diff --git a/next-posix.c b/next-posix.c
index d5cc733d0..43ec0acd9 100644
--- a/next-posix.c
+++ b/next-posix.c
@@ -40,24 +40,6 @@ posix_wait(int *status)
40 return wait_pid; 40 return wait_pid;
41} 41}
42 42
43pid_t
44waitpid(int pid, int *stat_loc, int options)
45{
46 union wait statusp;
47 pid_t wait_pid;
48
49 if (pid <= 0) {
50 if (pid != -1) {
51 errno = EINVAL;
52 return -1;
53 }
54 pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */
55 }
56 wait_pid = wait4(pid, &statusp, options, NULL);
57 stat_loc = (int *)statusp.w_status;
58 return wait_pid;
59}
60
61int 43int
62tcgetattr(int fd, struct termios *t) 44tcgetattr(int fd, struct termios *t)
63{ 45{
diff --git a/next-posix.h b/next-posix.h
index 967332308..b987b09c2 100644
--- a/next-posix.h
+++ b/next-posix.h
@@ -25,7 +25,6 @@
25#define _NEXT_POSIX_H 25#define _NEXT_POSIX_H
26 26
27#ifdef HAVE_NEXT 27#ifdef HAVE_NEXT
28
29#include <sys/dir.h> 28#include <sys/dir.h>
30 29
31/* NeXT's readdir() is BSD (struct direct) not POSIX (struct dirent) */ 30/* NeXT's readdir() is BSD (struct direct) not POSIX (struct dirent) */
@@ -34,28 +33,10 @@
34/* FILE */ 33/* FILE */
35#define O_NONBLOCK 00004 /* non-blocking open */ 34#define O_NONBLOCK 00004 /* non-blocking open */
36 35
37/* WAITPID */
38#undef WIFEXITED
39#undef WIFSTOPPED
40#undef WIFSIGNALED
41
42#define _W_INT(w) (*(int*)&(w)) /* convert union wait to int */
43#define WIFEXITED(w) (!((_W_INT(w)) & 0377))
44#define WIFSTOPPED(w) ((_W_INT(w)) & 0100)
45#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
46#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((_W_INT(w) >> 8) & 0377) : -1)
47#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (_W_INT(w) & 0177) : -1)
48#define WCOREFLAG 0x80
49#define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG)
50
51/* Swap out NeXT's BSD wait() for a more POSIX complient one */ 36/* Swap out NeXT's BSD wait() for a more POSIX complient one */
52pid_t posix_wait(int *status); 37pid_t posix_wait(int *status);
53#define wait(a) posix_wait(a) 38#define wait(a) posix_wait(a)
54 39
55/* MISC functions */
56#define setsid() setpgrp(0, getpid())
57pid_t waitpid(int pid, int *stat_loc, int options);
58
59/* TERMCAP */ 40/* TERMCAP */
60int tcgetattr(int fd, struct termios *t); 41int tcgetattr(int fd, struct termios *t);
61int tcsetattr(int fd, int opt, const struct termios *t); 42int tcsetattr(int fd, int opt, const struct termios *t);
diff --git a/openbsd-compat.h b/openbsd-compat.h
index 0d5e7427a..1be0ccd40 100644
--- a/openbsd-compat.h
+++ b/openbsd-compat.h
@@ -22,6 +22,7 @@
22#include "bsd-strsep.h" 22#include "bsd-strsep.h"
23#include "bsd-strtok.h" 23#include "bsd-strtok.h"
24#include "bsd-vis.h" 24#include "bsd-vis.h"
25#include "bsd-waitpid.h"
25#include "bsd-setproctitle.h" 26#include "bsd-setproctitle.h"
26 27
27/* rfc2553 socket API replacements */ 28/* rfc2553 socket API replacements */