GNOME Bugzilla – Bug 644432
Use Host As SSH Tunnel Option Fails With Error
Last modified: 2021-05-26 09:25:50 UTC
I am running vinagre 2.30.3-1ubuntu2 on a development release of Ubuntu 11.04. When attempting to connect while using the Use Host As SSH Tunnel option, I get a dialog window which contains "Error creating the SSH tunnel" followed by "Error reading from unix: Input/output error".
Also in Ubuntu 11.05 final release and Fedora 13 on. It used to be intermittent, now it never works. The entry by Martin Wilck on the Fedore bug 645913 has a good description of the bug. https://bugzilla.redhat.com/show_bug.cgi?id=645913#c3 ie: What vinagre actually does in pty_open is like this: 1. obtain a pty, 2. fork(), 3. child fork()s again abd terminates, 4. grandchild calls setsid(), detaching from terminal, 5. opens the pty fd and issues TIOCSCTTY on it. This attaches the grandchild to a new controlling terminal, 6. exec ssh, 7. fork again (because of "-f") and terminate parent This causes the great-grandchild to receive SIGHUP as now there is a controlling terminal, and the session leader has terminated. This is clearly broken. It is probably a matter of timing whether the SIGHUP arrives after ssh blocked it or before. In the former case, the connection succeeds, in the latter case, we get "Error reading from Unix: Input/output error".
Hi! I can confirm that bug is still present in version 3.0.1. Bye!
Created attachment 197838 [details] strace of Vinagre 3.2.0 reproducing the "Input/output error" message
I think there is a second cause of this error other than the SIGHUP issue that Martin Wilck's found. On my machine (running Ubuntu 11.04), I immediately get the "Error reading from unix: Input/output error" message when trying to connect, before even seeing a login prompt, so ssh would not even have forked into the background yet. strace also does not show any processes dying from SIGHUP until the end when I exit the program. It behaves the same in both 2.30.2 and 3.2.0. The error seems to be coming from an EIO well before the ssh process even writes the login prompt to its terminal. The EIO is from a read() on the pseudo-terminal master. The read happens in response to select() returning with the pseudo-terminal master in the readable set. And that happens right after a close() of the pseudo-terminal slave fd in the ssh process (which was left open by vinagre before the exec). You can also see that ssh was in the process of enumerating its open file descriptors. So I think probably ssh is closing all file descriptors other than 0, 1, and 2. This causes it to close the pseudo-terminal slave that vinagre opened and for some reason the Linux pseudo-terminal implementation considers it an error that there is no longer any open fd for the slave, despite the fact that it is still the controlling terminal of the ssh process. I have attached the full strace of 3.2.0.
I experimented with keeping the slave end open in the vinagre process and it makes everything work for me. No SIGHUPs. I will work on a patch.
Actually, I think there are two unrelated bugs at play here: 1) The problem with ssh closing the slave, which I described above and which repros 100% of the time. This happens before even getting the login prompt. 2) The problem with SIGHUPs, which is described at https://bugzilla.redhat.com/show_bug.cgi?id=645913 and repros sporadically. This happens after the login prompt. I say this because even after fixing #1 I sometimes get an "Input/output error" after entering my login password, so probably that is the SIGHUPs issue. Still planning to submit a patch for #1 once I have the time.
Created attachment 199092 [details] [review] Patch to fix the bug where read() on the ssh PTY master fails with EIO due to ssh closing the inherited PTY slave before opening /dev/tty Here's my fix for the main issue. With this patch, SSH tunneling works most of the time. (The SIGHUP problem is separate and still occurs occasionally.)
Comment on attachment 199092 [details] [review] Patch to fix the bug where read() on the ssh PTY master fails with EIO due to ssh closing the inherited PTY slave before opening /dev/tty Pushed to gnome-3-2 and master as commits 642858f2bd8d4ba82c628fd80fc75a8b1e591033 and 9001d60fab1057057e995d323ef6fffcc9dfa082. Thanks for the detailed explanation of the problem. I will leave this bug open until there is a solution for the other issue, but at least the failures are less frequent now.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version of Vinagre, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new enhancement request ticket at https://gitlab.gnome.org/GNOME/vinagre/-/issues/ Thank you for your understanding and your help.