aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2023-03-01 08:52:53 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2023-03-01 08:52:53 -0500
commitb50812ff5ef5009b7c6babb19fd9caa315f31515 (patch)
tree0535438678837dffb9ba5ba988efa482d53c1fc3 /test
parentchroot testing (diff)
downloadfirejail-b50812ff5ef5009b7c6babb19fd9caa315f31515.tar.gz
firejail-b50812ff5ef5009b7c6babb19fd9caa315f31515.tar.zst
firejail-b50812ff5ef5009b7c6babb19fd9caa315f31515.zip
appimage testing
Diffstat (limited to 'test')
-rw-r--r--test/appimage/Leafpad-0.8.17-x86_64.AppImagebin786432 -> 0 bytes
-rw-r--r--test/appimage/Leafpad-0.8.18.1.glibc2.4-x86_64.AppImagebin231417 -> 0 bytes
-rwxr-xr-xtest/appimage/appimage-args.exp90
-rwxr-xr-xtest/appimage/appimage-trace.exp45
-rwxr-xr-xtest/appimage/appimage-v1.exp92
-rwxr-xr-xtest/appimage/appimage-v2.exp31
-rwxr-xr-xtest/appimage/appimage.sh5
-rwxr-xr-xtest/appimage/hello-x86_64.AppImagebin0 -> 197824 bytes
-rw-r--r--test/appimage/main.c32
9 files changed, 60 insertions, 235 deletions
diff --git a/test/appimage/Leafpad-0.8.17-x86_64.AppImage b/test/appimage/Leafpad-0.8.17-x86_64.AppImage
deleted file mode 100644
index 865f6b44c..000000000
--- a/test/appimage/Leafpad-0.8.17-x86_64.AppImage
+++ /dev/null
Binary files differ
diff --git a/test/appimage/Leafpad-0.8.18.1.glibc2.4-x86_64.AppImage b/test/appimage/Leafpad-0.8.18.1.glibc2.4-x86_64.AppImage
deleted file mode 100644
index d167431f3..000000000
--- a/test/appimage/Leafpad-0.8.18.1.glibc2.4-x86_64.AppImage
+++ /dev/null
Binary files differ
diff --git a/test/appimage/appimage-args.exp b/test/appimage/appimage-args.exp
index e85e8a46a..ef64e862f 100755
--- a/test/appimage/appimage-args.exp
+++ b/test/appimage/appimage-args.exp
@@ -8,97 +8,15 @@ spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
10set appimage_id $spawn_id 10set appimage_id $spawn_id
11send -- "firejail --name=test --debug --appimage Leafpad-0.8.17-x86_64.AppImage testfile\r" 11send -- "firejail --name=test --appimage hello-x86_64.AppImage testfile\r"
12expect {
13 timeout {puts "TESTING ERROR 1\n";exit}
14 "execvp argument 2"
15}
16expect {
17 timeout {puts "TESTING ERROR 2\n";exit}
18 "AppRun"
19}
20expect {
21 timeout {puts "TESTING ERROR 3\n";exit}
22 "testfile"
23}
24expect { 12expect {
25 timeout {puts "TESTING ERROR 4\n";exit} 13 timeout {puts "TESTING ERROR 4\n";exit}
26 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
27} 15}
28sleep 2
29
30spawn $env(SHELL)
31send -- "firejail --list\r"
32expect { 16expect {
33 timeout {puts "TESTING ERROR 5\n";exit} 17 timeout {puts "TESTING ERROR 4\n";exit}
34 ":firejail" 18 "1 - testfile"
35}
36expect {
37 timeout {puts "TESTING ERROR 6\n";exit}
38 "appimage Leafpad"
39}
40after 100
41
42# grsecurity exit
43send -- "file /proc/sys/kernel/grsecurity\r"
44expect {
45 timeout {puts "TESTING ERROR - grsecurity detection\n";exit}
46 "grsecurity: directory" {puts "grsecurity present, exiting...\n";exit}
47 "cannot open" {puts "grsecurity not present\n"}
48}
49
50
51send -- "firejail --name=blablabla\r"
52expect {
53 timeout {puts "TESTING ERROR 7\n";exit}
54 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
55}
56sleep 2
57
58spawn $env(SHELL)
59send -- "firemon --seccomp --wrap\r"
60expect {
61 timeout {puts "TESTING ERROR 8\n";exit}
62 "need to be root" {puts "/proc mounted as hidepid, exiting...\n"; exit}
63 "appimage Leafpad"
64}
65expect {
66 timeout {puts "TESTING ERROR 9 (seccomp)\n";exit}
67 "Seccomp: 2"
68}
69expect {
70 timeout {puts "TESTING ERROR 10\n";exit}
71 "name=blablabla"
72}
73after 100
74send -- "firemon --caps --wrap\r"
75expect {
76 timeout {puts "TESTING ERROR 11\n";exit}
77 "appimage Leafpad"
78}
79expect {
80 timeout {puts "TESTING ERROR 12\n";exit}
81 "CapBnd:"
82}
83expect {
84 timeout {puts "TESTING ERROR 13\n";exit}
85 "0000000000000000"
86}
87expect {
88 timeout {puts "TESTING ERROR 14\n";exit}
89 "name=blablabla"
90}
91after 100
92
93spawn $env(SHELL)
94send -- "firejail --shutdown=test\r"
95
96set spawn_id $appimage_id
97expect {
98 timeout {puts "shutdown\n";exit}
99 "AppImage detached"
100} 19}
101 20
102after 100 21after 500
103
104puts "\nall done\n" 22puts "\nall done\n"
diff --git a/test/appimage/appimage-trace.exp b/test/appimage/appimage-trace.exp
index f98826138..c1e481a67 100755
--- a/test/appimage/appimage-trace.exp
+++ b/test/appimage/appimage-trace.exp
@@ -8,61 +8,28 @@ spawn $env(SHELL)
8match_max 100000 8match_max 100000
9set appimage_id $spawn_id 9set appimage_id $spawn_id
10 10
11send -- "firejail --trace --timeout=00:00:05 --appimage Leafpad-0.8.17-x86_64.AppImage\r" 11send -- "firejail --trace --timeout=00:00:05 --appimage hello-x86_64.AppImage\r"
12expect { 12expect {
13 timeout {puts "TESTING ERROR 1\n";exit} 13 timeout {puts "TESTING ERROR 1\n";exit}
14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
15} 15}
16expect { 16expect {
17 timeout {puts "TESTING ERROR 2\n";exit} 17 timeout {puts "TESTING ERROR 2\n";exit}
18 "leafpad:socket" 18 "AppRun:exec"
19} 19}
20expect { 20expect {
21 timeout {puts "TESTING ERROR 3\n";exit} 21 timeout {puts "TESTING ERROR 3\n";exit}
22 "leafpad:connect" 22 "AppRun:opendir"
23} 23}
24expect { 24expect {
25 timeout {puts "TESTING ERROR 4\n";exit} 25 timeout {puts "TESTING ERROR 4\n";exit}
26 "X11-unix/X0" 26 "Hello, World!"
27} 27}
28expect { 28expect {
29 timeout {puts "TESTING ERROR 5\n";exit} 29 timeout {puts "TESTING ERROR 5\n";exit}
30 "Parent is shutting down, bye" 30 "ping:exec"
31} 31}
32expect {
33 timeout {puts "shutdown\n"}
34 "AppImage detached"
35}
36sleep 1
37
38send -- "firejail --trace --timeout=00:00:05 --appimage Leafpad-0.8.18.1.glibc2.4-x86_64.AppImage\r"
39expect {
40 timeout {puts "TESTING ERROR 11\n";exit}
41 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
42}
43expect {
44 timeout {puts "TESTING ERROR 12\n";exit}
45 "leafpad:socket"
46}
47expect {
48 timeout {puts "TESTING ERROR 13\n";exit}
49 "leafpad:connect"
50}
51expect {
52 timeout {puts "TESTING ERROR 14\n";exit}
53 "X11-unix/X0"
54}
55expect {
56 timeout {puts "TESTING ERROR 15\n";exit}
57 "Parent is shutting down, bye"
58}
59expect {
60 timeout {puts "shutdown\n"}
61 "AppImage detached"
62}
63sleep 1
64
65 32
66after 100 33after 500
67 34
68puts "\nall done\n" 35puts "\nall done\n"
diff --git a/test/appimage/appimage-v1.exp b/test/appimage/appimage-v1.exp
deleted file mode 100755
index bb360cd18..000000000
--- a/test/appimage/appimage-v1.exp
+++ /dev/null
@@ -1,92 +0,0 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2023 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9set appimage_id $spawn_id
10
11send -- "firejail --name=test --debug --appimage Leafpad-0.8.17-x86_64.AppImage\r"
12expect {
13 timeout {puts "TESTING ERROR 1\n";exit}
14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
15}
16sleep 2
17
18spawn $env(SHELL)
19send -- "firejail --list\r"
20expect {
21 timeout {puts "TESTING ERROR 3\n";exit}
22 ":firejail"
23}
24expect {
25 timeout {puts "TESTING ERROR 3.1\n";exit}
26 "appimage Leafpad"
27}
28after 100
29
30# grsecurity exit
31send -- "file /proc/sys/kernel/grsecurity\r"
32expect {
33 timeout {puts "TESTING ERROR - grsecurity detection\n";exit}
34 "grsecurity: directory" {puts "grsecurity present, exiting...\n";exit}
35 "cannot open" {puts "grsecurity not present\n"}
36}
37
38
39send -- "firejail --name=blablabla\r"
40expect {
41 timeout {puts "TESTING ERROR 4\n";exit}
42 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
43}
44sleep 2
45
46spawn $env(SHELL)
47send -- "firemon --seccomp --wrap\r"
48expect {
49 timeout {puts "TESTING ERROR 5\n";exit}
50 "need to be root" {puts "/proc mounted as hidepid, exiting...\n"; exit}
51 "appimage Leafpad"
52}
53expect {
54 timeout {puts "TESTING ERROR 5.1 (seccomp)\n";exit}
55 "Seccomp: 2"
56}
57expect {
58 timeout {puts "TESTING ERROR 5.1\n";exit}
59 "name=blablabla"
60}
61after 100
62send -- "firemon --caps --wrap\r"
63expect {
64 timeout {puts "TESTING ERROR 6\n";exit}
65 "appimage Leafpad"
66}
67expect {
68 timeout {puts "TESTING ERROR 6.1\n";exit}
69 "CapBnd:"
70}
71expect {
72 timeout {puts "TESTING ERROR 6.2\n";exit}
73 "0000000000000000"
74}
75expect {
76 timeout {puts "TESTING ERROR 6.3\n";exit}
77 "name=blablabla"
78}
79after 100
80
81spawn $env(SHELL)
82send -- "firejail --shutdown=test\r"
83
84set spawn_id $appimage_id
85expect {
86 timeout {puts "shutdown\n"}
87 "AppImage detached"
88}
89
90after 100
91
92puts "\nall done\n"
diff --git a/test/appimage/appimage-v2.exp b/test/appimage/appimage-v2.exp
index 748ac3d79..2d86de240 100755
--- a/test/appimage/appimage-v2.exp
+++ b/test/appimage/appimage-v2.exp
@@ -8,12 +8,24 @@ spawn $env(SHELL)
8match_max 100000 8match_max 100000
9set appimage_id $spawn_id 9set appimage_id $spawn_id
10 10
11send -- "firejail --name=test --appimage Leafpad-0.8.18.1.glibc2.4-x86_64.AppImage\r" 11send -- "firejail --name=test --appimage hello-x86_64.AppImage\r"
12expect { 12expect {
13 timeout {puts "TESTING ERROR 1\n";exit} 13 timeout {puts "TESTING ERROR 1\n";exit}
14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms" 14 -re "Child process initialized in \[0-9\]+.\[0-9\]+ ms"
15} 15}
16sleep 2 16expect {
17 timeout {puts "TESTING ERROR 1\n";exit}
18 "Hello, World!"
19}
20expect {
21 timeout {puts "TESTING ERROR 1\n";exit}
22 "Operation not permitted"
23}
24expect {
25 timeout {puts "TESTING ERROR 1\n";exit}
26 "Hello, again!"
27}
28sleep 5
17 29
18spawn $env(SHELL) 30spawn $env(SHELL)
19send -- "firejail --list\r" 31send -- "firejail --list\r"
@@ -23,19 +35,10 @@ expect {
23} 35}
24expect { 36expect {
25 timeout {puts "TESTING ERROR 3.1\n";exit} 37 timeout {puts "TESTING ERROR 3.1\n";exit}
26 "appimage Leafpad" 38 "appimage hello-x86_64"
27} 39}
28after 100 40after 100
29 41
30# grsecurity exit
31send -- "file /proc/sys/kernel/grsecurity\r"
32expect {
33 timeout {puts "TESTING ERROR - grsecurity detection\n";exit}
34 "grsecurity: directory" {puts "grsecurity present, exiting...\n";exit}
35 "cannot open" {puts "grsecurity not present\n"}
36}
37
38
39send -- "firejail --name=blablabla\r" 42send -- "firejail --name=blablabla\r"
40expect { 43expect {
41 timeout {puts "TESTING ERROR 4\n";exit} 44 timeout {puts "TESTING ERROR 4\n";exit}
@@ -48,7 +51,7 @@ send -- "firemon --seccomp\r"
48expect { 51expect {
49 timeout {puts "TESTING ERROR 5\n";exit} 52 timeout {puts "TESTING ERROR 5\n";exit}
50 "need to be root" {puts "/proc mounted as hidepid, exiting...\n"; exit} 53 "need to be root" {puts "/proc mounted as hidepid, exiting...\n"; exit}
51 "appimage Leafpad" 54 "appimage hello-x86_64"
52} 55}
53expect { 56expect {
54 timeout {puts "TESTING ERROR 5.1 (seccomp)\n";exit} 57 timeout {puts "TESTING ERROR 5.1 (seccomp)\n";exit}
@@ -62,7 +65,7 @@ after 100
62send -- "firemon --caps\r" 65send -- "firemon --caps\r"
63expect { 66expect {
64 timeout {puts "TESTING ERROR 6\n";exit} 67 timeout {puts "TESTING ERROR 6\n";exit}
65 "appimage Leafpad" 68 "appimage hello-x86_64"
66} 69}
67expect { 70expect {
68 timeout {puts "TESTING ERROR 6.1\n";exit} 71 timeout {puts "TESTING ERROR 6.1\n";exit}
diff --git a/test/appimage/appimage.sh b/test/appimage/appimage.sh
index 0c50434ac..57e389249 100755
--- a/test/appimage/appimage.sh
+++ b/test/appimage/appimage.sh
@@ -7,16 +7,13 @@ export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8export LC_ALL=C 8export LC_ALL=C
9 9
10echo "TESTING: AppImage v1 (test/appimage/appimage-v1.exp)"
11./appimage-v1.exp
12
13echo "TESTING: AppImage v2 (test/appimage/appimage-v2.exp)" 10echo "TESTING: AppImage v2 (test/appimage/appimage-v2.exp)"
14./appimage-v2.exp 11./appimage-v2.exp
15 12
16echo "TESTING: AppImage file name (test/appimage/filename.exp)" 13echo "TESTING: AppImage file name (test/appimage/filename.exp)"
17./filename.exp 14./filename.exp
18 15
19echo "TESTING: AppImage argsv1 (test/appimage/appimage-args.exp)" 16echo "TESTING: AppImage args (test/appimage/appimage-args.exp)"
20./appimage-args.exp 17./appimage-args.exp
21 18
22echo "TESTING: AppImage trace (test/appimage/appimage-trace.exp)" 19echo "TESTING: AppImage trace (test/appimage/appimage-trace.exp)"
diff --git a/test/appimage/hello-x86_64.AppImage b/test/appimage/hello-x86_64.AppImage
new file mode 100755
index 000000000..b5d68fc5c
--- /dev/null
+++ b/test/appimage/hello-x86_64.AppImage
Binary files differ
diff --git a/test/appimage/main.c b/test/appimage/main.c
new file mode 100644
index 000000000..83c495183
--- /dev/null
+++ b/test/appimage/main.c
@@ -0,0 +1,32 @@
1// This is a simple hello program compiled on Debian 11 (glibc 2.31)
2// and packaged as an appimage using appimagetool from
3// https://github.com/AppImage/AppImageKit. The tool in installed
4// in the current directory.
5//
6// Building the appimage:
7// mkdir -p AppDir/usr/bin
8// gcc -o AppDir/usr/bin/hello main.c && strip AppDir/usr/bin/hello
9// ./appimagetool AppDir
10
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <unistd.h>
15
16int main(int argc, char **argv) {
17 // test args
18 int i;
19 for (i = 1; i < argc; i++)
20 printf("%d - %s\n", i, argv[i]);
21
22 printf("Hello, World!\n");
23
24 // elevate privileges - firejail should block it
25 system("ping -c 3 127.0.0.1\n");
26
27 printf("Hello, again!\n");
28 sleep(30);
29
30 return 0;
31}
32