From 97fff401a30014d9542b9a2c7835fe40cee00e8c Mon Sep 17 00:00:00 2001 From: zodiac Date: Tue, 17 Mar 2009 17:51:42 +0000 Subject: [PATCH] Fixed IE6 support, and fixed possible memory corruption, when sessions time out. git-svn-id: https://shellinabox.googlecode.com/svn/trunk@77 0da03de8-d603-11dd-86c2-0f8696b7b6f9 --- ChangeLog | 6 ++++++ config.h | 8 ++++---- shellinabox/launcher.c | 2 +- shellinabox/shell_in_a_box.js | 24 +++++++++++++++++++----- shellinabox/shellinaboxd.c | 4 ++++ shellinabox/vt100.js | 15 ++++++++++----- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d989d56..1b5828f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-03-17 Markus Gutschke + + * Fixed IE6 support. + + * Fixed possible memory corruption, when sessions time out. + 2009-03-16 Markus Gutschke * Fixed some compiler warnings, that newer versions of GCC issue. diff --git a/config.h b/config.h index 8ab50b1..1b35139 100644 --- a/config.h +++ b/config.h @@ -35,13 +35,13 @@ #define HAVE_PTSNAME_R 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_SECURITY_PAM_APPL_H */ +#define HAVE_SECURITY_PAM_APPL_H 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_SECURITY_PAM_CLIENT_H */ +#define HAVE_SECURITY_PAM_CLIENT_H 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_SECURITY_PAM_MISC_H */ +#define HAVE_SECURITY_PAM_MISC_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 @@ -95,7 +95,7 @@ #define STDC_HEADERS 1 /* Most recent revision number in the version control system */ -#define VCS_REVISION "76" +#define VCS_REVISION "77" /* Version number of package */ #define VERSION "2.4" diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index de13ab8..1f01dbb 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -1077,7 +1077,7 @@ static void childProcess(struct Service *service, int width, int height, environment[numEnvVars] = NULL; // Set initial terminal settings - struct termios tt; + struct termios tt = { 0 }; tcgetattr(0, &tt); cfsetispeed(&tt, 38400); cfsetospeed(&tt, 38400); diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 4f4fc13..9fd5c10 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -158,9 +158,18 @@ ShellInABox.prototype.sendRequest = function(request) { if (request == undefined) { request = new XMLHttpRequest(); } - request.open('POST', this.url, true); + request.open(this.session ? 'POST' : 'GET', this.url, true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'); + var content = this.session ? + ('width=' + this.terminalWidth + + '&height=' + this.terminalHeight + + '&session=' + + encodeURIComponent(this.session)) : ''; + if (this.session) { + request.setRequestHeader('Content-Length', content.length); + } + request.onreadystatechange = function(shellInABox) { return function() { try { @@ -170,10 +179,15 @@ ShellInABox.prototype.sendRequest = function(request) { } } }(this); - request.send( - 'width=' + this.terminalWidth + - '&height=' + this.terminalHeight + - (this.session ? "&session=" + encodeURIComponent(this.session) : "")); + try { + if (this.session) { + request.send(content); + } else { + request.send(); + } + } catch (e) { + alert('' + e + '\n' + this.url + '\n' + content); + } }; ShellInABox.prototype.onReadyStateChange = function(request) { diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index 367c768..b76efb2 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -273,6 +273,10 @@ static int handleSession(struct ServerConnection *connection, void *arg, } check(!session->done); check(completePendingRequest(session, buf, bytes, MAX_RESPONSE)); + connection = serverGetConnection(session->server, + connection, + session->pty); + session->connection = connection; if (session->len >= MAX_RESPONSE) { serverConnectionSetEvents(session->server, connection, 0); } diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index 49211d7..7e7c50d 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -226,6 +226,7 @@ VT100.prototype.initializeElements = function(container) { } } catch (e) { } + this.container.innerHTML = '