diff --git a/debian/shellinabox.default b/debian/shellinabox.default index a55051a..28f99b0 100644 --- a/debian/shellinabox.default +++ b/debian/shellinabox.default @@ -5,4 +5,6 @@ SHELLINABOX_DAEMON_START=1 SHELLINABOX_PORT=4200 # Any optional arguments (e.g. extra service definitions) -SHELLINABOX_ARGS= +# We disable beeps, as there have been reports of the VLC plugin crashing +# Firefox on Linux/x86_64. +SHELLINABOX_ARGS=--no-beep diff --git a/shellinabox/shell_in_a_box.js b/shellinabox/shell_in_a_box.js index 506ee9f..1a284ef 100644 --- a/shellinabox/shell_in_a_box.js +++ b/shellinabox/shell_in_a_box.js @@ -319,7 +319,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) { actions[i++] = oldActions[j++]; if (node.id == "endconfig") { node.id = ''; - if (serverSupportsSSL) { + if (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL) { // If the server supports both SSL and plain text connections, // provide a menu entry to switch between the two. var newNode = document.createElement('li'); @@ -349,7 +349,7 @@ ShellInABox.prototype.about = function() { alert("Shell In A Box version " + VERSION + "\nCopyright 2008-2009 by Markus Gutschke\n" + "For more information check http://shellinabox.com" + - (serverSupportsSSL ? + (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ? "\n\n" + "This product includes software developed by the OpenSSL Project\n" + "for use in the OpenSSL Toolkit. (http://www.openssl.org/)\n" + diff --git a/shellinabox/shellinaboxd.c b/shellinabox/shellinaboxd.c index d7835b1..0474f43 100644 --- a/shellinabox/shellinaboxd.c +++ b/shellinabox/shellinaboxd.c @@ -74,6 +74,7 @@ static int port; static int portMin; static int portMax; +static int noBeep = 0; static int numericHosts = 0; static int enableSSL = 1; static char *certificateDir; @@ -485,11 +486,13 @@ static int shellInABoxHttpHandler(HttpConnection *http, void *arg, extern char vt100End[]; extern char shellInABoxStart[]; extern char shellInABoxEnd[]; - char *sslState = stringPrintf(NULL, - "serverSupportsSSL = %s;\n\n", - enableSSL ? "true" : "false"); - int sslStateLength = strlen(sslState); - int contentLength = sslStateLength + + char *stateVars = stringPrintf(NULL, + "serverSupportsSSL = %s;\n" + "suppressAllAudio = %d;\n\n", + enableSSL ? "true" : "false", + noBeep); + int stateVarsLength = strlen(stateVars); + int contentLength = stateVarsLength + (vt100End - vt100Start) + (shellInABoxEnd - shellInABoxStart); char *response = stringPrintf(NULL, @@ -502,13 +505,13 @@ static int shellInABoxHttpHandler(HttpConnection *http, void *arg, if (strcmp(httpGetMethod(http), "HEAD")) { check(response = realloc(response, headerLength + contentLength)); memcpy(memcpy(memcpy( - response + headerLength, sslState, sslStateLength) + sslStateLength, + response + headerLength, stateVars, stateVarsLength)+stateVarsLength, vt100Start, vt100End - vt100Start) + (vt100End - vt100Start), shellInABoxStart, shellInABoxEnd - shellInABoxStart); } else { contentLength = 0; } - free(sslState); + free(stateVars); httpTransfer(http, response, headerLength + contentLength); } else if (pathInfoLength == 10 && !memcmp(pathInfo, "styles.css", 10)) { // Serve the style sheet. @@ -558,6 +561,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" + " --no-beep suppress all audio output\n" " -n, --numeric do not resolve hostnames\n" " -p, --port=PORT select a port (default: %d)\n" " -s, --service=SERVICE define one or more services\n" @@ -623,6 +627,7 @@ static void parseArgs(int argc, char * const argv[]) { { "debug", 0, 0, 'd' }, { "static-file", 1, 0, 'f' }, { "group", 1, 0, 'g' }, + { "no-beep", 0, 0, 0 }, { "numeric", 0, 0, 'n' }, { "port", 1, 0, 'p' }, { "service", 1, 0, 's' }, @@ -715,6 +720,9 @@ static void parseArgs(int argc, char * const argv[]) { fatal("Duplicate --group option."); } runAsGroup = parseGroup(optarg, NULL); + } else if (!idx--) { + // No Beep + noBeep = 1; } else if (!idx--) { // Numeric numericHosts = 1; diff --git a/shellinabox/shellinaboxd.man.in b/shellinabox/shellinaboxd.man.in index be9379f..11d6b82 100755 --- a/shellinabox/shellinaboxd.man.in +++ b/shellinabox/shellinaboxd.man.in @@ -57,6 +57,7 @@ shellinaboxd \- publish command line shell through AJAX interface [\ \fB-f\fP\ | \fB--static-file=\fP\fIurl\fP:\fIfile\fP\ ] [\ \fB-g\fP\ | \fB--group=\fP\fIgid\fP\ ] [\ \fB-h\fP\ | \fB--help\fP\ ] +[\ \fB--no-beep\fP\ ] [\ \fB-n\fP\ | \fB--numeric\fP\ ] [\ \fB-p\fP\ | \fB--port=\fP\fIport\fP\ ] [\ \fB-s\fP\ | \fB--service=\fP\fIservice\fP\ ] @@ -238,6 +239,11 @@ runs as. \fB-h\fP\ |\ \fB--help\fP Display a brief usage message showing the valid command line parameters. .TP +\fB--no-beep\fP +not only are audible signals undesired in some working environments, but +browser support for media playback is often buggy, too. Setting this option +suppresses all audio playback and enables the visual bell by default. +.TP \fB-n\fP\ |\ \fB--numeric\fP When running in .B --verbose @@ -580,3 +586,9 @@ Some browsers restrict the number of concurrent connections to a server. This restricts how many AJAX terminals can be opened simultaneously. If this becomes a problem, users can typically reconfigure their browsers to raise the limit. +.P +There have been reports of the VLC plugin on Linux/x86_64 crashing Firefox +when the browser page gets reloaded. Setting the +.B --no-beep +option eliminates all references to VLC and thus appears to work around +this crash. diff --git a/shellinabox/vt100.js b/shellinabox/vt100.js index 433ab00..7e82f79 100644 --- a/shellinabox/vt100.js +++ b/shellinabox/vt100.js @@ -128,7 +128,8 @@ VT100.prototype.reset = function(clearHistory) { this.offsetMode = false; this.mouseReporting = false; this.utfEnabled = true; - this.visibleBell = false; + this.visualBell = suppressAllAudio != 'undefined' && + suppressAllAudio; this.utfCount = 0; this.utfChar = 0; this.style = ''; @@ -209,17 +210,17 @@ VT100.prototype.initializeElements = function(container) { try { if (typeof navigator.mimeTypes["audio/x-wav"].enabledPlugin.name != 'undefined') { - embed = + embed = suppressAllAudio ? "" : ''; + 'id="beep_embed" ' + + 'src="beep.wav" ' + + 'autostart="false" ' + + 'volume="100" ' + + 'enablejavascript="true" ' + + 'type="audio/x-wav" ' + + 'height="16" ' + + 'width="200" ' + + 'style="position:absolute;left:-1000px;top:-1000px" />'; } } catch (e) { } @@ -240,18 +241,23 @@ VT100.prototype.initializeElements = function(container) { '' + '' + ' ' + - embed + '' + + (suppressAllAudio ? "" : + embed + '') + ''; } // Find the object used for playing the "beep" sound, if any. - this.beeper = this.getChildById(this.container, - 'beep_embed'); - if (!this.beeper || !this.beeper.Play) { + if (typeof suppressAllAudio != 'undefined' && suppressAllAudio) { + this.beeper = undefined; + } else { this.beeper = this.getChildById(this.container, + 'beep_embed'); + if (!this.beeper || !this.beeper.Play) { + this.beeper = this.getChildById(this.container, 'beep_bgsound'); - if (!this.beeper || typeof this.beeper.src == 'undefined') { - this.beeper = undefined; + if (!this.beeper || typeof this.beeper.src == 'undefined') { + this.beeper = undefined; + } } } @@ -1441,7 +1447,7 @@ VT100.prototype.toggleUTF = function() { }; VT100.prototype.toggleBell = function() { - this.visibleBell = !this.visibleBell; + this.visualBell = !this.visualBell; }; VT100.prototype.about = function() { @@ -1475,7 +1481,7 @@ VT100.prototype.showContextMenu = function(x, y) { '
  • ' + (this.utfEnabled ? '✔ ' : '') + 'Unicode
  • ' + '
  • ' + - (this.visibleBell ? '✔ ' : '') + 'Visible Bell
  • '+ + (this.visualBell ? '✔ ' : '') + 'Visual Bell'+ '
    ' + '
  • About...
  • ' + '' + @@ -2064,7 +2070,7 @@ VT100.prototype.flashScreen = function() { }; VT100.prototype.beep = function() { - if (this.visibleBell) { + if (this.visualBell) { this.flashScreen(); } else { try {