diff --git a/config.h b/config.h index 00cdb47..b4fee8a 100644 --- a/config.h +++ b/config.h @@ -132,7 +132,7 @@ #define STDC_HEADERS 1 /* Most recent revision number in the version control system */ -#define VCS_REVISION "124" +#define VCS_REVISION "125" /* Version number of package */ #define VERSION "2.8" diff --git a/configure b/configure index f91b6f0..289a34f 100755 --- a/configure +++ b/configure @@ -2037,7 +2037,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -VCS_REVISION=124 +VCS_REVISION=125 cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index 5417270..929a5f0 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.57) dnl This is the one location where the authoritative version number is stored AC_INIT(shellinabox, 2.8, markus@shellinabox.com) -VCS_REVISION=124 +VCS_REVISION=125 AC_SUBST(VCS_REVISION) AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", [Most recent revision number in the version control system]) diff --git a/demo/vt100.js b/demo/vt100.js index 24a0154..76acb4d 100644 --- a/demo/vt100.js +++ b/demo/vt100.js @@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.8 (revision 124)" + + alert("VT100 Terminal Emulator " + "2.8 (revision 125)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); }; diff --git a/libhttp/http.h b/libhttp/http.h index f1119eb..3235eab 100644 --- a/libhttp/http.h +++ b/libhttp/http.h @@ -66,8 +66,8 @@ typedef struct ServerConnection ServerConnection; typedef struct Server Server; typedef struct URL URL; -Server *newCGIServer(int portMin, int portMax, int timeout); -Server *newServer(int port); +Server *newCGIServer(int localhostOnly, int portMin, int portMax, int timeout); +Server *newServer(int localhostOnly, int port); void deleteServer(Server *server); int serverGetListeningPort(Server *server); int serverGetFd(Server *server); diff --git a/libhttp/server.c b/libhttp/server.c index aa08d86..f52a269 100644 --- a/libhttp/server.c +++ b/libhttp/server.c @@ -170,18 +170,20 @@ static int serverQuitHandler(struct HttpConnection *http, void *arg) { return HTTP_DONE; } -struct Server *newCGIServer(int portMin, int portMax, int timeout) { +struct Server *newCGIServer(int localhostOnly, int portMin, int portMax, + int timeout) { struct Server *server; check(server = malloc(sizeof(struct Server))); - initServer(server, portMin, portMax, timeout); + initServer(server, localhostOnly, portMin, portMax, timeout); return server; } -struct Server *newServer(int port) { - return newCGIServer(port, port, -1); +struct Server *newServer(int localhostOnly, int port) { + return newCGIServer(localhostOnly, port, port, -1); } -void initServer(struct Server *server, int portMin, int portMax, int timeout) { +void initServer(struct Server *server, int localhostOnly, int portMin, + int portMax, int timeout) { server->looping = 0; server->exitAll = 0; server->serverTimeout = timeout; @@ -196,7 +198,8 @@ void initServer(struct Server *server, int portMin, int portMax, int timeout) { &true, sizeof(true))); struct sockaddr_in serverAddr = { 0 }; serverAddr.sin_family = AF_INET; - serverAddr.sin_addr.s_addr = INADDR_ANY; + serverAddr.sin_addr.s_addr = htonl(localhostOnly + ? INADDR_LOOPBACK : INADDR_ANY); // Linux unlike BSD does not have support for picking a local port range. // So, we have to randomly pick a port from our allowed port range, and then diff --git a/libhttp/server.h b/libhttp/server.h index be1bd67..bb879fb 100644 --- a/libhttp/server.h +++ b/libhttp/server.h @@ -78,9 +78,11 @@ struct Server { struct SSLSupport ssl; }; -struct Server *newCGIServer(int portMin, int portMax, int timeout); -struct Server *newServer(int port); -void initServer(struct Server *server, int portMin, int portMax, int timeout); +struct Server *newCGIServer(int localhostOnly, int portMin, int portMax, + int timeout); +struct Server *newServer(int localhostOnly, int port); +void initServer(struct Server *server, int localhostOnly, int portMin, + int portMax, int timeout); void destroyServer(struct Server *server); void deleteServer(struct Server *server); int serverGetListeningPort(struct Server *server); diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 81c9a23..ab00bb1 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -355,7 +355,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) { }; ShellInABox.prototype.about = function() { - alert("Shell In A Box version " + "2.8 (revision 124)" + + alert("Shell In A Box version " + "2.8 (revision 125)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com" + (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ? diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index 7f0bcaf..5c00b9d 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -79,6 +79,7 @@ static int port; static int portMin; static int portMax; +static int localhostOnly = 0; static int noBeep = 0; static int numericHosts = 0; static int enableSSL = 1; @@ -595,6 +596,7 @@ static void usage(void) { " -f, --static-file=URL:FILE serve static file from URL path\n" " -g, --group=GID switch to this group (default: %s)\n" " -h, --help print this message\n" + " --localhost-only only listen on 127.0.0.1\n" " --no-beep suppress all audio output\n" " -n, --numeric do not resolve hostnames\n" " -p, --port=PORT select a port (default: %d)\n" @@ -664,6 +666,7 @@ static void parseArgs(int argc, char * const argv[]) { { "debug", 0, 0, 'd' }, { "static-file", 1, 0, 'f' }, { "group", 1, 0, 'g' }, + { "localhost-only", 0, 0, 0 }, { "no-beep", 0, 0, 0 }, { "numeric", 0, 0, 'n' }, { "port", 1, 0, 'p' }, @@ -781,6 +784,9 @@ static void parseArgs(int argc, char * const argv[]) { fatal("Duplicate --group option."); } runAsGroup = parseGroup(optarg, NULL); + } else if (!idx--) { + // Localhost Only + localhostOnly = 1; } else if (!idx--) { // No Beep noBeep = 1; @@ -962,7 +968,7 @@ int main(int argc, char * const argv[]) { // Create a new web server Server *server; if (port) { - check(server = newServer(port)); + check(server = newServer(localhostOnly, port)); dropPrivileges(); setUpSSL(server); } else { @@ -982,7 +988,8 @@ int main(int argc, char * const argv[]) { _exit(0); } check(!NOINTR(close(fds[0]))); - check(server = newCGIServer(portMin, portMax, AJAX_TIMEOUT)); + check(server = newCGIServer(localhostOnly, portMin, portMax, + AJAX_TIMEOUT)); cgiServer = server; setUpSSL(server); diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index 24a0154..76acb4d 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() { }; VT100.prototype.about = function() { - alert("VT100 Terminal Emulator " + "2.8 (revision 124)" + + alert("VT100 Terminal Emulator " + "2.8 (revision 125)" + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com"); };