1#!/bin/sh 2############################################################################### 3## Copyright (c) International Business Machines Corp., 2003 ## 4## ## 5## This program is free software; you can redistribute it and/or modify ## 6## it under the terms of the GNU General Public License as published by ## 7## the Free Software Foundation; either version 2 of the License, or ## 8## (at your option) any later version. ## 9## ## 10## This program is distributed in the hope that it will be useful, ## 11## but WITHOUT ANY WARRANTY; without even the implied warranty of ## 12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ## 13## the GNU General Public License for more details. ## 14## ## 15## You should have received a copy of the GNU General Public License ## 16## along with this program; if not, write to the Free Software Foundation, ## 17## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 18## ## 19############################################################################### 20. daemonlib.sh 21 22do_setup() 23{ 24 export RHOST="localhost" 25 export TEST_USER_PASSWD="eal" 26 export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA" 27 export TEST_USER_HOMEDIR="/home/$TEST_USER" 28 29 tst_test_cmds awk expect ftp useradd userdel vsftpd 30 31 for vsftp_confdir in /etc/vsftpd /etc; do 32 if [ -r "$vsftp_confdir/vsftpd.conf" ]; then 33 VSFTP_CONF="$vsftp_confdir/vsftpd.conf" 34 break 35 fi 36 done 37 if [ ! -r "$VSFTP_CONF" ] ; then 38 tst_brkm TBROK "vsftpd.conf not found." 39 fi 40 41 status_daemon vsftpd 42 if [ $? -ne 0 ]; then 43 start_daemon vsftpd 44 if [ $? -ne 0 ]; then 45 tst_brkm TBROK "Can't start vsftp" 46 fi 47 fi 48 49 LOCAL_ENABLE=$(awk -F= '/^local_enable=/ {print $2}' "$VSFTP_CONF") 50 if [ "$LOCAL_ENABLE" != "YES" ]; then 51 LOCAL_ENABLE="NO" 52 fi 53 54 ANONYMOUS_ENABLE=$(awk -F= '/^anonymous_enable=/ {print $2}' "$VSFTP_CONF") 55 if [ "$ANONYMOUS_ENABLE" != "NO" ]; then 56 ANONYMOUS_ENABLE="YES" 57 fi 58 59 if [ $TEST_USER = "root" -o $TEST_USER = "anonymous" ]; then 60 return 61 fi 62 63 userdel -r $TEST_USER 64 sleep 1 65 66 if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then 67 tst_brkm TBROK "Could not add test user $TEST_USER to system $RHOST." 68 fi 69 70 # create users home diretory (SLES 8 does not do this, even when specified 71 # in adduser) 72 USER_UID=$(id -u $TEST_USER) 73 USER_GID=$(id -g $TEST_USER) 74 mkdir -p "$TEST_USER_HOMEDIR" 75 chown -R $USER_UID:$USER_GID $TEST_USER_HOMEDIR 76} 77 78do_cleanup() 79{ 80 if [ $TEST_USER != "root" -a $TEST_USER != "anonymous" ]; then 81 userdel -r $TEST_USER 82 fi 83} 84