ssh03 revision 4548c6cf9bcdd96d8303caa4130ab638b61f8a30
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 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# FILE : ssh 20# 21# PURPOSE: Tests to see that ssh allows a valid username (non-root) 22# 23# SETUP: The program `/usr/bin/expect' MUST be installed. 24# 25# HISTORY: 26# 03/03 Jerone Young (jeroney@us.ibm.com) 27# 28 29#----------------------------------------------------------------------- 30# FUNCTION: do_setup 31#----------------------------------------------------------------------- 32 33do_setup() 34{ 35 export RHOST="localhost" 36 export TEST_USER="ssh_usr3" 37 export TEST_USER_PASSWD="eal" 38 export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA" 39 export TEST_USER_HOMEDIR="/home/$TEST_USER" 40 41 # erase user if he/she already exists, so we can have a clean env 42 TCtmp=/home/$TEST_USER 43 44 rm -Rf $TCtmp 45 46 tst_setup 47 48 exists expect ssh ssh03_s1 useradd userdel 49 50 userdel $TEST_USER 51 sleep 1 52 53 if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then 54 end_testcase "Could not add test user $TEST_USER to system $RHOST." 55 fi 56 57 # create users home diretory (SLES 8 does not do this, even when specified 58 # in adduser) 59 USER_UID=$(id -u $TEST_USER) 60 USER_GID=$(id -g $TEST_USER) 61 if ! mkdir -p "$TEST_USER_HOMEDIR"; then 62 end_testcase "Failed to create $TEST_USER_HOMEDIR" 63 fi 64 chown -R $USER_UID.$USER_GID "$TEST_USER_HOMEDIR" 65 66 trap do_cleanup EXIT 67 68} 69 70#----------------------------------------------------------------------- 71# FUNCTION: do_cleanup 72#----------------------------------------------------------------------- 73 74do_cleanup() 75{ 76 userdel $TEST_USER 77 tst_cleanup 78} 79 80#----------------------------------------------------------------------- 81# FUNCTION: MAIN 82# 83# DESCRIPTION: Create Test User 84# Call upon script to make sure an invalid user can not have access 85# Cleanup Test User from system 86# Exit with exit code of script called upon 87#----------------------------------------------------------------------- 88. net_cmdlib.sh 89 90read_opts $* 91do_setup 92ssh03_s1 || end_testcase "Testcase failed" 93do_cleanup 94