From 7161399b2da14725ee1fb938b21c666aeea555d6 Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Wed, 9 Aug 2017 23:27:24 +0200 Subject: [PATCH] Fix net/sslh for illumos - Ship SMF manifest for illumos - cast getpid() to int so printf works on illumos - rename queue to sslhqueue to avoid conflict on illumos - ifdef the change to sslh-main.c, this broke arg parsing on illumos --- net/sslh/distinfo | 5 ++- net/sslh/files/smf/manifest.xml | 31 ++++++++++++++++++ net/sslh/patches/patch-common.c | 49 ++++++++++++++++++++++++++++ net/sslh/patches/patch-common.h | 42 ++++++++++++++++++++++++ net/sslh/patches/patch-sslh-main.c | 14 +++++--- net/sslh/patches/patch-sslh-select.c | 23 +++++++++++++ 6 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 net/sslh/files/smf/manifest.xml create mode 100644 net/sslh/patches/patch-common.c create mode 100644 net/sslh/patches/patch-common.h create mode 100644 net/sslh/patches/patch-sslh-select.c diff --git a/net/sslh/distinfo b/net/sslh/distinfo index 6aa8ba1a59cb3..e1991ef66d761 100644 --- a/net/sslh/distinfo +++ b/net/sslh/distinfo @@ -4,5 +4,8 @@ SHA1 (sslh-1.18.tar.gz) = dacf6250e26250513deeaa310c78591d5b3e77f4 RMD160 (sslh-1.18.tar.gz) = 49e83f975f7e8df8358bdd1d7afeabdbe6269a82 SHA512 (sslh-1.18.tar.gz) = 859ad65a258534fde68295a2880c077a00205d96a6aafeb525abce836850b9deea7b39daa2dc74a0dc18d2b198884958a39fbe758d61c93b257676f3a7d4f7bc Size (sslh-1.18.tar.gz) = 53175 bytes +SHA1 (patch-common.c) = 9cef21e4d81949b81b7d036bb00106498edf3190 +SHA1 (patch-common.h) = 63fb02a7630ae9c7903e936cbd9e6a0964725f36 SHA1 (patch-echosrv.c) = 611044fd7ed1fd52c44e2d8ff393091c35478e17 -SHA1 (patch-sslh-main.c) = a74502a087b11c4d8f32791ac86c45c7a38923d9 +SHA1 (patch-sslh-main.c) = ce6b2cbf6bfde2daf6735bbf74f78c60a54c4008 +SHA1 (patch-sslh-select.c) = 493d3269041ed9861e00c06073713fbcf45b42fd diff --git a/net/sslh/files/smf/manifest.xml b/net/sslh/files/smf/manifest.xml new file mode 100644 index 0000000000000..cbc854935067c --- /dev/null +++ b/net/sslh/files/smf/manifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net/sslh/patches/patch-common.c b/net/sslh/patches/patch-common.c new file mode 100644 index 0000000000000..8e10a54516184 --- /dev/null +++ b/net/sslh/patches/patch-common.c @@ -0,0 +1,49 @@ +$NetBSD$ + +--- common.c.orig 2016-03-29 19:19:05.000000000 +0000 ++++ common.c +@@ -237,7 +237,7 @@ int connect_addr(struct connection *cnx, + } + + /* Store some data to write to the queue later */ +-int defer_write(struct queue *q, void* data, int data_size) ++int defer_write(struct sslhqueue *q, void* data, int data_size) + { + char *p; + if (verbose) +@@ -261,7 +261,7 @@ int defer_write(struct queue *q, void* d + * Upon success, the number of bytes written is returned. + * Upon failure, -1 returned (e.g. connexion closed) + * */ +-int flush_deferred(struct queue *q) ++int flush_deferred(struct sslhqueue *q) + { + int n; + +@@ -313,7 +313,7 @@ void dump_connection(struct connection * + * returns FD_STALLED if data was read, could not be written, and has been + * stored in temporary buffer. + */ +-int fd2fd(struct queue *target_q, struct queue *from_q) ++int fd2fd(struct sslhqueue *target_q, struct sslhqueue *from_q) + { + char buffer[BUFSIZ]; + int target, from, size_r, size_w; +@@ -594,7 +594,7 @@ void setup_syslog(const char* bin_name) + int res; + + name1 = strdup(bin_name); +- res = asprintf(&name2, "%s[%d]", basename(name1), getpid()); ++ res = asprintf(&name2, "%s[%d]", basename(name1), (int)getpid()); + CHECK_RES_DIE(res, "asprintf"); + openlog(name2, LOG_CONS, LOG_AUTH); + free(name1); +@@ -694,7 +694,7 @@ void write_pid_file(const char* pidfile) + exit(3); + } + +- fprintf(f, "%d\n", getpid()); ++ fprintf(f, "%d\n", (int)getpid()); + fclose(f); + } + diff --git a/net/sslh/patches/patch-common.h b/net/sslh/patches/patch-common.h new file mode 100644 index 0000000000000..170354125b974 --- /dev/null +++ b/net/sslh/patches/patch-common.h @@ -0,0 +1,42 @@ +$NetBSD$ + +--- common.h.orig 2016-03-29 19:19:05.000000000 +0000 ++++ common.h +@@ -69,7 +69,7 @@ enum connection_state { + + /* A 'queue' is composed of a file descriptor (which can be read from or + * written to), and a queue for deferred write data */ +-struct queue { ++struct sslhqueue { + int fd; + void *begin_deferred_data; + void *deferred_data; +@@ -84,7 +84,7 @@ struct connection { + /* q[0]: queue for external connection (client); + * q[1]: queue for internal connection (httpd or sshd); + * */ +- struct queue q[2]; ++ struct sslhqueue q[2]; + }; + + #define FD_CNXCLOSED 0 +@@ -95,7 +95,7 @@ struct connection { + /* common.c */ + void init_cnx(struct connection *cnx); + int connect_addr(struct connection *cnx, int fd_from); +-int fd2fd(struct queue *target, struct queue *from); ++int fd2fd(struct sslhqueue *target, struct sslhqueue *from); + char* sprintaddr(char* buf, size_t size, struct addrinfo *a); + void resolve_name(struct addrinfo **out, char* fullname); + void log_connection(struct connection *cnx); +@@ -110,8 +110,8 @@ int resolve_split_name(struct addrinfo * + + int start_listen_sockets(int *sockfd[], struct addrinfo *addr_list); + +-int defer_write(struct queue *q, void* data, int data_size); +-int flush_deferred(struct queue *q); ++int defer_write(struct sslhqueue *q, void* data, int data_size); ++int flush_deferred(struct sslhqueue *q); + + extern int probing_timeout, verbose, inetd, foreground, + background, transparent, numeric; diff --git a/net/sslh/patches/patch-sslh-main.c b/net/sslh/patches/patch-sslh-main.c index 0c4c773de77eb..6becbb56c8b44 100644 --- a/net/sslh/patches/patch-sslh-main.c +++ b/net/sslh/patches/patch-sslh-main.c @@ -4,21 +4,27 @@ --- sslh-main.c.orig 2016-03-29 19:19:05.000000000 +0000 +++ sslh-main.c -@@ -443,7 +443,7 @@ static void cmdline_config(int argc, cha +@@ -443,7 +443,11 @@ static void cmdline_config(int argc, cha #ifdef LIBCONFIG optind = 1; opterr = 0; /* we're missing protocol options at this stage so don't output errors */ -- while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { ++#ifdef BSD + while ((c = getopt_long(argc, argv, optstr, all_options, NULL)) != -1) { ++#else + while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { ++#endif if (c == 'v') { verbose++; } -@@ -480,7 +480,7 @@ static void parse_cmdline(int argc, char +@@ -480,7 +484,11 @@ static void parse_cmdline(int argc, char optind = 1; opterr = 1; next_arg: -- while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { ++#ifdef BSD + while ((c = getopt_long(argc, argv, optstr, all_options, NULL)) != -1) { ++#else + while ((c = getopt_long_only(argc, argv, optstr, all_options, NULL)) != -1) { ++#endif if (c == 0) continue; if (c >= PROT_SHIFT) { diff --git a/net/sslh/patches/patch-sslh-select.c b/net/sslh/patches/patch-sslh-select.c new file mode 100644 index 0000000000000..9111e5b538ddd --- /dev/null +++ b/net/sslh/patches/patch-sslh-select.c @@ -0,0 +1,23 @@ +$NetBSD$ + +--- sslh-select.c.orig 2016-03-29 19:19:05.000000000 +0000 ++++ sslh-select.c +@@ -131,7 +131,7 @@ int accept_new_connection(int listen_soc + /* Connect queue 1 of connection to SSL; returns new file descriptor */ + int connect_queue(struct connection *cnx, fd_set *fds_r, fd_set *fds_w) + { +- struct queue *q = &cnx->q[1]; ++ struct sslhqueue *q = &cnx->q[1]; + + q->fd = connect_addr(cnx, cnx->q[0].fd); + if ((q->fd != -1) && fd_is_in_range(q->fd)) { +@@ -156,7 +156,8 @@ int connect_queue(struct connection *cnx + void shovel(struct connection *cnx, int active_fd, + fd_set *fds_r, fd_set *fds_w) + { +- struct queue *read_q, *write_q; ++ struct sslhqueue *read_q, *write_q; ++ + + read_q = &cnx->q[active_fd]; + write_q = &cnx->q[1-active_fd];