Files
shadow/tests/su/01/run_su
nekral-guest 39beb1da3a 105_zn_CN was just applied to upstream repository.
Tag 104_man-sv, 101_ja, and 103_man-de as going to be fixed in 4.0.18.2.
2007-10-27 12:51:13 +00:00

48 lines
929 B
Plaintext
Executable File

#!/usr/bin/expect
set timeout 2
if {$argc != 3} {
puts "usage: run_su <user> <password> <prompt>"
exit 1
}
set user [lindex $argv 0]
set password [lindex $argv 1]
set prompt [lindex $argv 2]
# First, switch to the testsuite user
# (otherwise, no password will be asked)
spawn /bin/su testsuite
expect "$ " ;# Wait for the prompt
send "id\r" ;# Verify we are really testsuite
expect {
timeout {
puts "\ntimeout...FAIL"
exit 1
}
"uid=424243(testsuite) gid=424243 groups=424243"
}
send "su $user\r" ;# Switch to the user
expect "Password: " ;# Wait for the Password: prompt
# Wait a little bit more (su is not ready to receive the password)
sleep 0.1
send "$password\r" ;# Send the password
expect {
# Wait for the new prompt
"$prompt" {
send "id\r" ;# Verify the id
expect {
-re "\\($user\\).*\\($user\\).*\\($user\\)" {
puts "PASS"
exit 0
}
}
}
}
puts "\ntimeout...FAIL"
exit 1