]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Move err.h replacements into compat lib.
authorDarren Tucker <dtucker@zip.com.au>
Wed, 13 Jul 2016 04:42:35 +0000 (14:42 +1000)
committerDarren Tucker <dtucker@zip.com.au>
Wed, 13 Jul 2016 04:42:35 +0000 (14:42 +1000)
Move implementations of err.h replacement functions into their own file
in the libopenbsd-compat so we can use them in kexfuzz.c too.  ok djm@

configure.ac
openbsd-compat/Makefile.in
openbsd-compat/bsd-err.c [new file with mode: 0644]
openbsd-compat/bsd-misc.h
regress/misc/kexfuzz/kexfuzz.c
regress/netcat.c

index 2bb5a63c8f518c2e39e25ff3ec7673e4d327572a..005a9ead58b70da176c3e4c41da6c571396172e4 100644 (file)
@@ -373,6 +373,7 @@ AC_CHECK_HEADERS([ \
        dirent.h \
        endian.h \
        elf.h \
+       err.h \
        features.h \
        fcntl.h \
        floatingpoint.h \
@@ -1692,6 +1693,8 @@ AC_CHECK_FUNCS([ \
        closefrom \
        dirfd \
        endgrent \
+       err \
+       errx \
        explicit_bzero \
        fchmod \
        fchown \
@@ -1783,6 +1786,7 @@ AC_CHECK_FUNCS([ \
        vasprintf \
        vsnprintf \
        waitpid \
+       warn \
 ])
 
 AC_LINK_IFELSE(
index 3c5e3b7f7da8e90d3ec289d6ada3defe6da540b9..aca9eba7591c8b4f25fa768a529a5cf3f54a1384 100644 (file)
@@ -18,7 +18,7 @@ LDFLAGS=-L. @LDFLAGS@
 
 OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o reallocarray.o realpath.o rresvport.o setenv.o setproctitle.o sha1.o sha2.o rmd160.o md5.o sigact.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o blowfish.o bcrypt_pbkdf.o explicit_bzero.o
 
-COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o kludge-fd_set.o
+COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cray.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-setres_id.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xmmap.o xcrypt.o kludge-fd_set.o
 
 PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o
 
diff --git a/openbsd-compat/bsd-err.c b/openbsd-compat/bsd-err.c
new file mode 100644 (file)
index 0000000..ab10646
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 Tim Rice <tim@multitalents.net>
+ *
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * 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_ERR
+void
+err(int r, const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       fprintf(stderr, "%s: ", strerror(errno));
+       vfprintf(stderr, fmt, args);
+       fputc('\n', stderr);
+       va_end(args);
+       exit(r);
+}
+#endif
+
+#ifndef HAVE_ERRX
+void
+errx(int r, const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       vfprintf(stderr, fmt, args);
+       fputc('\n', stderr);
+       va_end(args);
+       exit(r);
+}
+#endif
+
+#ifndef HAVE_WARN
+void
+warn(const char *fmt, ...)
+{
+       va_list args;
+
+       va_start(args, fmt);
+       fprintf(stderr, "%s: ", strerror(errno));
+       vfprintf(stderr, fmt, args);
+       fputc('\n', stderr);
+       va_end(args);
+}
+#endif
index 0d81d17352eae6812da12a21529ef3ae0effeae2..27abb2e92b62d57a6b4bd647490b3d3de85dc2f4 100644 (file)
@@ -126,4 +126,15 @@ pid_t getpgid(pid_t);
 int pledge(const char *promises, const char *paths[]);
 #endif
 
+/* bsd-err.h */
+#ifndef HAVE_ERR
+void err(int, const char *, ...) __attribute__((format(printf, 2, 3)));
+#endif
+#ifndef HAVE_ERRX
+void errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
+#endif
+#ifndef HAVE_WARN
+void warn(const char *, ...) __attribute__((format(printf, 1, 2)));
+#endif
+
 #endif /* _BSD_MISC_H */
index e6751d31c362ed3d7cc4bd61e85c69368d665d3b..2894d3a1e80c016594767e50999957f87c330fa7 100644 (file)
@@ -17,7 +17,9 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <err.h>
+#ifdef HAVE_ERR_H
+# include <err.h>
+#endif
 
 #include "ssherr.h"
 #include "ssh_api.h"
index 6234ba019d37d8256a1e86dd3b1a3cd99bb17f45..7c29e0cf95a2dea85bd38774dcac2bf1b798831d 100644 (file)
@@ -134,46 +134,6 @@ void       usage(int);
 ssize_t drainbuf(int, unsigned char *, size_t *);
 ssize_t fillbuf(int, unsigned char *, size_t *);
 
-static void err(int, const char *, ...) __attribute__((format(printf, 2, 3)));
-static void errx(int, const char *, ...) __attribute__((format(printf, 2, 3)));
-static void warn(const char *, ...) __attribute__((format(printf, 1, 2)));
-
-static void
-err(int r, const char *fmt, ...)
-{
-       va_list args;
-
-       va_start(args, fmt);
-       fprintf(stderr, "%s: ", strerror(errno));
-       vfprintf(stderr, fmt, args);
-       fputc('\n', stderr);
-       va_end(args);
-       exit(r);
-}
-
-static void
-errx(int r, const char *fmt, ...)
-{
-       va_list args;
-
-       va_start(args, fmt);
-       vfprintf(stderr, fmt, args);
-       fputc('\n', stderr);
-       va_end(args);
-       exit(r);
-}
-
-static void
-warn(const char *fmt, ...)
-{
-       va_list args;
-
-       va_start(args, fmt);
-       fprintf(stderr, "%s: ", strerror(errno));
-       vfprintf(stderr, fmt, args);
-       fputc('\n', stderr);
-       va_end(args);
-}
 
 int
 main(int argc, char *argv[])