This commit is contained in:
Ondrej Mejzlik 2025-05-14 12:55:48 +02:00
commit e05400b503

View file

@ -0,0 +1,76 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lftp/RHEL-88955-tls-close
# Description: previously lftp did not properly close TLS session and broke file uploads
# Author: Tomas Korbar <tkorbar@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2025 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES=${PACKAGES:-lftp}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm 'lftp' || rlDie "lftp not installed"
rlAssertRpm 'vsftpd' || rlDie "vsftpd not installed"
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlRun "set -o pipefail"
rlFileBackup /etc/vsftpd/vsftpd.conf /etc/lftp.conf
rlRun 'useradd -p "$(openssl passwd -1 testing)" testing'
# for some reason 43277 was able to trigger this problem most reliably
rlRun "dd if=/dev/urandom of=mockscrubbed bs=43277 count=1"
rlRun "openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -sha256 -days 365 -subj '/C=US/CN=localhost'" 0 "Generate certificate key pair"
rlRun "printf '
rsa_cert_file=$tmp/cert.pem
rsa_private_key_file=$tmp/key.pem
ssl_enable=YES
allow_anon_ssl=YES
ssl_tlsv1=YES
require_ssl_reuse=NO
debug_ssl=YES
anon_root=/srv/ftp
dual_log_enable=YES' >> /etc/vsftpd/vsftpd.conf" 0 "Configuring vsftpd"
rlServiceStart vsftpd
# lowering the socket buffer size to 4096 bytes increases risk of this issue
# manifesting, because the buffer will be more often full and lftp will have
# to wait until there is enough space for close-notify alert of TLS protocol
rlRun "printf 'set ssl:verify-certificate off\nset net:socket-buffer 4096\n' >> /etc/lftp.conf" 0 "Turning off certificate verification"
rlPhaseEnd
rlPhaseStartTest
for i in {1..10}; do
rlRun "rlWatchdog \"lftp -d -e 'put mockscrubbed; quit' -u 'testing,testing' localhost\" 5" 0 "Uploading file"
done
rlPhaseEnd
rlPhaseStartCleanup
rlFileRestore
rlServiceRestore vsftpd
rlRun "userdel testing -r"
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd