aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-11-17 20:35:48 +0100
committerGilles Chehade <gilles@poolp.org>2019-11-17 20:35:48 +0100
commit4ccbc5c256c361ea188438877591ec608f80fbbe (patch)
treef95c386b532dab21c35de71e9a158e1dd375051d
parentfix strnvis test (diff)
downloadOpenSMTPD-4ccbc5c256c361ea188438877591ec608f80fbbe.tar.xz
OpenSMTPD-4ccbc5c256c361ea188438877591ec608f80fbbe.zip
conditionally build signal.c
-rw-r--r--configure.ac3
-rw-r--r--openbsd-compat/Makefile.am4
-rw-r--r--openbsd-compat/bsd-misc.c27
-rw-r--r--openbsd-compat/bsd-misc.h14
-rw-r--r--openbsd-compat/openbsd-compat.h8
-rw-r--r--openbsd-compat/signal.c60
6 files changed, 74 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac
index f2e6908d..54074d9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -537,7 +537,6 @@ AC_CHECK_FUNCS([ \
chflags \
crypt_checkpass \
dirfd \
- endgrent \
err \
errc \
errx \
@@ -574,6 +573,7 @@ AC_CHECK_FUNCS([ \
setresuid \
setresgid \
setsid \
+ signal \
sigaction \
snprintf \
socketpair \
@@ -2035,6 +2035,7 @@ AM_CONDITIONAL([NEED_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" != "xyes
AM_CONDITIONAL([NEED_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" != "xyes"])
AM_CONDITIONAL([NEED_SETRESGID], [test "x$ac_cv_func_setresgid" != "xyes"])
AM_CONDITIONAL([NEED_SETRESUID], [test "x$ac_cv_func_setresuid" != "xyes"])
+AM_CONDITIONAL([NEED_SIGNAL], [test "x$ac_cv_func_signal" != "xyes"])
AM_CONDITIONAL([NEED_STRLCAT], [test "x$ac_cv_func_strlcat" != "xyes"])
AM_CONDITIONAL([NEED_STRLCPY], [test "x$ac_cv_func_strlcpy" != "xyes"])
AM_CONDITIONAL([NEED_STRMODE], [test "x$ac_cv_func_strmode" != "xyes"])
diff --git a/openbsd-compat/Makefile.am b/openbsd-compat/Makefile.am
index 8b9b4872..e872e3dd 100644
--- a/openbsd-compat/Makefile.am
+++ b/openbsd-compat/Makefile.am
@@ -86,6 +86,10 @@ if NEED_INET_NET_PTON
libopenbsd_compat_a_SOURCES += inet_net_pton.c
endif
+if NEED_SIGNAL
+libopenbsd_compat_a_SOURCES += signal.c
+endif
+
if NEED_PIDFILE
libopenbsd_compat_a_SOURCES += pidfile.c
endif
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 0a2e33ea..5a7a5a5c 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -133,30 +133,3 @@ int usleep(unsigned int useconds)
return nanosleep(&ts, NULL);
}
#endif
-
-mysig_t
-mysignal(int sig, mysig_t act)
-{
-#ifdef HAVE_SIGACTION
- struct sigaction sa, osa;
-
- if (sigaction(sig, NULL, &osa) == -1)
- return (mysig_t) -1;
- if (osa.sa_handler != act) {
- memset(&sa, 0, sizeof(sa));
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-#ifdef SA_INTERRUPT
- if (sig == SIGALRM)
- sa.sa_flags |= SA_INTERRUPT;
-#endif
- sa.sa_handler = act;
- if (sigaction(sig, &sa, NULL) == -1)
- return (mysig_t) -1;
- }
- return (osa.sa_handler);
-#else
- #undef signal
- return (signal(sig, act));
-#endif
-}
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index c040a2b3..82b93450 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -27,10 +27,6 @@ char *ssh_get_progname(char *);
#define setsid() setpgrp(0, getpid())
#endif /* !HAVE_SETSID */
-#ifndef HAVE_SETENV
-int setenv(const char *, const char *, int);
-#endif /* !HAVE_SETENV */
-
#if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID)
int seteuid(uid_t);
#endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */
@@ -64,14 +60,4 @@ int nanosleep(const struct timespec *, struct timespec *);
int usleep(unsigned int useconds);
#endif
-/* wrapper for signal interface */
-typedef void (*mysig_t)(int);
-mysig_t mysignal(int sig, mysig_t act);
-
-#define signal(a,b) mysignal(a,b)
-
-#ifndef HAVE_ENDGRENT
-# define endgrent() {}
-#endif
-
#endif /* _BSD_MISC_H */
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 65deb5ca..82b2bc75 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -289,4 +289,12 @@ char * strndup(const char *, size_t);
char * strnlen(const char *, size_t);
#endif
+
+#ifdef NEED_SIGNAL
+typedef void (*mysig_t)(int);
+mysig_t mysignal(int sig, mysig_t act);
+#define signal(a,b) mysignal(a,b)
+#endif
+
+
#endif /* _OPENBSD_COMPAT_H */
diff --git a/openbsd-compat/signal.c b/openbsd-compat/signal.c
new file mode 100644
index 00000000..cdae0cd2
--- /dev/null
+++ b/openbsd-compat/signal.c
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright (c) 1999-2004 Damien Miller <djm@mindrot.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "includes.h"
+
+#include <sys/types.h>
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
+#include <err.h>
+#include <string.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+mysig_t
+mysignal(int sig, mysig_t act)
+{
+#ifdef HAVE_SIGACTION
+ struct sigaction sa, osa;
+
+ if (sigaction(sig, NULL, &osa) == -1)
+ return (mysig_t) -1;
+ if (osa.sa_handler != act) {
+ memset(&sa, 0, sizeof(sa));
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+#ifdef SA_INTERRUPT
+ if (sig == SIGALRM)
+ sa.sa_flags |= SA_INTERRUPT;
+#endif
+ sa.sa_handler = act;
+ if (sigaction(sig, &sa, NULL) == -1)
+ return (mysig_t) -1;
+ }
+ return (osa.sa_handler);
+#else
+ #undef signal
+ return (signal(sig, act));
+#endif
+}