Enlightenment CVS committal
Author : mej
Project : eterm
Module : Eterm
Dir : eterm/Eterm/src
Modified Files:
libscream.c
Log Message:
Thu Jan 5 14:50:53 2006 Michael Jennings (mej)
Fixed firewall bounce port checking from 2005-12-05.
----------------------------------------------------------------------
===================================================================
RCS file: /cvsroot/enlightenment/eterm/Eterm/src/libscream.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- libscream.c 5 Dec 2005 20:45:58 -0000 1.29
+++ libscream.c 5 Jan 2006 19:49:32 -0000 1.30
@@ -211,22 +211,28 @@
struct sockaddr_in addr;
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = INADDR_LOOPBACK;
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
for (lp = NS_MIN_PORT; (lp > 0) && (lp < NS_MAX_PORT);
lp++) {
addr.sin_port = htons(lp);
- if (!bind(tmp_sock, (struct sockaddr *) &addr,
sizeof(struct sockaddr_in))
- && !listen(tmp_sock, 1)) {
+ if (bind(tmp_sock, (struct sockaddr *) &addr,
sizeof(struct sockaddr_in))) {
+ D_ESCREEN(("Unable to bind socket %d to
127.0.0.1:%hd -- %s\n", tmp_sock, lp, strerror(errno)));
+ } else if (listen(tmp_sock, 1)) {
+ D_ESCREEN(("Unable to listen on port %hd -- %s\n",
lp, strerror(errno)));
+ } else {
/* We can listen on this port. Use it! */
/* FIXME: Minor race condition between port
selection and ssh call. */
+ D_ESCREEN(("Got available listening port %d.\n",
lp));
break;
}
}
if ((lp < 0) || (lp == NS_MAX_PORT)) {
/* We're going to fail anyway, so just throw something
in. */
- lp = (NS_MIN_PORT + random()) % NS_MAX_PORT;
+ lp = NS_MIN_PORT + (random() % (NS_MAX_PORT -
NS_MIN_PORT));
BOUND(lp, NS_MIN_PORT, NS_MAX_PORT);
+ D_ESCREEN(("Chose random listening port %d.\n", lp));
}
+ close(tmp_sock);
}
}
h->delay = (delay ? delay : NS_TUNNEL_DELAY);
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs