summaryrefslogtreecommitdiff
path: root/network/redir/patches/25_fix_setsockopt.dpatch
diff options
context:
space:
mode:
authorMatteo Bernardini <ponce@slackbuilds.org>2013-07-25 12:23:52 +0200
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2016-01-17 09:40:16 +0700
commit9f0af0e072f8940a3122d3c0ea4da5665e6a291e (patch)
tree321ad9fbf6295e59229753103357c1f703036953 /network/redir/patches/25_fix_setsockopt.dpatch
parent15498860e5de555bc2d27a88e4ceba7354c7fb2b (diff)
downloadslackbuilds-9f0af0e072f8940a3122d3c0ea4da5665e6a291e.tar.gz
network/redir: Added (Redirect TCP connections).
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
Diffstat (limited to 'network/redir/patches/25_fix_setsockopt.dpatch')
-rw-r--r--network/redir/patches/25_fix_setsockopt.dpatch62
1 files changed, 62 insertions, 0 deletions
diff --git a/network/redir/patches/25_fix_setsockopt.dpatch b/network/redir/patches/25_fix_setsockopt.dpatch
new file mode 100644
index 0000000000..0623198f72
--- /dev/null
+++ b/network/redir/patches/25_fix_setsockopt.dpatch
@@ -0,0 +1,62 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 25_fix_setsockopt.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Ensure that the server socket has SO_REUSEADDR and SO_LINGER set properly.
+
+@DPATCH@
+diff -urNad redir~/redir.c redir/redir.c
+--- redir~/redir.c 2009-03-03 17:35:12.022427586 -0500
++++ redir/redir.c 2009-03-03 17:45:28.998426896 -0500
+@@ -90,8 +90,8 @@
+ /* let's set up some globals... */
+ int dodebug = 0;
+ int dosyslog = 0;
+-unsigned char reuse_addr = 1;
+-unsigned char linger_opt = 0;
++int reuse_addr = 1; /* allow address reuse */
++struct linger linger_opt = { 0, 0}; /* do not linger */
+ char * bind_addr = NULL;
+ struct sockaddr_in addr_out;
+ int timeout = 0;
+@@ -906,6 +906,7 @@
+
+ int servsock;
+ struct sockaddr_in server;
++ int ret;
+
+ /*
+ * Get a socket to work with. This socket will
+@@ -944,8 +945,30 @@
+ server.sin_addr.s_addr = htonl(inet_addr("0.0.0.0"));
+ }
+
+- setsockopt(servsock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
+- setsockopt(servsock, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof(SO_LINGER));
++ ret = setsockopt(servsock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
++ if (ret != 0) {
++ if(fail) {
++ return -1;
++ }
++ else {
++ perror("server: setsockopt (SO_REUSEADDR)");
++ if (dosyslog)
++ syslog(LOG_ERR, "setsockopt failed with SO_REUSEADDR: %s",strerror(errno));
++ exit(1);
++ }
++ }
++ ret = setsockopt(servsock, SOL_SOCKET, SO_LINGER, &linger_opt, sizeof(linger_opt));
++ if (ret != 0) {
++ if(fail) {
++ return -1;
++ }
++ else {
++ perror("server: setsockopt (SO_LINGER)");
++ if (dosyslog)
++ syslog(LOG_ERR, "setsockopt failed with SO_LINGER: %s",strerror(errno));
++ exit(1);
++ }
++ }
+
+ /*
+ * Try to bind the address to the socket.