Skip to content

Commit

Permalink
Fix the timing issue of vsftpd during boot (probably invalid config)
Browse files Browse the repository at this point in the history
This appears to be a timing issue of vsftpd's initial script
(/etc/init.d/vsftpd). When starting the vsftpd service, the script uses
a while loop to make sure that the vsftpd process has been created with
the expected PID. The problem is that it should sleep if it can't grep
the same PID via ps command.

while [ ${n} -le 5 ]
do
    _PID="$(if [ -e ...vsftpd.pid ]; then cat ...vsftpd.pid; fi)"
    if ! ps -C vsftpd | grep -qs "${_PID}"
        then
            break
    fi
    sleep 1
    n=$(( $n + 1 ))
done

if ! ps -C vsftpd | grep -qs "${_PID}"
then
    log_warning_msg "vsftpd failed - probably invalid config."
    exit 1
fi

However, synchronization based on time is not working in general. This
change will rewrite the while loop to an infinite loop and remove the
exclamation symbol (!) from the if condition.

Upgrading the version of vsftpd is not helpful here because
vsftpd_3.0.3-11 (Ubuntu 18.10) didn't resolve it yet.

Change-Id: I07382709c33bd9bab61fcea76ab7deca5f630084
Reviewed-by: Jędrzej Nowacki <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
ryanjh committed Jan 16, 2019
1 parent 2c875ef commit fe29a6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/testserver/vsftpd/vsftpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ useradd -d "/home/$USER/ftp" -s /bin/bash ftptest; echo "ftptest:$PASS" | chpass
cp $TESTDATA/vsftpd.{conf,user_list} /etc/

# Resolve error message "vsftpd failed - probably invalid config" during boot
command='start-stop-daemon --start --background -m --oknodo --pidfile /var/run/vsftpd/vsftpd.pid'
command+=' --exec ${DAEMON}'
sed -i "s,$command.*$,$command; sleep 10," /etc/init.d/vsftpd
# This bug has been reported to Debian bug tracking system (ID #911396)
command='ps -C vsftpd | grep -qs "${_PID}"'
sed -i -e 's,while [ ${n} -le 5 ].*$,while true,' \
-e "s,\t\t\tif ! $command.*$,\t\t\tif $command," /etc/init.d/vsftpd

# Populate the FTP sites:
su $USER -c "cp -r $TESTDATA/ftp ~/ftp"
Expand Down

0 comments on commit fe29a6a

Please sign in to comment.