ftp_setup revision d44f013aef9d746bd5d36bb953c1f33ec1133e2c
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 21do_setup() 22{ 23 export RHOST="localhost" 24 export TEST_USER_PASSWD="eal" 25 export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA" 26 export TEST_USER_HOMEDIR="/home/$TEST_USER" 27 28 for vsftp_confdir in /etc/vsftpd /etc; do 29 if [ -r "$vsftp_confdir/vsftpd.conf" ]; then 30 VSFTP_CONF="$vsftp_confdir/vsftpd.conf" 31 break 32 fi 33 done 34 if [ ! -r "$VSFTP_CONF" ] ; then 35 tst_brkm TBROK "vsftpd.conf not found." 36 fi 37 38 LOCAL_ENABLE=$(awk -F= '/^local_enable=/ {print $2}' "$VSFTP_CONF") 39 if [ "$LOCAL_ENABLE" != "YES" ]; then 40 LOCAL_ENABLE="NO" 41 fi 42 43 ANONYMOUS_ENABLE=$(awk -F= '/^anonymous_enable=/ {print $2}' "$VSFTP_CONF") 44 if [ "$ANONYMOUS_ENABLE" != "NO" ]; then 45 ANONYMOUS_ENABLE="YES" 46 fi 47 48 if [ $TEST_USER = "root" -o $TEST_USER = "anonymous" ]; then 49 return 50 fi 51 52 userdel -r $TEST_USER 53 sleep 1 54 55 if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then 56 tst_brkm TBROK "Could not add test user $TEST_USER to system $RHOST." 57 fi 58 59 # create users home diretory (SLES 8 does not do this, even when specified 60 # in adduser) 61 USER_UID=$(id -u $TEST_USER) 62 USER_GID=$(id -g $TEST_USER) 63 mkdir -p "$TEST_USER_HOMEDIR" 64 chown -R $USER_UID:$USER_GID $TEST_USER_HOMEDIR 65} 66 67do_cleanup() 68{ 69 if [ $TEST_USER != "root" -a $TEST_USER != "anonymous" ]; then 70 userdel -r $TEST_USER 71 fi 72} 73