#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lftp/sanity
# Description: Basic lftp sanity test
# Author: Jakub Hrozek <jhrozek@redhat.com>
# Modified by: David Kutalek <dkutalek@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2006, 2012 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh
PACKAGE="lftp"
rlJournalStart
rlPhaseStartSetup
rlRun "rlImport selinux-policy/common" 0 "Importing SELinux library"
rlAssertRpm $PACKAGE
rlAssertRpm "expect"
rlAssertRpm "vsftpd"
rlFileBackup "/etc/vsftpd/vsftpd.conf"
if ! rlIsRHEL '<8'; then
# On rhel8 tcp_wrappers are not compiled in.
rlRun "sed -i 's/tcp_wrappers=YES/tcp_wrappers=NO/' vsftpd.conf" 0 "Disable tcp_wrappers"
fi
# User is created in the pyhon script
rlRun "cp -f ./vsftpd.conf /etc/vsftpd/vsftpd.conf"
rlServiceStart "vsftpd"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp ./sanity.py $TmpDir/"
rlRun "pushd $TmpDir"
if rlIsRHEL '<=6'; then
rlRun "rlSEBooleanBackup allow_ftpd_anon_write"
rlRun "rlSEBooleanBackup allow_ftpd_full_access"
rlRun "rlSEBooleanOn allow_ftpd_anon_write"
rlRun "rlSEBooleanOn allow_ftpd_full_access"
else
rlRun "rlSEBooleanBackup ftpd_anon_write"
rlRun "rlSEBooleanBackup ftpd_full_access"
rlRun "rlSEBooleanOn ftpd_anon_write"
rlRun "rlSEBooleanOn ftpd_full_access"
fi
rlPhaseEnd
rlPhaseStartTest
rlRun "python2 sanity.py -v"
rlPhaseEnd
rlPhaseStartCleanup
rlFileRestore
rlServiceRestore "vsftpd"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlRun "rlSEBooleanRestore" 0 "Restoring SELinux booleans"
# If the python script does not finish this deletes the user from the system
rlRun "userdel -rf lftp-tester" 0,6 "Delete lftp-tester user"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd