Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 537290 - net-ftp/vsftpd - /etc/init.d/vsftpd does not handle children generated by vsftpd
Summary: net-ftp/vsftpd - /etc/init.d/vsftpd does not handle children generated by vsftpd
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Markos Chandras (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2015-01-21 21:11 UTC by tom reinertson
Modified: 2015-01-31 13:07 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
vsftpd.init.patch (vsftpd.init.patch,825 bytes, patch)
2015-01-21 21:11 UTC, tom reinertson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tom reinertson 2015-01-21 21:11:43 UTC
Created attachment 394530 [details, diff]
vsftpd.init.patch

vsftpd can generate multiple child processes but the current stop script will only stop the parent task listed in the pid file but none of its children.

it would seem the best solution would be to use pgrep to search for vsftpd processes and placing those pid's into the proper pidfile.  however, start-stop-daemon doesn't seem to support multiple pid's in the pidfile (at least, i couldn't figure out to make it work) so i propose an alternative solution: use start-stop-daemon to kill the parent process listed in the pid file and then use pkill to kill any child processes.

this solution will also work in the instance where no pidfile can be found.  note that the current stop script does not work properly in the no-pidfile case.  it tries to stop all processes with the name $SVCNAME.  however, in the case of multiple virtual ftp servers, $SVCNAME will be of the form vsftpd.server-1 so it will never find any processes (because they are all named vsftpd).

the new code for the stop script is below.  note that this works properly in the normal (default) case where vsftpd is running as a single ftp server, as well as the case where it is running as multiple, virtual ftp servers.

stop() {
    ebegin "Stopping ${SVCNAME}"
    local retval=0
    if [ -f ${VSFTPD_PID} ]; then
        start-stop-daemon --stop --pidfile ${VSFTPD_PID} || retval=1
        pkill --full ${VSFTPD_CONF}
    else
        ewarn "Couldn't find ${VSFTPD_PID} trying to stop using the config filename ${VSFTPD_CONF}"
        pgrep --full ${VSFTPD_CONF} > ${VSFTPD_PID}
        start-stop-daemon --stop --pidfile ${VSFTPD_PID} || retval=1
        pkill --full ${VSFTPD_CONF}
    fi
    eend ${retval}
}
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2015-01-31 13:07:58 UTC
The patch looks good to me. Sadly I have no openrc installation to test it so I just merged it as is. Thanks

+*vsftpd-3.0.2-r4 (31 Jan 2015)
+
+  31 Jan 2015; Markos Chandras <hwoarang@gentoo.org> +vsftpd-3.0.2-r4.ebuild,
+  files/vsftpd.init:
+  Make sure child processes are killed properly. Bug #537290 by rhumbliner
+