Bug 1566

Summary: superfluous descriptor duplications in sftp-server
Product: Portable OpenSSH Reporter: Jan Pechanec <Jan.Pechanec>
Component: sftp-serverAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: djm
Priority: P3    
Version: 5.2p1   
Hardware: All   
OS: Solaris   
Bug Depends on:    
Bug Blocks: 1626    
Attachments:
Description Flags
suggested patch none

Description Jan Pechanec 2009-03-05 01:31:32 AEDT
Created attachment 1609 [details]
suggested patch

pfiles on running sftp-server shows:

   ...
   ...
   3: S_IFIFO mode:0000 dev:329,0 ino:91352 uid:0 gid:0 size:0
      O_RDWR
   4: S_IFIFO mode:0000 dev:329,0 ino:91353 uid:0 gid:0 size:0
      O_RDWR

those descriptors are created by 2 dup() calls on STD(IN|OUT)_FILENO. However, there is no need for that and sftp-server can work directly with 0 and 1. I see that this code came with the 1st sftp-server implementation in version 2.3.0p1 and hasn't change since then. Even the Cygwin code that follows those dup()'s and which looks like it might need those came long after that. After the attached patch was applied, the full output of pfiles follows and there is no regression.

   0: S_IFIFO mode:0000 dev:340,0 ino:1570 uid:0 gid:0 size:0
      O_RDWR
   1: S_IFIFO mode:0000 dev:340,0 ino:1571 uid:0 gid:0 size:0
      O_RDWR
   2: S_IFIFO mode:0000 dev:340,0 ino:1572 uid:0 gid:0 size:0
      O_RDWR

the "make tests" passed all tests.
Comment 1 Damien Miller 2010-01-04 13:25:38 AEDT
committed - will be in openssh-5.4. Thanks
Comment 2 Darren Tucker 2010-03-26 10:52:11 AEDT
With the release of 5.4p1, this bug is now considered closed.