summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmin Mesbah <mesbah.amin@gmail.com>2017-02-13 00:29:20 (GMT)
committer Amin Mesbah <mesbah.amin@gmail.com>2017-02-13 00:39:39 (GMT)
commitf4f8c4e024218d47cfee1a8467c53d7ce54b4acc (patch)
treed19f44b193d4c85ea360b6dce9747f5147dd070f
parent8832471170e97bf71ff9a51e54e4915602cb1868 (diff)
Add failing test for opening read-only tomb.
Adds a test function called test-open-read-only(). The test prepares a tomb file, removes the "write" permissions from it, and then attempts to open it with "read-only" mount options (`-o ro,noatime,nodev`). The test currently fails as expected.
-rwxr-xr-xextras/test/runtests31
1 files changed, 28 insertions, 3 deletions
diff --git a/extras/test/runtests b/extras/test/runtests
index b664e9a..4c99a0e 100755
--- a/extras/test/runtests
+++ b/extras/test/runtests
@@ -56,7 +56,7 @@ command -v qrencode > /dev/null || QRENCODE=0
typeset -A results
-tests=(dig forge lock badpass open close passwd chksum bind setkey)
+tests=(dig forge lock badpass open close openro passwd chksum bind setkey)
{ test $RESIZER = 1 } && { tests+=(resize) }
{ test $KDF = 1 } && { tests+=(kdforge kdfpass kdflock kdfopen) }
{ test $STEGHIDE = 1 } && { tests+=(stgin stgout stgopen stgpipe stgimpl) }
@@ -194,7 +194,32 @@ test-regression() {
}
+test-open-read-only() {
+ notice "wiping all testro.tomb* in /tmp"
+ sudo rm -f /tmp/testro.tomb{,.key,.new.key}
+
+ # Create new
+ tt dig -s 20 /tmp/testro.tomb
+ tt forge /tmp/testro.tomb.key \
+ --ignore-swap --unsafe --tomb-pwd ${dummypass} --use-urandom
+ tt lock /tmp/testro.tomb -k /tmp/testro.tomb.key \
+ --ignore-swap --unsafe --tomb-pwd ${dummypass}
+
+ notice "Testing open read only"
+
+ # Remove write privilege on test.tomb
+ chmod -w /tmp/testro.tomb
+
+ # Attempt to open the unwritable tomb with the read-only mount option
+ tt open /tmp/testro.tomb -k /tmp/testro.tomb.key \
+ --ignore-swap --unsafe --tomb-pwd ${dummypass} -o ro,noatime,nodev
+
+ { test $? = 0 } && {
+ results+=(openro SUCCESS)
+ tt close testro
+ }
+}
startloops=(`sudo losetup -a |cut -d: -f1`)
@@ -227,8 +252,8 @@ tt close test
{ test $? = 0 } && { results+=(close SUCCESS) }
-
-
+# isolated function
+test-open-read-only
notice "Testing changing tomb password"