Bug 1566 - superfluous descriptor duplications in sftp-server
Summary: superfluous descriptor duplications in sftp-server
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 5.2p1
Hardware: All Solaris
: P3 normal
Assignee: Assigned to nobody
Depends on:
Blocks: V_5_4
  Show dependency treegraph
Reported: 2009-03-05 01:31 EST by Jan Pechanec
Modified: 2010-03-26 10:52 EST (History)
1 user (show)

See Also:

suggested patch (1.89 KB, patch)
2009-03-05 01:31 EST, Jan Pechanec
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Pechanec 2009-03-05 01:31:32 EST
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
   4: S_IFIFO mode:0000 dev:329,0 ino:91353 uid:0 gid:0 size:0

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
   1: S_IFIFO mode:0000 dev:340,0 ino:1571 uid:0 gid:0 size:0
   2: S_IFIFO mode:0000 dev:340,0 ino:1572 uid:0 gid:0 size:0

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