Added new "--localhost-only" command line option.
git-svn-id: https://shellinabox.googlecode.com/svn/trunk@125 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
parent
6dbbe62310
commit
5ec8c4c19b
10 changed files with 31 additions and 19 deletions
2
config.h
2
config.h
|
@ -132,7 +132,7 @@
|
||||||
#define STDC_HEADERS 1
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
/* Most recent revision number in the version control system */
|
/* Most recent revision number in the version control system */
|
||||||
#define VCS_REVISION "124"
|
#define VCS_REVISION "125"
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#define VERSION "2.8"
|
#define VERSION "2.8"
|
||||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -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
|
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||||
|
|
||||||
|
|
||||||
VCS_REVISION=124
|
VCS_REVISION=125
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
|
|
@ -2,7 +2,7 @@ AC_PREREQ(2.57)
|
||||||
|
|
||||||
dnl This is the one location where the authoritative version number is stored
|
dnl This is the one location where the authoritative version number is stored
|
||||||
AC_INIT(shellinabox, 2.8, markus@shellinabox.com)
|
AC_INIT(shellinabox, 2.8, markus@shellinabox.com)
|
||||||
VCS_REVISION=124
|
VCS_REVISION=125
|
||||||
AC_SUBST(VCS_REVISION)
|
AC_SUBST(VCS_REVISION)
|
||||||
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
|
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
|
||||||
[Most recent revision number in the version control system])
|
[Most recent revision number in the version control system])
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
VT100.prototype.about = 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" +
|
"\nCopyright 2008-2009 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com");
|
"For more information check http://shellinabox.com");
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,8 +66,8 @@ typedef struct ServerConnection ServerConnection;
|
||||||
typedef struct Server Server;
|
typedef struct Server Server;
|
||||||
typedef struct URL URL;
|
typedef struct URL URL;
|
||||||
|
|
||||||
Server *newCGIServer(int portMin, int portMax, int timeout);
|
Server *newCGIServer(int localhostOnly, int portMin, int portMax, int timeout);
|
||||||
Server *newServer(int port);
|
Server *newServer(int localhostOnly, int port);
|
||||||
void deleteServer(Server *server);
|
void deleteServer(Server *server);
|
||||||
int serverGetListeningPort(Server *server);
|
int serverGetListeningPort(Server *server);
|
||||||
int serverGetFd(Server *server);
|
int serverGetFd(Server *server);
|
||||||
|
|
|
@ -170,18 +170,20 @@ static int serverQuitHandler(struct HttpConnection *http, void *arg) {
|
||||||
return HTTP_DONE;
|
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;
|
struct Server *server;
|
||||||
check(server = malloc(sizeof(struct Server)));
|
check(server = malloc(sizeof(struct Server)));
|
||||||
initServer(server, portMin, portMax, timeout);
|
initServer(server, localhostOnly, portMin, portMax, timeout);
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Server *newServer(int port) {
|
struct Server *newServer(int localhostOnly, int port) {
|
||||||
return newCGIServer(port, port, -1);
|
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->looping = 0;
|
||||||
server->exitAll = 0;
|
server->exitAll = 0;
|
||||||
server->serverTimeout = timeout;
|
server->serverTimeout = timeout;
|
||||||
|
@ -196,7 +198,8 @@ void initServer(struct Server *server, int portMin, int portMax, int timeout) {
|
||||||
&true, sizeof(true)));
|
&true, sizeof(true)));
|
||||||
struct sockaddr_in serverAddr = { 0 };
|
struct sockaddr_in serverAddr = { 0 };
|
||||||
serverAddr.sin_family = AF_INET;
|
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.
|
// 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
|
// So, we have to randomly pick a port from our allowed port range, and then
|
||||||
|
|
|
@ -78,9 +78,11 @@ struct Server {
|
||||||
struct SSLSupport ssl;
|
struct SSLSupport ssl;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Server *newCGIServer(int portMin, int portMax, int timeout);
|
struct Server *newCGIServer(int localhostOnly, int portMin, int portMax,
|
||||||
struct Server *newServer(int port);
|
int timeout);
|
||||||
void initServer(struct Server *server, 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 destroyServer(struct Server *server);
|
||||||
void deleteServer(struct Server *server);
|
void deleteServer(struct Server *server);
|
||||||
int serverGetListeningPort(struct Server *server);
|
int serverGetListeningPort(struct Server *server);
|
||||||
|
|
|
@ -355,7 +355,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ShellInABox.prototype.about = function() {
|
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" +
|
"\nCopyright 2008-2009 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com" +
|
"For more information check http://shellinabox.com" +
|
||||||
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
|
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
static int port;
|
static int port;
|
||||||
static int portMin;
|
static int portMin;
|
||||||
static int portMax;
|
static int portMax;
|
||||||
|
static int localhostOnly = 0;
|
||||||
static int noBeep = 0;
|
static int noBeep = 0;
|
||||||
static int numericHosts = 0;
|
static int numericHosts = 0;
|
||||||
static int enableSSL = 1;
|
static int enableSSL = 1;
|
||||||
|
@ -595,6 +596,7 @@ static void usage(void) {
|
||||||
" -f, --static-file=URL:FILE serve static file from URL path\n"
|
" -f, --static-file=URL:FILE serve static file from URL path\n"
|
||||||
" -g, --group=GID switch to this group (default: %s)\n"
|
" -g, --group=GID switch to this group (default: %s)\n"
|
||||||
" -h, --help print this message\n"
|
" -h, --help print this message\n"
|
||||||
|
" --localhost-only only listen on 127.0.0.1\n"
|
||||||
" --no-beep suppress all audio output\n"
|
" --no-beep suppress all audio output\n"
|
||||||
" -n, --numeric do not resolve hostnames\n"
|
" -n, --numeric do not resolve hostnames\n"
|
||||||
" -p, --port=PORT select a port (default: %d)\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' },
|
{ "debug", 0, 0, 'd' },
|
||||||
{ "static-file", 1, 0, 'f' },
|
{ "static-file", 1, 0, 'f' },
|
||||||
{ "group", 1, 0, 'g' },
|
{ "group", 1, 0, 'g' },
|
||||||
|
{ "localhost-only", 0, 0, 0 },
|
||||||
{ "no-beep", 0, 0, 0 },
|
{ "no-beep", 0, 0, 0 },
|
||||||
{ "numeric", 0, 0, 'n' },
|
{ "numeric", 0, 0, 'n' },
|
||||||
{ "port", 1, 0, 'p' },
|
{ "port", 1, 0, 'p' },
|
||||||
|
@ -781,6 +784,9 @@ static void parseArgs(int argc, char * const argv[]) {
|
||||||
fatal("Duplicate --group option.");
|
fatal("Duplicate --group option.");
|
||||||
}
|
}
|
||||||
runAsGroup = parseGroup(optarg, NULL);
|
runAsGroup = parseGroup(optarg, NULL);
|
||||||
|
} else if (!idx--) {
|
||||||
|
// Localhost Only
|
||||||
|
localhostOnly = 1;
|
||||||
} else if (!idx--) {
|
} else if (!idx--) {
|
||||||
// No Beep
|
// No Beep
|
||||||
noBeep = 1;
|
noBeep = 1;
|
||||||
|
@ -962,7 +968,7 @@ int main(int argc, char * const argv[]) {
|
||||||
// Create a new web server
|
// Create a new web server
|
||||||
Server *server;
|
Server *server;
|
||||||
if (port) {
|
if (port) {
|
||||||
check(server = newServer(port));
|
check(server = newServer(localhostOnly, port));
|
||||||
dropPrivileges();
|
dropPrivileges();
|
||||||
setUpSSL(server);
|
setUpSSL(server);
|
||||||
} else {
|
} else {
|
||||||
|
@ -982,7 +988,8 @@ int main(int argc, char * const argv[]) {
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
check(!NOINTR(close(fds[0])));
|
check(!NOINTR(close(fds[0])));
|
||||||
check(server = newCGIServer(portMin, portMax, AJAX_TIMEOUT));
|
check(server = newCGIServer(localhostOnly, portMin, portMax,
|
||||||
|
AJAX_TIMEOUT));
|
||||||
cgiServer = server;
|
cgiServer = server;
|
||||||
setUpSSL(server);
|
setUpSSL(server);
|
||||||
|
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ VT100.prototype.toggleBell = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
VT100.prototype.about = 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" +
|
"\nCopyright 2008-2009 by Markus Gutschke\n" +
|
||||||
"For more information check http://shellinabox.com");
|
"For more information check http://shellinabox.com");
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue