summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2017-05-14 07:47:28 (GMT)
committer GitHub <noreply@github.com>2017-05-14 07:47:28 (GMT)
commit5f71b486df105f7104d881ef1536511fa781390c (patch)
treea5efc2946e48264a84c710348934ad5edf14b4ef
parent9fa55d1165941beee5eeea9b37261a0661b32b3b (diff)
parent67004392fa886dc7fa3f1df6ea3f5145edb3bbef (diff)
Merge pull request #261 from Narrat/missing_lsof_stuff_2HEADmaster
Missing lsof stuff
-rw-r--r--extras/test/10_operations.sh11
-rw-r--r--extras/test/Makefile2
-rw-r--r--extras/test/close_block.c41
-rw-r--r--extras/test/setup1
-rwxr-xr-xtomb2
5 files changed, 55 insertions, 2 deletions
diff --git a/extras/test/10_operations.sh b/extras/test/10_operations.sh
index bc664c9..41d740e 100644
--- a/extras/test/10_operations.sh
+++ b/extras/test/10_operations.sh
@@ -21,4 +21,15 @@ test_expect_success 'Testing open in read only mode' '
chmod +w $tomb
'
+if test_have_prereq LSOF; then
+ gcc -Wall -o $TMP/close_block $TEST_HOME/close_block.c
+ test_expect_success 'Testing functionality of the slam operation (use of lsof)' '
+ mkdir $TMP/testmount &&
+ tt_open $TMP/testmount --tomb-pwd $DUMMYPASS &&
+ tt_set_ownership $TMP/testmount &&
+ $TMP/close_block $TMP/testmount/occupied 20 &
+ tt slam
+ '
+fi
+
test_done
diff --git a/extras/test/Makefile b/extras/test/Makefile
index 7910051..8515d2c 100644
--- a/extras/test/Makefile
+++ b/extras/test/Makefile
@@ -24,7 +24,7 @@ RM ?= rm -f
PROVE ?= prove
AGGREGATE_SCRIPT ?= aggregate-results
DEFAULT_TEST_TARGET ?= test
-TEST_OPTS ?= --verbose --immediate --chain-lint --root=/tmp/tomb/sharness
+TEST_OPTS ?= --verbose --immediate --root=/tmp/tomb/sharness
T = $(sort $(wildcard *.sh))
diff --git a/extras/test/close_block.c b/extras/test/close_block.c
new file mode 100644
index 0000000..b2b2ef3
--- /dev/null
+++ b/extras/test/close_block.c
@@ -0,0 +1,41 @@
+/*
+ * Small program which simply opens a file in a tomb to block the
+ * $ tomb close
+ * operation
+ *
+ * Hard coded assumption on command line arguments
+ * 2) Path to open
+ * 3) How long to open the file (in seconds and can be optional)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+
+int main(int argc, char const *argv[]) {
+ FILE *file_ptr;
+ unsigned int to_wait=10;
+
+ if ( argc < 2 ) {
+ fprintf(stderr, "Usage: %s path [time]\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if ( argc == 3 ) {
+ to_wait = atoi(argv[2]);
+ }
+
+ file_ptr = fopen(argv[1],"w");
+
+ if ( file_ptr == NULL ) {
+ fprintf(stderr, "Error while opening the file.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ sleep(to_wait);
+
+ fclose(file_ptr);
+
+ return 0;
+}
diff --git a/extras/test/setup b/extras/test/setup
index bdc3ecb..9f73737 100644
--- a/extras/test/setup
+++ b/extras/test/setup
@@ -51,6 +51,7 @@ command -v steghide > /dev/null && test_set_prereq STEGHIDE
command -v e2fsck resize2fs > /dev/null && test_set_prereq RESIZER
command -v tomb-kdb-pbkdf2 > /dev/null && test_set_prereq KDF
command -v qrencode > /dev/null && test_set_prereq QRENCODE
+command -v lsof > /dev/null && test_set_prereq LSOF
# GnuPG config
diff --git a/tomb b/tomb
index ce5a909..91b0a2a 100755
--- a/tomb
+++ b/tomb
@@ -782,7 +782,7 @@ function _print() {
_list_optional_tools() {
typeset -a _deps
_deps=(gettext dcfldd wipe steghide)
- _deps+=(resize2fs tomb-kdb-pbkdf2 qrencode swish-e unoconv)
+ _deps+=(resize2fs tomb-kdb-pbkdf2 qrencode swish-e unoconv lsof)
for d in $_deps; do
_print "`which $d`"
done