Bug 1570

Summary: Incorrect return code if mux master has completed
Product: Portable OpenSSH Reporter: Peter Oliver <peter.oliver>
Component: sshAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: minor CC: djm
Priority: P2    
Version: 5.2p1   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 1626    
Attachments:
Description Flags
vs 5.2p1 - Don't recycle channel id 0
none
prefer to dispatch exit statuses via mux control fd dtucker: ok+

Description Peter Oliver 2009-03-11 00:12:17 AEDT
When a control master is running because it still has clients, but the command that that master originally ran has already exited, a client will incorrectly exit 255.  It will otherwise work correctly.

> cat ~/.ssh/config
ControlMaster   auto
ControlPath     ~/.ssh/mux/%r@%h:%p
> ssh -f remote-host sleep 60
Password: 
> ssh -n remote-host sleep 300 &
[3] 9166
> ssh -vv remote-host date
OpenSSH_5.1p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/xxx/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: auto-mux: Trying existing master
Tue Mar 10 12:31:01 GMT 2009
debug2: Received EOF from master
debug2: Received exit status from master 0
> echo $?
0
> sleep 60
> ssh -vv remote-host date
OpenSSH_5.1p1, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/xxx/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: auto-mux: Trying existing master
Tue Mar 10 12:32:14 GMT 2009
debug2: Received EOF from master
debug2: Control master terminated unexpectedly
> echo $?
255
Comment 1 Peter Oliver 2009-03-14 04:34:46 AEDT
Created attachment 1617 [details]
vs 5.2p1 - Don't recycle channel id 0

The attached patch prevents channel id 0 from being reused.  This causes client_input_channel_req to correctly forward the exit value to the mux client.
Comment 2 Damien Miller 2009-11-10 13:48:02 AEDT
Created attachment 1719 [details]
prefer to dispatch exit statuses via mux control fd

I think this approach is better: this implicitly identifies mux channels that have recycled the initial session ID by preferring to dispatch exit statuses via ones that have a control FD (i.e. mux channels) to ones that don't (i.e. the initial session).
Comment 3 Damien Miller 2009-11-10 13:48:19 AEDT
Put this on the list for openssh-5.4
Comment 4 Damien Miller 2009-11-17 16:32:16 AEDT
patch applied. The fix will be in OpenSSH 5.4 - thanks for the detailed report.
Comment 5 Darren Tucker 2010-03-26 10:51:15 AEDT
With the release of 5.4p1, this bug is now considered closed.