From c658d33187cde764f7f2fd65f743e79be5d17e75 Mon Sep 17 00:00:00 2001 From: Narrat Date: Mon, 17 Apr 2017 18:04:05 +0200 Subject: [PATCH 1/2] --version includes lsof as optional dep --- tomb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 67004392fa886dc7fa3f1df6ea3f5145edb3bbef Mon Sep 17 00:00:00 2001 From: Narrat Date: Fri, 12 May 2017 20:24:49 +0200 Subject: [PATCH 2/2] Add testcase for slam operation Thanks to @roddhjav for the intel and the test itself. Closes #258 --- extras/test/10_operations.sh | 11 ++++++++++ extras/test/Makefile | 2 +- extras/test/close_block.c | 41 ++++++++++++++++++++++++++++++++++++ extras/test/setup | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 extras/test/close_block.c 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 +#include +#include + + +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