| Summary: | Sftp hangs if stderr is used. | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | Portable OpenSSH | Reporter: | jchadima | ||||||||
| Component: | sshd | Assignee: | Assigned to nobody <unassigned-bugs> | ||||||||
| Status: | CLOSED FIXED | ||||||||||
| Severity: | major | CC: | djm, jchadima, mortals | ||||||||
| Priority: | P2 | ||||||||||
| Version: | 5.4p1 | ||||||||||
| Hardware: | Other | ||||||||||
| OS: | All | ||||||||||
| Bug Depends on: | |||||||||||
| Bug Blocks: | 1708 | ||||||||||
| Attachments: |
|
||||||||||
|
Description
jchadima
2010-04-08 20:02:36 AEST
When you say "session.c before version 1.237" do you mean that 1.237 is affected? Also, are you using the version from portable OpenSSH CVS or from OpenBSD CVS? (In reply to comment #1) > When you say "session.c before version 1.237" do you mean that 1.237 is > affected? yes all versions from 1.237 are affected, all older aren't Also, are you using the version from portable OpenSSH CVS or > from OpenBSD CVS? portable openssh. The problem is in this chunk of the patch: @@ -507,6 +507,10 @@ */ if (compat20) { session_set_fds(s, inout[1], inout[1], s->is_subsystem ? -1 : err[1]); + /* close err[1] to not leak the socket if this inside a subsystem */ + if (s->is_subsystem) { + close(err[1]); + } } else { server_loop(pid, inout[1], inout[1], err[1]); /* server_loop has closed inout[1] and err[1]. */ and another one for pipes also. the stderr is closed and any attempt to write to it causes the hang. Created attachment 1840 [details]
session-subsys-stderr-devnull.diff
set stderr to /dev/null for subsystems
This should fix it. patch applied - will be in 5.6. Thanks! This solutions is not 100% correct because breaks the chroot environment with internal-sftp. Typical setup:
subsystem sftp internal-sftp
match group sftponly
chroot directory /home/%u
x11forwarding no
allowtcpforwarding no
forcecommand internal-sftp
the /home/%u directories are root owned with some subdirs owned by an user, but there should not be the copy of dev directory inside.
The patch wants to have at least /dev/null inside the chroot.
The possible sollution is to open /dev/null before chroot. Created attachment 1884 [details]
/home/djm/sshd-ignore-subsys-stderr.diff
Ignore stderr from subsystems in channels code (warning: completely untested diff)
Seems to be working for me, thx. Created attachment 1885 [details]
/home/djm/sshd-ignore-subsys-stderr.diff
improved patch
patch applied - will be in 5.6. Thanks. *** Bug 1755 has been marked as a duplicate of this bug. *** Move resolved bugs to CLOSED after 5.7 release |