Show the real host name in the SSH password prompt, if available.
Add some commented-out debugging helpers for tracking down problems with non-US keyboards.
#define STDC_HEADERS 1
/* Most recent revision number in the version control system */
-#define VCS_REVISION "163"
+#define VCS_REVISION "164"
/* Version number of package */
#define VERSION "2.9"
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-VCS_REVISION=163
+VCS_REVISION=164
cat >>confdefs.h <<_ACEOF
dnl This is the one location where the authoritative version number is stored
AC_INIT(shellinabox, 2.9, markus@shellinabox.com)
-VCS_REVISION=163
+VCS_REVISION=164
AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system])
};
VT100.prototype.about = function() {
- alert("VT100 Terminal Emulator " + "2.9 (revision 163)" +
+ alert("VT100 Terminal Emulator " + "2.9 (revision 164)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com");
};
}
if (this.menu.style.visibility == 'hidden') {
+ // this.vt100('R: c=');
+ // for (var i = 0; i < ch.length; i++)
+ // this.vt100((i != 0 ? ', ' : '') + ch.charCodeAt(i));
+ // this.vt100('\r\n');
this.keysPressed(ch);
}
};
};
VT100.prototype.keyDown = function(event) {
+ // this.vt100('D: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
this.checkComposedKeys(event);
this.lastKeyPressedEvent = undefined;
this.lastKeyDownEvent = undefined;
};
VT100.prototype.keyPressed = function(event) {
+ // this.vt100('P: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyDownEvent) {
// If we already processed the key on keydown, do not process it
// again here. Ideally, the browser should not even have generated a
};
VT100.prototype.keyUp = function(event) {
+ // this.vt100('U: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyPressedEvent) {
// The compose key on Linux occasionally confuses the browser and keeps
// inserting bogus characters into the input field, even if just a regular
check(!uname(&uts));
hostname = uts.nodename;
}
+ const char *fqdn;
+ check(fqdn = strdup(hostname));
check(hostname = strdup(hostname));
char *dot = strchr(hostname, '.');
if (dot) {
char *user = NULL;
char *prompt;
check(prompt = stringPrintf(NULL, "%s login: ", hostname));
- if (read_string(1, prompt, &user) <= 0) {
+ for (;;) {
+ if (read_string(1, prompt, &user) <= 0) {
+ free(user);
+ free(prompt);
+ _exit(1);
+ }
+ if (*user) {
+ for (char *u = user; *u; u++) {
+ char ch = *u;
+ if (!((ch >= '0' && ch <= '9') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z') ||
+ ch == '-' || ch == '_' || ch == '.')) {
+ goto invalid_user_name;
+ }
+ }
+ break;
+ }
+ invalid_user_name:
free(user);
- free(prompt);
- _exit(1);
+ user = NULL;
}
free(prompt);
char *cmdline = stringPrintf(NULL, service->cmdline, user);
free(user);
+
+ // Replace '@localhost' with the actual host name. This results in a nicer
+ // prompt when SSH asks for the password.
+ char *ptr = strrchr(cmdline, '@');
+ if (!strcmp(ptr + 1, "localhost")) {
+ int offset = ptr + 1 - cmdline;
+ check(cmdline = realloc(cmdline,
+ strlen(cmdline) + strlen(fqdn) -
+ strlen("localhost") + 1));
+ ptr = cmdline + offset;
+ *ptr = '\000';
+ strncat(ptr, fqdn, strlen(fqdn));
+ }
+
free((void *)service->cmdline);
service->cmdline = cmdline;
pw = getPWEnt(service->uid);
#endif
}
+ free((void *)fqdn);
free((void *)hostname);
if (restricted &&
free(ptr);
}
}
+
+ // Don't allow manipulation of the SSH command line through "creative" use
+ // of the host name.
+ for (char *h = host; *h; h++) {
+ char ch = *h;
+ if (!((ch >= '0' && ch <= '9') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z') ||
+ ch == '-' || ch == '.')) {
+ fatal("Invalid hostname \"%s\" in service definition", host);
+ }
+ }
+
service->cmdline = stringPrintf(NULL,
"ssh -a -e none -i /dev/null -x -oChallengeResponseAuthentication=no "
"-oCheckHostIP=no -oClearAllForwardings=yes -oCompression=no "
};
ShellInABox.prototype.about = function() {
- alert("Shell In A Box version " + "2.9 (revision 163)" +
+ alert("Shell In A Box version " + "2.9 (revision 164)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com" +
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
};
VT100.prototype.about = function() {
- alert("VT100 Terminal Emulator " + "2.9 (revision 163)" +
+ alert("VT100 Terminal Emulator " + "2.9 (revision 164)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com");
};
}
if (this.menu.style.visibility == 'hidden') {
+ // this.vt100('R: c=');
+ // for (var i = 0; i < ch.length; i++)
+ // this.vt100((i != 0 ? ', ' : '') + ch.charCodeAt(i));
+ // this.vt100('\r\n');
this.keysPressed(ch);
}
};
};
VT100.prototype.keyDown = function(event) {
+ // this.vt100('D: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
this.checkComposedKeys(event);
this.lastKeyPressedEvent = undefined;
this.lastKeyDownEvent = undefined;
};
VT100.prototype.keyPressed = function(event) {
+ // this.vt100('P: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyDownEvent) {
// If we already processed the key on keydown, do not process it
// again here. Ideally, the browser should not even have generated a
};
VT100.prototype.keyUp = function(event) {
+ // this.vt100('U: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyPressedEvent) {
// The compose key on Linux occasionally confuses the browser and keeps
// inserting bogus characters into the input field, even if just a regular
}
if (this.menu.style.visibility == 'hidden') {
+ // this.vt100('R: c=');
+ // for (var i = 0; i < ch.length; i++)
+ // this.vt100((i != 0 ? ', ' : '') + ch.charCodeAt(i));
+ // this.vt100('\r\n');
this.keysPressed(ch);
}
};
};
VT100.prototype.keyDown = function(event) {
+ // this.vt100('D: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
this.checkComposedKeys(event);
this.lastKeyPressedEvent = undefined;
this.lastKeyDownEvent = undefined;
};
VT100.prototype.keyPressed = function(event) {
+ // this.vt100('P: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyDownEvent) {
// If we already processed the key on keydown, do not process it
// again here. Ideally, the browser should not even have generated a
};
VT100.prototype.keyUp = function(event) {
+ // this.vt100('U: c=' + event.charCode + ', k=' + event.keyCode +
+ // (event.shiftKey || event.ctrlKey || event.altKey ||
+ // event.metaKey ? ', ' +
+ // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
+ // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
+ // '\r\n');
if (this.lastKeyPressedEvent) {
// The compose key on Linux occasionally confuses the browser and keeps
// inserting bogus characters into the input field, even if just a regular