summaryrefslogtreecommitdiff
path: root/tests/chsh/08_chsh_myuser_to_restricted_shell/run.exp
blob: b1bd8d66c3d614e571c084a68157b78f37581ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/expect

set timeout 5

if {$argc < 1} {
	puts "usage: run.exp \[shell] \[user]"
	exit 1
}
set shell     [lindex $argv 0]

if {$argc == 2} {
	spawn /usr/bin/chsh [lindex $argv 1]
} else {
	spawn /usr/bin/chsh
}

expect "Password: "
send "myuserF00barbaz\r"
expect "Changing the login shell for myuser"
expect "Enter the new value, or press ENTER for the default"
expect -re "Login Shell .*\]: "
send "$shell\r"
expect "$shell\r\n"
expect "chsh: $shell is an invalid shell\r\n"
expect {
	eof {
		if ([string compare $expect_out(buffer) ""]) {
			set fp [open "tmp/out" w]
			puts $fp "$expect_out(buffer)"
			puts "\nFAIL"
			exit 1
		}
	} default {
		puts "\nFAIL"
		exit 1
	}
}

puts "\nPASS"
exit 0