Split run.exp and run.exp2 in separate tests for each
options/combinations.
This commit is contained in:
1
tests/su/02/env_FOO-options_
Symbolic link
1
tests/su/02/env_FOO-options_
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-
Symbolic link
1
tests/su/02/env_FOO-options_-
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_--login
Symbolic link
1
tests/su/02/env_FOO-options_--login
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_--login.exp
Executable file
48
tests/su/02/env_FOO-options_--login.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su --login, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su --login $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be empty"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_--login_bash
Symbolic link
1
tests/su/02/env_FOO-options_--login_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_--preserve-environment
Symbolic link
1
tests/su/02/env_FOO-options_--preserve-environment
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_--preserve-environment.exp
Executable file
48
tests/su/02/env_FOO-options_--preserve-environment.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su --preserve-environment, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_--preserve-environment_bash
Symbolic link
1
tests/su/02/env_FOO-options_--preserve-environment_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-.exp
Executable file
48
tests/su/02/env_FOO-options_-.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su - $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be empty"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-_bash
Symbolic link
1
tests/su/02/env_FOO-options_-_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-l
Symbolic link
1
tests/su/02/env_FOO-options_-l
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-l-m
Symbolic link
1
tests/su/02/env_FOO-options_-l-m
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-l-m.exp
Executable file
48
tests/su/02/env_FOO-options_-l-m.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -l -m, make a login shell, but preserve environment
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -l -m $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-l-m_bash
Symbolic link
1
tests/su/02/env_FOO-options_-l-m_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-l.exp
Executable file
48
tests/su/02/env_FOO-options_-l.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -l, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su - $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be empty"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-l_bash
Symbolic link
1
tests/su/02/env_FOO-options_-l_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-m
Symbolic link
1
tests/su/02/env_FOO-options_-m
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-m.exp
Executable file
48
tests/su/02/env_FOO-options_-m.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-m_bash
Symbolic link
1
tests/su/02/env_FOO-options_-m_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-p
Symbolic link
1
tests/su/02/env_FOO-options_-p
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_FOO-options_-p-
Symbolic link
1
tests/su/02/env_FOO-options_-p-
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-p-.exp
Executable file
48
tests/su/02/env_FOO-options_-p-.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -p -, make a login shell, but preserve environment
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -p $command - myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-p-_bash
Symbolic link
1
tests/su/02/env_FOO-options_-p-_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_-p.exp
Executable file
48
tests/su/02/env_FOO-options_-p.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options_-p_bash
Symbolic link
1
tests/su/02/env_FOO-options_-p_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
48
tests/su/02/env_FOO-options_.exp
Executable file
48
tests/su/02/env_FOO-options_.exp
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su, preserve environment
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su myuser $command\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# FOO should be 'bar'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_FOO-options__bash
Symbolic link
1
tests/su/02/env_FOO-options__bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special-options_
Symbolic link
1
tests/su/02/env_special-options_
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special-options_-l
Symbolic link
1
tests/su/02/env_special-options_-l
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special-options_-l-p
Symbolic link
1
tests/su/02/env_special-options_-l-p
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
55
tests/su/02/env_special-options_-l-p.exp
Executable file
55
tests/su/02/env_special-options_-l-p.exp
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m -l, make a login shell, but preserve environment
|
||||
# However, PATH is not preserved, but set to what it would be with login
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -p $command -l myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/bin:/usr/bin:/bin:/usr/games'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special-options_-l-p_bash
Symbolic link
1
tests/su/02/env_special-options_-l-p_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
54
tests/su/02/env_special-options_-l.exp
Executable file
54
tests/su/02/env_special-options_-l.exp
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -l, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su - $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/bin:/usr/bin:/bin:/usr/games'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/home/'myuser'myuser'/bin/sh'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special-options_-l_bash
Symbolic link
1
tests/su/02/env_special-options_-l_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special-options_-p
Symbolic link
1
tests/su/02/env_special-options_-p
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
56
tests/su/02/env_special-options_-p.exp
Executable file
56
tests/su/02/env_special-options_-p.exp
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect -re "PATH=\"(.*)\"\r" {set PATH $expect_out(1,string)}
|
||||
send_user "PATH='$PATH'"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# PATH should be '$PATH'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"$PATH\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special-options_-p_bash
Symbolic link
1
tests/su/02/env_special-options_-p_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
55
tests/su/02/env_special-options_.exp
Executable file
55
tests/su/02/env_special-options_.exp
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su, preserve environment
|
||||
# However, PATH is reset
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su myuser $command\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/bin:/usr/bin:/bin:/usr/games'"
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/home/'myuser'myuser'/bin/sh'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special-options__bash
Symbolic link
1
tests/su/02/env_special-options__bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special_root-options_
Symbolic link
1
tests/su/02/env_special_root-options_
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special_root-options_-l
Symbolic link
1
tests/su/02/env_special_root-options_-l
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special_root-options_-l-p
Symbolic link
1
tests/su/02/env_special_root-options_-l-p
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
57
tests/su/02/env_special_root-options_-l-p.exp
Executable file
57
tests/su/02/env_special_root-options_-l-p.exp
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -l -p root, make a login shell, but preserve environment
|
||||
# However, PATH is not preserved, but set to what it would be with login
|
||||
# for root
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -p $command - root\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'"
|
||||
send "\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special_root-options_-l-p_bash
Symbolic link
1
tests/su/02/env_special_root-options_-l-p_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
54
tests/su/02/env_special_root-options_-l.exp
Executable file
54
tests/su/02/env_special_root-options_-l.exp
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -l root, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -l root\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'"
|
||||
send "\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special_root-options_-l_bash
Symbolic link
1
tests/su/02/env_special_root-options_-l_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
1
tests/su/02/env_special_root-options_-p
Symbolic link
1
tests/su/02/env_special_root-options_-p
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
56
tests/su/02/env_special_root-options_-p.exp
Executable file
56
tests/su/02/env_special_root-options_-p.exp
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect -re "PATH=\"(.*)\"\r" {set PATH $expect_out(1,string)}
|
||||
send_user "PATH='$PATH'"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -p root, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send_user "\n# PATH should be '$PATH'"
|
||||
send "\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"$PATH\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special_root-options_-p_bash
Symbolic link
1
tests/su/02/env_special_root-options_-p_bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
55
tests/su/02/env_special_root-options_.exp
Executable file
55
tests/su/02/env_special_root-options_.exp
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su to root, preserve environment
|
||||
# However, PATH is reset
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send_user "\n# PATH should be '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'"
|
||||
send "\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
1
tests/su/02/env_special_root-options__bash
Symbolic link
1
tests/su/02/env_special_root-options__bash
Symbolic link
@@ -0,0 +1 @@
|
||||
run_env_test.sh
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
cd $(dirname $0)
|
||||
|
||||
# Rational:
|
||||
# Test that su can be used to switch to root and to a normal account
|
||||
|
||||
# no testsuite password
|
||||
# root password: rootF00barbaz
|
||||
# myuser password: myuserF00barbaz
|
||||
|
||||
save()
|
||||
{
|
||||
[ ! -d tmp ] && mkdir tmp
|
||||
for i in passwd group shadow gshadow
|
||||
do
|
||||
[ -f /etc/$i ] && cp /etc/$i tmp/$i
|
||||
done
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
restore()
|
||||
{
|
||||
for i in passwd group shadow gshadow
|
||||
do
|
||||
[ -f tmp/$i ] && cp tmp/$i /etc/$i && rm tmp/$i
|
||||
done
|
||||
rmdir tmp
|
||||
}
|
||||
|
||||
save
|
||||
|
||||
# restore the files on exit
|
||||
trap 'restore' 0
|
||||
|
||||
cp data/{passwd,shadow,group,gshadow} /etc/
|
||||
|
||||
./run.exp
|
||||
./run.exp "-c bash"
|
||||
./run.exp2
|
||||
./run.exp2 "-c bash"
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export FOO=bar\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su, preserve environment
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su myuser $command\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su - $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m -, make a login shell, but preserve environment
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -p $command - myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"FOO=\\\"\$FOO\\\"\"\r"
|
||||
expect "FOO=\"bar\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
if {$argc == 1} {
|
||||
set command [lindex $argv 0]
|
||||
} else {
|
||||
set command ""
|
||||
}
|
||||
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
send "id\r"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "export PATH=bar:\$PATH\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su, preserve environment
|
||||
# However, PATH is reset
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su myuser $command\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/home/'myuser'myuser'/bin/sh'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su - $command myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/home/'myuser'myuser'/bin/sh'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Regular su to root, preserve environment
|
||||
# However, PATH is reset
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su - root, make a login shell
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command - root\r"
|
||||
expect "# "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=0(root) gid=0(root) groups=0(root)\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "# "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "# "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m, as for regular su, environment is preserved
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su $command -m myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"bar:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# su -m -, make a login shell, but preserve environment
|
||||
# However, PATH is not preserved, but set to what it would be with login
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su -p $command - myuser\r"
|
||||
expect "$ "
|
||||
|
||||
send "id\n"
|
||||
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"PATH=\\\"\$PATH\\\"\"\r"
|
||||
expect "PATH=\"/usr/local/bin:/usr/bin:/bin:/usr/games\"\r"
|
||||
expect "$ "
|
||||
|
||||
send "echo \"'\$HOME'\$USER'\$LOGNAME'\$SHELL'\"\r"
|
||||
expect "'/root'root'root'/bin/bash'\r"
|
||||
expect "$ "
|
||||
|
||||
send "exit\r"
|
||||
expect "# "
|
||||
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
38
tests/su/02/run_env_test.sh
Executable file
38
tests/su/02/run_env_test.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
testname=$(basename $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
command=""
|
||||
|
||||
case "$testname" in
|
||||
*_bash)
|
||||
log_start "$0" "propagation of environment variable FOO in command bash: $testname"
|
||||
testname=$(echo "$testname" | sed -s 's/_bash$//')
|
||||
command="-c bash"
|
||||
echo testname: $testname
|
||||
;;
|
||||
*)
|
||||
log_start "$0" "propagation of environment variable FOO: $test"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
"./$testname.exp" "$command"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
Reference in New Issue
Block a user