summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2000-11-05 09:08:45 +0000
committerBen Lindstrom <mouring@eviladmin.org>2000-11-05 09:08:45 +0000
commit67e21e1eb2366f4598f8ee483dfbacc92010a687 (patch)
tree7d62334093443926fdef24bcc4ceb9a84a9eb7d6
parentfd496053df95abd3046a46729b1a12ae540b07ad (diff)
- (bal) Reworked NEWS-OS and NeXT ports to extract waitpid() and
setsid() into more common files
-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 d902bd62..0e5113cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,9 @@
[deattack.c]
so that large packets do not wrap "n"; from netbsd
- (bal) rijndel.c - fix up RCSID to match OpenBSD tree
- - (bal) auth2-skey.c - Checked in. Missing from portable tree
+ - (bal) auth2-skey.c - Checked in. Missing from portable tree.
+ - (bal) Reworked NEWS-OS and NeXT ports to extract waitpid() and
+ setsid() into more common files
20001029
- (stevesk) Fix typo in auth.c: USE_PAM not PAM
diff --git a/Makefile.in b/Makefile.in
index c5535263..c03b46cb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -37,7 +37,7 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-add$(EXEEXT) ssh-keygen$(EXEEXT) ssh-agen
LIBSSH_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
-LIBOPENBSD_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
+LIBOPENBSD_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
SSHOBJS= ssh.o sshconnect.o sshconnect1.o sshconnect2.o log-client.o readconf.o clientloop.o
diff --git a/bsd-misc.h b/bsd-misc.h
index 0546ef1f..ae2b3fff 100644
--- a/bsd-misc.h
+++ b/bsd-misc.h
@@ -27,6 +27,11 @@
#include "config.h"
+#ifndef HAVE_SETSID
+#define setsid() setpgrp(0, getpid())
+#endif /* !HAVE_SETSID */
+
+
#ifndef HAVE_SETENV
int setenv(const char *name, const char *value, int overwrite);
#endif /* !HAVE_SETENV */
diff --git a/bsd-waitpid.c b/bsd-waitpid.c
new file mode 100644
index 00000000..fb17063a
--- /dev/null
+++ b/bsd-waitpid.c
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include "includes.h"
+
+#ifndef HAVE_WAITPID
+#include <errno.h>
+#include <sys/wait.h>
+#include <bsd-waitpid.h>
+
+pid_t
+waitpid(int pid, int *stat_loc, int options)
+{
+ union wait statusp;
+ pid_t wait_pid;
+
+ if (pid <= 0) {
+ if (pid != -1) {
+ errno = EINVAL;
+ return -1;
+ }
+ pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */
+ }
+ wait_pid = wait4(pid, &statusp, options, NULL);
+ stat_loc = (int *)statusp.w_status;
+ return wait_pid;
+}
+
+#endif /* !HAVE_WAITPID */
diff --git a/bsd-waitpid.h b/bsd-waitpid.h
new file mode 100644
index 00000000..25c6e9c8
--- /dev/null
+++ b/bsd-waitpid.h
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ */
+
+#ifndef _BSD_WAITPID_H
+#define _BSD_WAITPID_H
+
+#ifndef HAVE_WAITPID
+/* Clean out any potental issues */
+#undef WIFEXITED
+#undef WIFSTOPPED
+#undef WIFSIGNALED
+
+/* Define required functions to mimic a POSIX look and feel */
+#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(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)
+
+/* Prototype */
+pid_t waitpid(int pid, int *stat_loc, int options);
+
+#endif /* !HAVE_WAITPID */
+#endif /* _BSD_WAITPID_H */
diff --git a/configure.in b/configure.in
index 6f27c3b9..888cd91c 100644
--- a/configure.in
+++ b/configure.in
@@ -287,7 +287,7 @@ fi
AC_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)
dnl Checks for library functions.
-AC_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)
+AC_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)
dnl Checks for time functions
AC_CHECK_FUNCS(gettimeofday time)
dnl Checks for libutil functions
diff --git a/news4-posix.c b/news4-posix.c
deleted file mode 100644
index b1a289f7..00000000
--- a/news4-posix.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "config.h"
-
-#ifdef HAVE_NEWS4
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include <errno.h>
-#include <termios.h>
-#include <sys/wait.h>
-
-#include "xmalloc.h"
-#include "ssh.h"
-#include "news4-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);
-}
-
-#endif /* HAVE_NEWS4 */
diff --git a/news4-posix.h b/news4-posix.h
index 87406793..af1cac3f 100644
--- a/news4-posix.h
+++ b/news4-posix.h
@@ -6,7 +6,6 @@
#define _NEWS4_POSIX_H
#ifdef HAVE_NEWS4
-
#include <sys/wait.h>
typedef long clock_t;
@@ -14,22 +13,5 @@ typedef long clock_t;
/* 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(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 setsid() setpgrp(0, getpid())
-
#endif /* HAVE_NEWS4 */
#endif /* _NEWS4_POSIX_H */
diff --git a/next-posix.c b/next-posix.c
index d5cc733d..43ec0acd 100644
--- a/next-posix.c
+++ b/next-posix.c
@@ -40,24 +40,6 @@ posix_wait(int *status)
return wait_pid;
}
-pid_t
-waitpid(int pid, int *stat_loc, int options)
-{
- union wait statusp;
- pid_t wait_pid;
-
- if (pid <= 0) {
- if (pid != -1) {
- errno = EINVAL;
- return -1;
- }
- pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */
- }
- wait_pid = wait4(pid, &statusp, options, NULL);
- stat_loc = (int *)statusp.w_status;
- return wait_pid;
-}
-
int
tcgetattr(int fd, struct termios *t)
{
diff --git a/next-posix.h b/next-posix.h
index 96733230..b987b09c 100644
--- a/next-posix.h
+++ b/next-posix.h
@@ -25,7 +25,6 @@
#define _NEXT_POSIX_H
#ifdef HAVE_NEXT
-
#include <sys/dir.h>
/* NeXT's readdir() is BSD (struct direct) not POSIX (struct dirent) */
@@ -34,28 +33,10 @@
/* 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(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)
-
/* Swap out NeXT's BSD wait() for a more POSIX complient one */
pid_t posix_wait(int *status);
#define wait(a) posix_wait(a)
-/* MISC functions */
-#define setsid() setpgrp(0, getpid())
-pid_t waitpid(int pid, int *stat_loc, int options);
-
/* TERMCAP */
int tcgetattr(int fd, struct termios *t);
int tcsetattr(int fd, int opt, const struct termios *t);
diff --git a/openbsd-compat.h b/openbsd-compat.h
index 0d5e7427..1be0ccd4 100644
--- a/openbsd-compat.h
+++ b/openbsd-compat.h
@@ -22,6 +22,7 @@
#include "bsd-strsep.h"
#include "bsd-strtok.h"
#include "bsd-vis.h"
+#include "bsd-waitpid.h"
#include "bsd-setproctitle.h"
/* rfc2553 socket API replacements */