aboutsummaryrefslogtreecommitdiffstats
path: root/chapter08
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@mengyan1223.wang>2021-07-20 18:24:26 +0800
committerXi Ruoyao <xry111@mengyan1223.wang>2021-07-20 18:24:26 +0800
commit908a3c34c998a42c4bb5bcebf179c85ce62c7f59 (patch)
tree11ffb7aa82a21867ba22c0ccf368b2d26fde0c22 /chapter08
parent14e0b47d284bb1c12dda5220f56626bacef49fcc (diff)
parent94862dad6173cfd146f41cd1ca1b0149f8215451 (diff)
Merge branch 'xry111/tester-nohack' into trunk
Use a fixed UID for "tester" user, instead of the tty owner's UID. The problem using tty owner's UID is, when tty is owned by "root" the UID of "tester" will be 0. This cause a namesis between "tester" and root. And, the "tester" is introduced to run some tests which are not expected to be ran as root. If "tester" has UID 0, it will have root priviledge and the tests will fail again. Bash tests require the user to own the tty. To satisify it, we use Expect to spawn a new pseudoterminal to run Bash tests.
Diffstat (limited to 'chapter08')
-rw-r--r--chapter08/bash.xml13
1 files changed, 10 insertions, 3 deletions
diff --git a/chapter08/bash.xml b/chapter08/bash.xml
index bb0f2b0fb..5007c2d46 100644
--- a/chapter08/bash.xml
+++ b/chapter08/bash.xml
@@ -73,11 +73,18 @@
<screen><userinput remap="test">chown -Rv tester .</userinput></screen>
- <para>Now, run the tests as the <systemitem
+ <para>The testsuite of the package is designed to be ran as a non-root
+ user, owning the terminal connected to standard input. To satisify the
+ requirement, spawn a new pseudoterminal using
+ <application>Expect</application> and run the tests as the <systemitem
class="username">tester</systemitem> user:</para>
-<screen><userinput remap="test">su tester &lt;&lt; EOF
-PATH=$PATH make tests &lt; $(tty)
+<screen><userinput remap="test">su -s /usr/bin/expect tester &lt;&lt; EOF
+set timeout -1
+spawn make tests
+expect eof
+lassign [wait] _ _ _ value
+exit $value
EOF</userinput></screen>
<para>Install the package:</para>