Bug 1590541

Summary: chrooted vsftpd child processes are not killed by "service vsftpd stop"
Product: Red Hat Enterprise Linux 7 Reporter: Richard D Alloway <ralloway>
Component: vsftpdAssignee: Ondřej Lysoněk <olysonek>
Status: CLOSED WONTFIX QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-13 12:17:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch redefines __pids_pidsof() to catch chroot'd processes none

Description Richard D Alloway 2018-06-12 19:57:18 UTC
(I am duplicating the CentOS ticket here with the bug reporters details)

Description of problem:
After a client connects to vsftpd it spawns 2 child processes. One of these processes (that owns control connection) chroots to secure_chroot_dir from vsftpd.conf (/usr/share/empty by default) and another one may chroot to /var/ftp or to user's home dir (depending on vsftpd.conf).

If we try to stop vsftpd when client is connected, then chrooted childs of vsftpd are not killed, because they are not selected by __pids_pidof() function from /etc/rc.d/init.d/functions


Version-Release number of selected component (if applicable):
vsftpd-3.0.2-22

How reproducible:
always

Steps to Reproduce:
1. Install and start vsftpd
2. Connect to it as anonymous user
3. Issue command 'service vsftpd stop'

Actual results:
Child processes are not killed. Client is still connected and can continue normal work!

Expected results:
All processes, including child processes, should be stopped.

Additional info:

Comment 2 Richard D Alloway 2018-06-12 19:59:42 UTC
Created attachment 1450642 [details]
Patch redefines __pids_pidsof() to catch chroot'd processes

Comment 3 Richard D Alloway 2018-06-12 20:01:10 UTC
Attached is a patch for the source RPM which redefines the __pids_pidof() function  from /etc/rc.d/init.d/functions locally within SOURCES/vsftpd.init to catch chroot'd procs.  This redefinition would work in any init script for processes which have chroot'd processes.

-Rich Alloway (Rogue Wave)

Comment 4 Ondřej Lysoněk 2018-06-13 12:17:41 UTC
I don't think that doing this is wise. We shouldn't just kill all FTP sessions whenever vsftpd is stopped - in the worst case, they can be in the middle of a file transfer. Also, the vsftpd service is restarted when vsftpd is upgraded (just like any service following the guildelines). I don't think we should just kill off all FTP sessions when vsftpd is upgraded. I think that killing FTP sessions should be an explicit choice of the admin.

FWIW, this behaviour is not specific to vsftpd. For example, if you stop sshd, existing ssh sessions will continue to run.