From f233eee37465218ff2b8a7b8806f1d85ea757c70 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 16 Nov 2016 20:11:29 -0500 Subject: testing --- test/fs/fs.sh | 13 ++++++++++- test/fs/fscheck-bindnoroot.exp | 17 ++++++++++++++ test/fs/fscheck-private.exp | 50 ++++++++++++++++++++++++++++++++++++++++++ test/fs/fscheck-readonly.exp | 15 +++++++++++++ test/fs/fscheck-tmpfs.exp | 14 ++++++++++++ test/fs/read-write.exp | 28 +++++------------------ test/fs/testfile1 | 0 7 files changed, 114 insertions(+), 23 deletions(-) create mode 100755 test/fs/fscheck-bindnoroot.exp create mode 100755 test/fs/fscheck-private.exp create mode 100755 test/fs/fscheck-readonly.exp create mode 100755 test/fs/fscheck-tmpfs.exp create mode 100644 test/fs/testfile1 (limited to 'test/fs') diff --git a/test/fs/fs.sh b/test/fs/fs.sh index efbf505ee..1c5473f79 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -82,10 +82,21 @@ echo "TESTING: recursive mkdir (test/fs/mkdir.exp)" echo "TESTING: double whitelist (test/fs/whitelist-double.exp)" ./whitelist-double.exp - echo "TESTING: whitelist (test/fs/whitelist.exp)" ./whitelist.exp +echo "TESTING: fscheck --bind non root (test/fs/fscheck-bindnoroot.exp)" +./fscheck-bindnoroot.exp + +echo "TESTING: fscheck --tmpfs non root (test/fs/fscheck-tmpfs.exp)" +./fscheck-tmpfs.exp + +echo "TESTING: fscheck --private= (test/fs/fscheck-private.exp)" +./fscheck-private.exp + +echo "TESTING: fscheck --read-only= (test/fs/fscheck-readonly.exp)" +./fscheck-readonly.exp + #cleanup rm -fr ~/fjtest-dir rm -fr ~/fjtest-dir-lnk diff --git a/test/fs/fscheck-bindnoroot.exp b/test/fs/fscheck-bindnoroot.exp new file mode 100755 index 000000000..8cbe2b8af --- /dev/null +++ b/test/fs/fscheck-bindnoroot.exp @@ -0,0 +1,17 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +# dir +send -- "firejail --net=br0 --bind=testdir1,/etc\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Error" +} +after 100 + +puts "\nall done\n" + + diff --git a/test/fs/fscheck-private.exp b/test/fs/fscheck-private.exp new file mode 100755 index 000000000..28c921538 --- /dev/null +++ b/test/fs/fscheck-private.exp @@ -0,0 +1,50 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + + + +# file link +#send -- "firejail --private=fscheck-file-link\r" +#expect { +# timeout {puts "TESTING ERROR 2\n";exit} +# "Error" +#} +#after 100 + +# file +send -- "firejail --private=testfile1\r" +expect { + timeout {puts "TESTING ERROR 2.1\n";exit} + "Error" +} +after 100 + +# .. +send -- "firejail --private=../fs/testfile1\r" +expect { + timeout {puts "TESTING ERROR 2.2\n";exit} + "Error" +} +after 100 + +# no file +send -- "firejail --private=../test/nodir\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "Error" +} +after 100 + +# same owner +send -- "firejail --private=/etc\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "Error" +} +after 100 + +puts "\nall done\n" + diff --git a/test/fs/fscheck-readonly.exp b/test/fs/fscheck-readonly.exp new file mode 100755 index 000000000..4d7528e50 --- /dev/null +++ b/test/fs/fscheck-readonly.exp @@ -0,0 +1,15 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +# dir +send -- "firejail --read-only=../test/testdir1\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Error" +} +after 100 + +puts "\nall done\n" diff --git a/test/fs/fscheck-tmpfs.exp b/test/fs/fscheck-tmpfs.exp new file mode 100755 index 000000000..deac5a631 --- /dev/null +++ b/test/fs/fscheck-tmpfs.exp @@ -0,0 +1,14 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +# .. +send -- "firejail --tmpfs=fscheck-dir\r" +expect { + timeout {puts "TESTING ERROR 0.1\n";exit} + "Error" +} +after 100 + diff --git a/test/fs/read-write.exp b/test/fs/read-write.exp index 57986488e..19a915f66 100755 --- a/test/fs/read-write.exp +++ b/test/fs/read-write.exp @@ -15,37 +15,21 @@ expect { } sleep 1 -send -- "echo mytest >~/_firejail_test_dir/a;echo done\r" +send -- "echo mytest > ~/_firejail_test_dir/a\r" expect { - timeout {puts "TESTING ERROR 1\n";exit} - "done" -} -after 100 - -send -- "echo mytest >~/_firejail_test_dir/test1/b;echo done\r" -expect { - timeout {puts "TESTING ERROR 2\n";exit} - "done" + timeout {puts "TESTING ERROR 5\n";exit} + "Read-only file system" } after 100 -send -- "cat ~/_firejail_test_dir/a;echo done\r" -expect { - timeout {puts "TESTING ERROR 3\n";exit} - "mytest" {puts "TESTING ERROR 4\n";exit} - "done" -} -after 100 +send -- "echo mytest > ~/_firejail_test_dir/test1/b\r" +sleep 1 -send -- "cat ~/_firejail_test_dir/test1/b;echo done\r" +send -- "cat ~/_firejail_test_dir/test1/b\r" expect { timeout {puts "TESTING ERROR 5\n";exit} "mytest" } -expect { - timeout {puts "TESTING ERROR 6\n";exit} - "done" -} after 100 puts "\nall done\n" diff --git a/test/fs/testfile1 b/test/fs/testfile1 new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3-54-g00ecf