[openssh-commits] [openssh] 01/01: Original portability patch from djm@ for platforms missing err.h. Fix name space clash on Solaris 10. Still more to do for Solaris 10 to deal with msghdr structure differences. ok djm@

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Feb 25 03:03:27 AEDT 2015


This is an automated email from the git hooks/post-receive script.

tim pushed a commit to branch master
in repository openssh.

commit 13af342458f5064144abbb07e5ac9bbd4eb42567
Author: Tim Rice <tim at multitalents.net>
Date:   Tue Feb 24 07:56:47 2015 -0800

    Original portability patch from djm@ for platforms missing err.h.
    Fix name space clash on Solaris 10. Still more to do for Solaris 10
    to deal with msghdr structure differences. ok djm@
---
 regress/netcat.c | 67 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 53 insertions(+), 14 deletions(-)

diff --git a/regress/netcat.c b/regress/netcat.c
index 84efe11..3f100bd 100644
--- a/regress/netcat.c
+++ b/regress/netcat.c
@@ -44,7 +44,6 @@
 #include <netinet/ip.h>
 #include <arpa/telnet.h>
 
-#include <err.h>
 #include <errno.h>
 #include <netdb.h>
 #include <poll.h>
@@ -122,6 +121,47 @@ 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[])
 {
@@ -500,7 +540,7 @@ main(int argc, char *argv[])
 int
 unix_bind(char *path)
 {
-	struct sockaddr_un sun;
+	struct sockaddr_un sun_sa;
 	int s;
 
 	/* Create unix domain socket. */
@@ -508,17 +548,17 @@ unix_bind(char *path)
 	     0)) < 0)
 		return (-1);
 
-	memset(&sun, 0, sizeof(struct sockaddr_un));
-	sun.sun_family = AF_UNIX;
+	memset(&sun_sa, 0, sizeof(struct sockaddr_un));
+	sun_sa.sun_family = AF_UNIX;
 
-	if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
-	    sizeof(sun.sun_path)) {
+	if (strlcpy(sun_sa.sun_path, path, sizeof(sun_sa.sun_path)) >=
+	    sizeof(sun_sa.sun_path)) {
 		close(s);
 		errno = ENAMETOOLONG;
 		return (-1);
 	}
 
-	if (bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
+	if (bind(s, (struct sockaddr *)&sun_sa, SUN_LEN(&sun_sa)) < 0) {
 		close(s);
 		return (-1);
 	}
@@ -532,7 +572,7 @@ unix_bind(char *path)
 int
 unix_connect(char *path)
 {
-	struct sockaddr_un sun;
+	struct sockaddr_un sun_sa;
 	int s;
 
 	if (uflag) {
@@ -544,16 +584,16 @@ unix_connect(char *path)
 	}
 	(void)fcntl(s, F_SETFD, FD_CLOEXEC);
 
-	memset(&sun, 0, sizeof(struct sockaddr_un));
-	sun.sun_family = AF_UNIX;
+	memset(&sun_sa, 0, sizeof(struct sockaddr_un));
+	sun_sa.sun_family = AF_UNIX;
 
-	if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
-	    sizeof(sun.sun_path)) {
+	if (strlcpy(sun_sa.sun_path, path, sizeof(sun_sa.sun_path)) >=
+	    sizeof(sun_sa.sun_path)) {
 		close(s);
 		errno = ENAMETOOLONG;
 		return (-1);
 	}
-	if (connect(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
+	if (connect(s, (struct sockaddr *)&sun_sa, SUN_LEN(&sun_sa)) < 0) {
 		close(s);
 		return (-1);
 	}
@@ -1331,7 +1371,6 @@ usage(int ret)
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-#include <err.h>
 #include <errno.h>
 #include <netdb.h>
 #include <stdio.h>

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list