shellinabox / shellinabox

Official-ish Fork of Shell In A Box
https://code.google.com/p/shellinabox/
Other
2.85k stars 459 forks source link

Hangs when SSH-ing into Solaris shells after login #58

Open KLuka opened 9 years ago

KLuka commented 9 years ago

From tmcre...@gmail.com on March 11, 2010 14:45:30

What steps will reproduce the problem? 1. Get shellinabox hosted on a Linux box

  1. Log in to that machine using shellinabox
  2. ssh somesolarisbox.com, authenticate What is the expected output? What do you see instead? I expect to see bash/zsh/whatever on the Solaris box. Instead, the tab/window in my browser seems to stop responding key presses. What version of the product are you using? On what operating system? 2.10-1 on Debian Lenny (i386) from the .deb provided at code.google.com. Please provide any additional information below. I have tried connecting to Solaris 10 and Opensolaris snv111 and snv133 machines using FireFox 3.5, 3.6, Opera 10.10, and Safari 4.

Original issue: http://code.google.com/p/shellinabox/issues/detail?id=58

KLuka commented 9 years ago

From joonas.t...@gmail.com on March 19, 2010 04:44:43

I can also confirm this problem with multiple different systems.

Also Shell in a box will not build on Solaris. So shell in a box will not work in anyway with solaris.

KLuka commented 9 years ago

From jonathan...@gmail.com on June 06, 2011 14:56:08

Maybe it's related to termcap/terminfo and how it's processed by BSD and Solaris? I know a lot of older systems complain about something as common as TERM=rxvt-unicode, so maybe changing the value of shellinabox's $TERM would fix it?

KLuka commented 9 years ago

From ian.hoog...@gmail.com on December 09, 2011 04:00:33

After connection from Linux (OEL6) to Solaris (11) and no output is given, the commands are processed! When you issue 'exit' right after login to Solaris, the output is 'Connection to w.x.y.z closed.' (probably more will work to...)

SSH-ing with putty from Linux to Solaris works, so it seems only the processing off output from Solaris.

KLuka commented 9 years ago

From ja...@ring.gs on February 06, 2012 15:54:33

Has there been any movement on this bug?

I can confirm this bug exists with Shellinabox running on Debian 6 and CentOS 6 when connecting to a Solaris 10 host. Problem exists if the shellinabox service is LOGIN or SSH.

KLuka commented 9 years ago

From ja...@ring.gs on February 06, 2012 16:26:13

Additionally, if Shellinabox is configured to SSH directly to a Solaris host, ala -s /:SSH:solaris.host.net it also fails. (same behaviour as if logging into a Linux host and then ssh'ing to the Solaris host)

From my investigations I think it may be todo with the way Shellinabox does STDIN/STDOUT redirection. But I havent looked too deeply at the source code.

KLuka commented 9 years ago

From ja...@ring.gs on February 06, 2012 22:35:40

Further, telnet to a Solaris 11 host works fine.

KLuka commented 9 years ago

From ja...@ring.gs on February 12, 2012 13:22:55

Further. Running a telnet server on the Linux based Shellinabox server, and telnetting to localhost then SSH'ing to a Solaris host works fine.

As a stop gap, anyone else experiencing this bug may try this if your local security policy allows it:

Run a telnet server on localhost Setup shellinabox to run telnet localhost as an unprivileged user rather than /bin/login

KLuka commented 9 years ago

From valerio....@gmail.com on March 06, 2012 05:05:15

We use this work-around to make it works

I hope this information could help someone (this problem make us crazy)

KLuka commented 9 years ago

From storm...@yahoo.com on September 06, 2012 15:57:43

I figured out the solution for this bug. If you login to Linux and run stty, the terminal speed is 0. Linux accepts this, but Solaris takes a baud speed of 0 literally and sends/receives no characters (hangs).

There are problems with launcher.c. First of all, the usage of cfsetispeed/cfsetospeed() is dubious. The second argument requires a type speed_t, which is not just a standard integer. These are #defined macros. So instead of 38400, we really want B38400 (which does not expand to the integer 38400 by the way).

Secondly, the calls to cfset*speed() aren't working as expected at all. The only way I could get the terminal speed set properly was to include "| B38400" in the tt.c_cflag list. Once the terminal speed is set to something sane like 38400, running stty after login to a Linux box should also show this speed. And thus when connecting to Solaris, it will in turn get that speed as well. And the hang should go away.

Finally (unrelated to this bug), Solaris 10 doesn't like ^? for the backspace key. The default on Solaris 10 is ^H. So this patch also includes a fix for that, but only for launcher.c. I believe more needs to be done with vt100.jspp before ^H works properly. An improvement would be a way to toggle this in configure so it hits all necessary files. Not everyone uses Linux exclusively and not everyone agrees that ^? should be backspace. I know it's easy to fix with stty, but a Solaris (or even HP-UX) shop typically likes to use ^H across the board. Feel free to remove the VERASE portion of the patch if you do not want this.

Patch:

--- shellinabox-2.14/shellinabox/launcher.c.orig 2012-08-18 00:49:59.816968852 -0400
+++ shellinabox-2.14/shellinabox/launcher.c 2012-08-27 18:56:12.966625229 -0400
@@ -1479,13 +1480,14 @@
// Set initial terminal settings
struct termios tt = { 0 };
tcgetattr(0, &tt);
- cfsetispeed(&tt, 38400);
- cfsetospeed(&tt, 38400);
+ cfsetispeed(&tt, B38400);
+ cfsetospeed(&tt, B38400);
tt.c_iflag = TTYDEF_IFLAG & ~ISTRIP;
tt.c_oflag = TTYDEF_OFLAG;
tt.c_lflag = TTYDEF_LFLAG;
- tt.c_cflag = (TTYDEF_CFLAG & ~(CS7|PARENB|HUPCL)) | CS8;
- tt.c_cc[VERASE] = '\x7F';
+ tt.c_cflag = (TTYDEF_CFLAG & ~(CS7|PARENB|HUPCL)) | CS8 | B38400;
+ //tt.c_cc[VERASE] = '\x7F';
+ tt.c_cc[VERASE] = '\x08';
tcsetattr(0, TCSAFLUSH, &tt);

// Assert root privileges in order to update utmp entry.
KLuka commented 9 years ago

From afteixe...@gmail.com on January 22, 2013 12:02:37

Very much thanks for this solution!

Works like a charm! :)

KLuka commented 9 years ago

From beewoo...@gmail.com on November 28, 2013 11:19:26

The patch as given doesn't look right for inclusion. According to the termios man page, the inclusion of B38400 in the c_cflag is not POSIX. If someone who can test this is able to include

cfsetspeed(&tt, B38400)

and observe that it solves the Solaris hang then I'll include it in an update.

BTW, the ^H/DEL change isn't likely to make everyone happy. I'm pretty sure you can work around this by changing the local terminal settings for the Solaris session.

KLuka commented 9 years ago

From ja...@ring.gs on November 28, 2013 11:47:20

We've had both of those fixes (cfsetspeed and the ^H/DEL one) in production for a year or so now without any observed issues accessing Solaris 10 and EL5/EL6 hosts.