aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-11-17 20:39:06 +0100
committerGilles Chehade <gilles@poolp.org>2019-11-17 20:39:06 +0100
commitb9dd09dd5abdbf167519790dc2d90248441fd154 (patch)
tree4f8487c514f7e1a73cc96ae1c82ef143285072e8
parentconditionally build signal.c (diff)
downloadOpenSMTPD-b9dd09dd5abdbf167519790dc2d90248441fd154.tar.xz
OpenSMTPD-b9dd09dd5abdbf167519790dc2d90248441fd154.zip
conditionally build strerror
-rw-r--r--configure.ac1
-rw-r--r--openbsd-compat/Makefile.am4
-rw-r--r--openbsd-compat/bsd-misc.c13
-rw-r--r--openbsd-compat/bsd-misc.h4
-rw-r--r--openbsd-compat/openbsd-compat.h4
-rw-r--r--openbsd-compat/strerror.c44
6 files changed, 53 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 54074d9b..4cfd5cd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2036,6 +2036,7 @@ 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_STRERROR], [test "x$ac_cv_func_strerror" != "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 e872e3dd..ca21423b 100644
--- a/openbsd-compat/Makefile.am
+++ b/openbsd-compat/Makefile.am
@@ -118,6 +118,10 @@ if NEED_SSL_CTX_USE_CERTIFICATE_CHAIN_MEM
libopenbsd_compat_a_SOURCES += SSL_CTX_use_certificate_chain_mem.c
endif
+if NEED_STRERROR
+libopenbsd_compat_a_SOURCES += strerror.c
+endif
+
if NEED_STRLCAT
libopenbsd_compat_a_SOURCES += strlcat.c
endif
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 5a7a5a5c..5cf1c0e8 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -79,19 +79,6 @@ int setegid(uid_t egid)
}
#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
-#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
-const char *strerror(int e)
-{
- extern int sys_nerr;
- extern char *sys_errlist[];
-
- if ((e >= 0) && (e < sys_nerr))
- return (sys_errlist[e]);
-
- return ("unlisted error");
-}
-#endif
-
#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
int nanosleep(const struct timespec *req, struct timespec *rem)
{
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 82b93450..bfcb2763 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -35,10 +35,6 @@ int seteuid(uid_t);
int setegid(uid_t);
#endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */
-#if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR)
-const char *strerror(int);
-#endif
-
#ifndef HAVE_STRUCT_TIMEVAL
struct timeval {
long tv_sec;
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
index 82b2bc75..ab23a933 100644
--- a/openbsd-compat/openbsd-compat.h
+++ b/openbsd-compat/openbsd-compat.h
@@ -296,5 +296,9 @@ mysig_t mysignal(int sig, mysig_t act);
#define signal(a,b) mysignal(a,b)
#endif
+#ifdef NEED_STRERROR
+const char *strerror(int);
+#endif
+
#endif /* _OPENBSD_COMPAT_H */
diff --git a/openbsd-compat/strerror.c b/openbsd-compat/strerror.c
new file mode 100644
index 00000000..0ddad2d4
--- /dev/null
+++ b/openbsd-compat/strerror.c
@@ -0,0 +1,44 @@
+
+/*
+ * 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>
+
+const char *strerror(int e)
+{
+ extern int sys_nerr;
+ extern char *sys_errlist[];
+
+ if ((e >= 0) && (e < sys_nerr))
+ return (sys_errlist[e]);
+
+ return ("unlisted error");
+}