summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>2008-01-06 20:34:19 +0000
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>2008-01-06 20:34:19 +0000
commite4d00c832fb8a268ab050dd18214faea66b88c83 (patch)
treee9a8072391f19fa1f71063247b64f5c68d8fa90d
parent4cff2127e3c0ecf561c50800b99a33d48f71a0c9 (diff)
downloadshadow-e4d00c832fb8a268ab050dd18214faea66b88c83.tar.gz
Split run.exp and run.exp2 in separate tests for each
options/combinations.
l---------tests/su/02/env_FOO-options_1
l---------tests/su/02/env_FOO-options_-1
l---------tests/su/02/env_FOO-options_--login1
-rwxr-xr-xtests/su/02/env_FOO-options_--login.exp48
l---------tests/su/02/env_FOO-options_--login_bash1
l---------tests/su/02/env_FOO-options_--preserve-environment1
-rwxr-xr-xtests/su/02/env_FOO-options_--preserve-environment.exp48
l---------tests/su/02/env_FOO-options_--preserve-environment_bash1
-rwxr-xr-xtests/su/02/env_FOO-options_-.exp48
l---------tests/su/02/env_FOO-options_-_bash1
l---------tests/su/02/env_FOO-options_-l1
l---------tests/su/02/env_FOO-options_-l-m1
-rwxr-xr-xtests/su/02/env_FOO-options_-l-m.exp48
l---------tests/su/02/env_FOO-options_-l-m_bash1
-rwxr-xr-xtests/su/02/env_FOO-options_-l.exp48
l---------tests/su/02/env_FOO-options_-l_bash1
l---------tests/su/02/env_FOO-options_-m1
-rwxr-xr-xtests/su/02/env_FOO-options_-m.exp48
l---------tests/su/02/env_FOO-options_-m_bash1
l---------tests/su/02/env_FOO-options_-p1
l---------tests/su/02/env_FOO-options_-p-1
-rwxr-xr-xtests/su/02/env_FOO-options_-p-.exp48
l---------tests/su/02/env_FOO-options_-p-_bash1
-rwxr-xr-xtests/su/02/env_FOO-options_-p.exp48
l---------tests/su/02/env_FOO-options_-p_bash1
-rwxr-xr-xtests/su/02/env_FOO-options_.exp48
l---------tests/su/02/env_FOO-options__bash1
l---------tests/su/02/env_special-options_1
l---------tests/su/02/env_special-options_-l1
l---------tests/su/02/env_special-options_-l-p1
-rwxr-xr-xtests/su/02/env_special-options_-l-p.exp55
l---------tests/su/02/env_special-options_-l-p_bash1
-rwxr-xr-xtests/su/02/env_special-options_-l.exp54
l---------tests/su/02/env_special-options_-l_bash1
l---------tests/su/02/env_special-options_-p1
-rwxr-xr-xtests/su/02/env_special-options_-p.exp56
l---------tests/su/02/env_special-options_-p_bash1
-rwxr-xr-xtests/su/02/env_special-options_.exp55
l---------tests/su/02/env_special-options__bash1
l---------tests/su/02/env_special_root-options_1
l---------tests/su/02/env_special_root-options_-l1
l---------tests/su/02/env_special_root-options_-l-p1
-rwxr-xr-xtests/su/02/env_special_root-options_-l-p.exp57
l---------tests/su/02/env_special_root-options_-l-p_bash1
-rwxr-xr-xtests/su/02/env_special_root-options_-l.exp54
l---------tests/su/02/env_special_root-options_-l_bash1
l---------tests/su/02/env_special_root-options_-p1
-rwxr-xr-xtests/su/02/env_special_root-options_-p.exp56
l---------tests/su/02/env_special_root-options_-p_bash1
-rwxr-xr-xtests/su/02/env_special_root-options_.exp55
l---------tests/su/02/env_special_root-options__bash1
-rwxr-xr-xtests/su/02/run44
-rwxr-xr-xtests/su/02/run.exp103
-rwxr-xr-xtests/su/02/run.exp2168
-rwxr-xr-xtests/su/02/run_env_test.sh38
55 files changed, 946 insertions, 315 deletions
diff --git a/tests/su/02/env_FOO-options_ b/tests/su/02/env_FOO-options_
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_- b/tests/su/02/env_FOO-options_-
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_--login b/tests/su/02/env_FOO-options_--login
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--login
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_--login.exp b/tests/su/02/env_FOO-options_--login.exp
new file mode 100755
index 00000000..8cd7679b
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--login.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_--login_bash b/tests/su/02/env_FOO-options_--login_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--login_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_--preserve-environment b/tests/su/02/env_FOO-options_--preserve-environment
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--preserve-environment
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_--preserve-environment.exp b/tests/su/02/env_FOO-options_--preserve-environment.exp
new file mode 100755
index 00000000..88932bb2
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--preserve-environment.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_--preserve-environment_bash b/tests/su/02/env_FOO-options_--preserve-environment_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_--preserve-environment_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-.exp b/tests/su/02/env_FOO-options_-.exp
new file mode 100755
index 00000000..6ba3e005
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-_bash b/tests/su/02/env_FOO-options_-_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-l b/tests/su/02/env_FOO-options_-l
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-l-m b/tests/su/02/env_FOO-options_-l-m
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l-m
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-l-m.exp b/tests/su/02/env_FOO-options_-l-m.exp
new file mode 100755
index 00000000..8b187a6b
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l-m.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-l-m_bash b/tests/su/02/env_FOO-options_-l-m_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l-m_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-l.exp b/tests/su/02/env_FOO-options_-l.exp
new file mode 100755
index 00000000..a23f8c4d
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-l_bash b/tests/su/02/env_FOO-options_-l_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-l_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-m b/tests/su/02/env_FOO-options_-m
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-m
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-m.exp b/tests/su/02/env_FOO-options_-m.exp
new file mode 100755
index 00000000..061aacb3
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-m.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-m_bash b/tests/su/02/env_FOO-options_-m_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-m_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-p b/tests/su/02/env_FOO-options_-p
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-p- b/tests/su/02/env_FOO-options_-p-
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p-
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-p-.exp b/tests/su/02/env_FOO-options_-p-.exp
new file mode 100755
index 00000000..fc848966
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p-.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-p-_bash b/tests/su/02/env_FOO-options_-p-_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p-_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_-p.exp b/tests/su/02/env_FOO-options_-p.exp
new file mode 100755
index 00000000..061aacb3
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options_-p_bash b/tests/su/02/env_FOO-options_-p_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options_-p_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_FOO-options_.exp b/tests/su/02/env_FOO-options_.exp
new file mode 100755
index 00000000..ff87b2eb
--- /dev/null
+++ b/tests/su/02/env_FOO-options_.exp
@@ -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
+
diff --git a/tests/su/02/env_FOO-options__bash b/tests/su/02/env_FOO-options__bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_FOO-options__bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_ b/tests/su/02/env_special-options_
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-l b/tests/su/02/env_special-options_-l
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-l
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-l-p b/tests/su/02/env_special-options_-l-p
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-l-p
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-l-p.exp b/tests/su/02/env_special-options_-l-p.exp
new file mode 100755
index 00000000..28176157
--- /dev/null
+++ b/tests/su/02/env_special-options_-l-p.exp
@@ -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
+
diff --git a/tests/su/02/env_special-options_-l-p_bash b/tests/su/02/env_special-options_-l-p_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-l-p_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-l.exp b/tests/su/02/env_special-options_-l.exp
new file mode 100755
index 00000000..6f33c234
--- /dev/null
+++ b/tests/su/02/env_special-options_-l.exp
@@ -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
+
diff --git a/tests/su/02/env_special-options_-l_bash b/tests/su/02/env_special-options_-l_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-l_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-p b/tests/su/02/env_special-options_-p
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-p
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_-p.exp b/tests/su/02/env_special-options_-p.exp
new file mode 100755
index 00000000..aaac4973
--- /dev/null
+++ b/tests/su/02/env_special-options_-p.exp
@@ -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
+
diff --git a/tests/su/02/env_special-options_-p_bash b/tests/su/02/env_special-options_-p_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options_-p_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special-options_.exp b/tests/su/02/env_special-options_.exp
new file mode 100755
index 00000000..2865b37c
--- /dev/null
+++ b/tests/su/02/env_special-options_.exp
@@ -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
+
diff --git a/tests/su/02/env_special-options__bash b/tests/su/02/env_special-options__bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special-options__bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_ b/tests/su/02/env_special_root-options_
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-l b/tests/su/02/env_special_root-options_-l
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-l-p b/tests/su/02/env_special_root-options_-l-p
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l-p
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-l-p.exp b/tests/su/02/env_special_root-options_-l-p.exp
new file mode 100755
index 00000000..f94e26f0
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l-p.exp
@@ -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
+
diff --git a/tests/su/02/env_special_root-options_-l-p_bash b/tests/su/02/env_special_root-options_-l-p_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l-p_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-l.exp b/tests/su/02/env_special_root-options_-l.exp
new file mode 100755
index 00000000..6a58849c
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l.exp
@@ -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
+
diff --git a/tests/su/02/env_special_root-options_-l_bash b/tests/su/02/env_special_root-options_-l_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-l_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-p b/tests/su/02/env_special_root-options_-p
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-p
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_-p.exp b/tests/su/02/env_special_root-options_-p.exp
new file mode 100755
index 00000000..e28e58cc
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-p.exp
@@ -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
+
diff --git a/tests/su/02/env_special_root-options_-p_bash b/tests/su/02/env_special_root-options_-p_bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options_-p_bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/env_special_root-options_.exp b/tests/su/02/env_special_root-options_.exp
new file mode 100755
index 00000000..0b86452b
--- /dev/null
+++ b/tests/su/02/env_special_root-options_.exp
@@ -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
+
diff --git a/tests/su/02/env_special_root-options__bash b/tests/su/02/env_special_root-options__bash
new file mode 120000
index 00000000..11a6d1a5
--- /dev/null
+++ b/tests/su/02/env_special_root-options__bash
@@ -0,0 +1 @@
+run_env_test.sh \ No newline at end of file
diff --git a/tests/su/02/run b/tests/su/02/run
deleted file mode 100755
index ed683b56..00000000
--- a/tests/su/02/run
+++ /dev/null
@@ -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"
-
diff --git a/tests/su/02/run.exp b/tests/su/02/run.exp
deleted file mode 100755
index 08d388f8..00000000
--- a/tests/su/02/run.exp
+++ /dev/null
@@ -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
-
diff --git a/tests/su/02/run.exp2 b/tests/su/02/run.exp2
deleted file mode 100755
index f8615d64..00000000
--- a/tests/su/02/run.exp2
+++ /dev/null
@@ -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
-
diff --git a/tests/su/02/run_env_test.sh b/tests/su/02/run_env_test.sh
new file mode 100755
index 00000000..525d6193
--- /dev/null
+++ b/tests/su/02/run_env_test.sh
@@ -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
+