aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-11-08 11:55:57 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2016-11-08 11:55:57 -0500
commit62a19b0cac1646b0187e860f9edfb0843f572d1e (patch)
tree6d76d83dd3a7b901be200b7c8b610c9fbf8ef105
parenttesting (diff)
downloadfirejail-62a19b0cac1646b0187e860f9edfb0843f572d1e.tar.gz
firejail-62a19b0cac1646b0187e860f9edfb0843f572d1e.tar.zst
firejail-62a19b0cac1646b0187e860f9edfb0843f572d1e.zip
testing
-rwxr-xr-xtest/fs/fs.sh8
-rwxr-xr-xtest/fs/private-home-dir.exp70
-rwxr-xr-xtest/fs/private-home.exp45
-rwxr-xr-xtest/fs/private.exp51
4 files changed, 147 insertions, 27 deletions
diff --git a/test/fs/fs.sh b/test/fs/fs.sh
index 3139b8eae..812da02b0 100755
--- a/test/fs/fs.sh
+++ b/test/fs/fs.sh
@@ -22,7 +22,13 @@ echo "TESTING: read/write /dev/shm (test/fs/fs_dev_shm.exp)"
22./fs_dev_shm.exp 22./fs_dev_shm.exp
23 23
24echo "TESTING: private (test/fs/private.exp)" 24echo "TESTING: private (test/fs/private.exp)"
25./private.exp `whoami` 25./private.exp
26
27echo "TESTING: private home (test/fs/private-home.exp)"
28./private-home.exp
29
30echo "TESTING: private home dir (test/fs/private-home-dir.exp)"
31./private-home-dir.exp
26 32
27echo "TESTING: private-etc (test/fs/private-etc.exp)" 33echo "TESTING: private-etc (test/fs/private-etc.exp)"
28./private-etc.exp 34./private-etc.exp
diff --git a/test/fs/private-home-dir.exp b/test/fs/private-home-dir.exp
new file mode 100755
index 000000000..5491be834
--- /dev/null
+++ b/test/fs/private-home-dir.exp
@@ -0,0 +1,70 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10
11if {[file exists ~/.asoundrc]} {
12 puts "found .asoundrc file\n"
13} else {
14 send -- "touch ~/.asoundrc\r"
15}
16after 100
17
18if {[file exists ~/.Xauthority]} {
19 puts "found .Xauthority file\n"
20} else {
21 send -- "touch ~/.Xauthority\r"
22}
23after 100
24send -- "mkdir ~/_firejail_test_dir_\r"
25sleep 1
26
27# testing profile and private
28send -- "firejail --private=~/_firejail_test_dir_\r"
29expect {
30 timeout {puts "TESTING ERROR 0\n";exit}
31 "Child process initialized"
32}
33sleep 1
34
35send -- "ls -l ~\r"
36expect {
37 timeout {puts "TESTING ERROR 1\n";exit}
38 "total 0"
39}
40after 100
41
42send -- "ls -al ~\r"
43expect {
44 timeout {puts "TESTING ERROR 2\n";exit}
45 ".asoundrc"
46}
47expect {
48 timeout {puts "TESTING ERROR 3\n";exit}
49 ".bashrc"
50}
51expect {
52 timeout {puts "TESTING ERROR 4\n";exit}
53 ".Xauthority"
54}
55after 100
56
57send -- "exit\r"
58sleep 1
59
60
61# testing profile and private
62send -- "firejail --private=/etc\r"
63expect {
64 timeout {puts "TESTING ERROR 5\n";exit}
65 "private directory should be owned by the current user"
66}
67sleep 1
68
69
70puts "all done\n"
diff --git a/test/fs/private-home.exp b/test/fs/private-home.exp
new file mode 100755
index 000000000..de5a88dea
--- /dev/null
+++ b/test/fs/private-home.exp
@@ -0,0 +1,45 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10# create some test files in user home directory
11send -- "touch ~/_firejail_test_file1\r"
12send -- "touch ~/_firejail_test_file2\r"
13send -- "mkdir ~/_firejail_test_dir1\r"
14send -- "mkdir ~/_firejail_test_dir1/_firejail_test_dir2\r"
15send -- "touch ~/_firejail_test_dir1/_firejail_test_dir2/_firejail_test_file3\r"
16after 100
17
18send -- "firejail --private-home=_firejail_test_file1,_firejail_test_file2,_firejail_test_dir1\r"
19expect {
20 timeout {puts "TESTING ERROR 1\n";exit}
21 "Child process initialized"
22}
23after 100
24
25send -- "find ~\r"
26expect {
27 timeout {puts "TESTING ERROR 2\n";exit}
28 "_firejail_test_file3"
29}
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "_firejail_test_file2"
33}
34expect {
35 timeout {puts "TESTING ERROR 4\n";exit}
36 "_firejail_test_file1"
37}
38after 100
39
40send -- "rm -f ~/_firejail_test_file*\r"
41send -- "rm -fr ~/_firejail_test_dir*\r"
42after 100
43
44puts "\nall done\n"
45
diff --git a/test/fs/private.exp b/test/fs/private.exp
index 67435b888..8114ee45d 100755
--- a/test/fs/private.exp
+++ b/test/fs/private.exp
@@ -7,53 +7,52 @@ set timeout 10
7spawn $env(SHELL) 7spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
10if { $argc != 1 } { 10
11 puts "TESTING ERROR: argument missing" 11if {[file exists ~/.asoundrc]} {
12 puts "Usage: private.exp username" 12 puts "found .asoundrc file\n"
13 puts "where username is the name of the current user" 13} else {
14 exit 14 send -- "touch ~/.asoundrc\r"
15} 15}
16after 100
17
18if {[file exists ~/.Xauthority]} {
19 puts "found .Xauthority file\n"
20} else {
21 send -- "touch ~/.Xauthority\r"
22}
23after 100
16 24
17# testing profile and private 25# testing profile and private
18send -- "firejail --private --profile=/etc/firejail/default.profile\r" 26send -- "firejail --private\r"
19expect { 27expect {
20 timeout {puts "TESTING ERROR 0\n";exit} 28 timeout {puts "TESTING ERROR 0\n";exit}
21 "Child process initialized" 29 "Child process initialized"
22} 30}
23sleep 1 31sleep 1
24send -- "exit\r"
25sleep 1
26 32
27send -- "firejail --private --noprofile\r" 33send -- "ls -l ~\r"
28expect { 34expect {
29 timeout {puts "TESTING ERROR 1\n";exit} 35 timeout {puts "TESTING ERROR 1\n";exit}
30 "Child process initialized" 36 "total 0"
31} 37}
38after 100
32 39
33sleep 1 40send -- "ls -al ~\r"
34send -- "cd ~; ls -al; echo done\r"
35expect { 41expect {
36 timeout {puts "TESTING ERROR 2\n";exit} 42 timeout {puts "TESTING ERROR 2\n";exit}
37 ".bashrc" 43 ".asoundrc"
38} 44}
39expect { 45expect {
40 timeout {puts "TESTING ERROR 3\n";exit} 46 timeout {puts "TESTING ERROR 3\n";exit}
41 done 47 ".bashrc"
42}
43
44# owner /tmp
45send -- "stat -c %U%a /tmp;echo done\r"
46expect {
47 timeout {puts "TESTING ERROR 10\n";exit}
48 "root777" {puts "version 1\n";}
49 "root1777" {puts "version 2\n";}
50 "nobody777" {puts "version 3\n";}
51 "nobody1777" {puts "version 4\n";}
52} 48}
53expect { 49expect {
54 timeout {puts "TESTING ERROR 11\n";exit} 50 timeout {puts "TESTING ERROR 4\n";exit}
55 "done" 51 ".Xauthority"
56} 52}
57after 100 53after 100
58 54
55send -- "exit\r"
56sleep 1
57
59puts "all done\n" 58puts "all done\n"