1 #!/bin/sh 2 ################################################################################ 3 ## Copyright (c) International Business Machines Corp., 2000 ## 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 21 do_setup() 22 { 23 export RHOST="localhost" 24 export TEST_USER_PASSWD="now_this_is_a_good_ltp_test_password" 25 export TEST_USER_HOMEDIR="/home/$TEST_USER" 26 27 tst_check_cmds expect ssh useradd userdel 28 29 # erase user if he/she already exists, so we can have a clean env 30 do_cleanup 31 sleep 1 32 33 if ! useradd -m -d "$TEST_USER_HOMEDIR" $TEST_USER; then 34 tst_brkm TBROK "Failed to add user $TEST_USER to system $RHOST." 35 fi 36 37 echo "$TEST_USER:$TEST_USER_PASSWD" | chpasswd 38 39 # create users home diretory (SLES 8 does not do this, even when 40 # specified in adduser) 41 if [ ! -d "$TEST_USER_HOMEDIR" ]; then 42 USER_UID=$(id -u $TEST_USER) 43 USER_GID=$(id -g $TEST_USER) 44 if ! mkdir -p "$TEST_USER_HOMEDIR"; then 45 tst_brkm TBROK "Failed to create $TEST_USER_HOMEDIR" 46 fi 47 chown -Rf $USER_UID.$USER_GID "$TEST_USER_HOMEDIR" 48 fi 49 } 50 51 do_cleanup() 52 { 53 userdel -r $TEST_USER 2> /dev/null 54 } 55