diff options
author | netblue30 <netblue30@yahoo.com> | 2019-10-31 17:37:36 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2019-10-31 17:37:36 -0400 |
commit | 11418a46c1c1c51a1270bb585bf8152f9298bc74 (patch) | |
tree | 17b60e42e62ecb6d4096f9bfbaaa0543defd7326 | |
parent | testing (diff) | |
download | firejail-11418a46c1c1c51a1270bb585bf8152f9298bc74.tar.gz firejail-11418a46c1c1c51a1270bb585bf8152f9298bc74.tar.zst firejail-11418a46c1c1c51a1270bb585bf8152f9298bc74.zip |
dns fixes
-rw-r--r-- | src/firejail/main.c | 3 | ||||
-rw-r--r-- | src/firejail/profile.c | 4 | ||||
-rwxr-xr-x | test/environment/dns.exp | 74 |
3 files changed, 63 insertions, 18 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c index 7dc1b449b..5b39dd491 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -2209,9 +2209,8 @@ int main(int argc, char **argv) { | |||
2209 | else if (cfg.dns4 == NULL) | 2209 | else if (cfg.dns4 == NULL) |
2210 | cfg.dns4 = dns; | 2210 | cfg.dns4 = dns; |
2211 | else { | 2211 | else { |
2212 | fprintf(stderr, "Error: up to 4 DNS servers can be specified\n"); | 2212 | fwarning("Warning: up to 4 DNS servers can be specified, %s ignored\n", dns); |
2213 | free(dns); | 2213 | free(dns); |
2214 | return 1; | ||
2215 | } | 2214 | } |
2216 | } | 2215 | } |
2217 | 2216 | ||
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 80a4bed5a..03cd9dadb 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -874,8 +874,8 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
874 | else if (cfg.dns4 == NULL) | 874 | else if (cfg.dns4 == NULL) |
875 | cfg.dns4 = dns; | 875 | cfg.dns4 = dns; |
876 | else { | 876 | else { |
877 | fprintf(stderr, "Error: up to 4 DNS servers can be specified\n"); | 877 | fwarning("Warning: up to 4 DNS servers can be specified, %s ignored\n", dns); |
878 | exit(1); | 878 | free(dns); |
879 | } | 879 | } |
880 | return 0; | 880 | return 0; |
881 | } | 881 | } |
diff --git a/test/environment/dns.exp b/test/environment/dns.exp index 6ddc0ccea..d1f3f650f 100755 --- a/test/environment/dns.exp +++ b/test/environment/dns.exp | |||
@@ -1,31 +1,77 @@ | |||
1 | #!/usr/bin/expect -f | 1 | #!/usr/bin/expect -f |
2 | 2 | ||
3 | set timeout 30 | 3 | set timeout 10 |
4 | spawn $env(SHELL) | 4 | spawn $env(SHELL) |
5 | match_max 100000 | 5 | match_max 100000 |
6 | 6 | ||
7 | send -- "firejail --dns=8.8.4.4 --dns=8.8.8.8 --dns=4.2.2.1 --dns=::2 --dns=1.2.3.4 sleep 1\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 1\n";exit} | ||
10 | "Warning: up to 4 DNS servers can be specified, 1.2.3.4 ignored" | ||
11 | } | ||
12 | expect { | ||
13 | timeout {puts "TESTING ERROR 1.1\n";exit} | ||
14 | "DNS server 8.8.4.4" | ||
15 | } | ||
16 | expect { | ||
17 | timeout {puts "TESTING ERROR 1.2\n";exit} | ||
18 | "DNS server 8.8.8.8" | ||
19 | } | ||
20 | expect { | ||
21 | timeout {puts "TESTING ERROR 1.3\n";exit} | ||
22 | "DNS server 4.2.2.1" | ||
23 | } | ||
24 | expect { | ||
25 | timeout {puts "TESTING ERROR 1.4\n";exit} | ||
26 | "DNS server ::2" | ||
27 | } | ||
28 | expect { | ||
29 | timeout {puts "TESTING ERROR 1.5\n";exit} | ||
30 | "Child process initialized" | ||
31 | } | ||
32 | expect { | ||
33 | timeout {puts "TESTING ERROR 1.6\n";exit} | ||
34 | "Parent is shutting down, bye..." | ||
35 | } | ||
36 | after 100 | ||
37 | |||
38 | |||
39 | send -- "firejail --quiet --dns=8.8.4.4 --dns=8.8.8.8 --dns=4.2.2.1 --dns=::2 --dns=1.2.3.4 cat /etc/passwd\r" | ||
40 | expect { | ||
41 | timeout {puts "TESTING ERROR 2\n";exit} | ||
42 | "Warning: up to 4 DNS servers can be specified, 1.2.3.4 ignored" {puts "TESTING ERROR 2.1\n";exit} | ||
43 | "DNS server 8.8.4.4" {puts "TESTING ERROR 2.2\n";exit} | ||
44 | "DNS server 8.8.8.8" {puts "TESTING ERROR 2.3\n";exit} | ||
45 | "DNS server 4.2.2.1" {puts "TESTING ERROR 2.4\n";exit} | ||
46 | "DNS server ::2" {puts "TESTING ERROR 2.5\n";exit} | ||
47 | "Child process initialized" {puts "TESTING ERROR 2.6\n";exit} | ||
48 | "Parent is shutting down, bye..." {puts "TESTING ERROR 2.7\n";exit} | ||
49 | "root" | ||
50 | } | ||
51 | after 100 | ||
52 | |||
7 | send -- "firejail --dns=8.8.4.4 --dns=8.8.8.8 --dns=4.2.2.1 --dns=::2\r" | 53 | send -- "firejail --dns=8.8.4.4 --dns=8.8.8.8 --dns=4.2.2.1 --dns=::2\r" |
8 | expect { | 54 | expect { |
9 | timeout {puts "TESTING ERROR 2.1\n";exit} | 55 | timeout {puts "TESTING ERROR 3\n";exit} |
10 | "Child process initialized" | 56 | "Child process initialized" |
11 | } | 57 | } |
12 | sleep 1 | 58 | sleep 1 |
13 | 59 | ||
14 | send -- "cat /etc/resolv.conf\r" | 60 | send -- "cat /etc/resolv.conf\r" |
15 | expect { | 61 | expect { |
16 | timeout {puts "TESTING ERROR 2.2\n";exit} | 62 | timeout {puts "TESTING ERROR 4.1\n";exit} |
17 | "nameserver 8.8.4.4" | 63 | "nameserver 8.8.4.4" |
18 | } | 64 | } |
19 | expect { | 65 | expect { |
20 | timeout {puts "TESTING ERROR 2.3\n";exit} | 66 | timeout {puts "TESTING ERROR 4.2\n";exit} |
21 | "nameserver 8.8.8.8" | 67 | "nameserver 8.8.8.8" |
22 | } | 68 | } |
23 | expect { | 69 | expect { |
24 | timeout {puts "TESTING ERROR 2.4\n";exit} | 70 | timeout {puts "TESTING ERROR 4.3\n";exit} |
25 | "nameserver 4.2.2.1" | 71 | "nameserver 4.2.2.1" |
26 | } | 72 | } |
27 | expect { | 73 | expect { |
28 | timeout {puts "TESTING ERROR 2.5\n";exit} | 74 | timeout {puts "TESTING ERROR 4.4\n";exit} |
29 | "nameserver ::2" | 75 | "nameserver ::2" |
30 | } | 76 | } |
31 | after 100 | 77 | after 100 |
@@ -35,27 +81,27 @@ sleep 1 | |||
35 | 81 | ||
36 | send -- "firejail --profile=dns.profile\r" | 82 | send -- "firejail --profile=dns.profile\r" |
37 | expect { | 83 | expect { |
38 | timeout {puts "TESTING ERROR 12.1\n";exit} | 84 | timeout {puts "TESTING ERROR 5.1\n";exit} |
39 | "Child process initialized" | 85 | "Child process initialized" |
40 | } | 86 | } |
41 | sleep 1 | 87 | sleep 1 |
42 | 88 | ||
43 | send -- "cat /etc/resolv.conf\r" | 89 | send -- "cat /etc/resolv.conf\r" |
44 | expect { | 90 | expect { |
45 | timeout {puts "TESTING ERROR 12.2\n";exit} | 91 | timeout {puts "TESTING ERROR 5.2\n";exit} |
46 | "nameserver 8.8.4.4" | 92 | "nameserver 8.8.4.4" |
47 | } | 93 | } |
48 | expect { | 94 | expect { |
49 | timeout {puts "TESTING ERROR 12.3\n";exit} | 95 | timeout {puts "TESTING ERROR 5.3\n";exit} |
50 | "nameserver 8.8.8.8" | 96 | "nameserver 8.8.8.8" |
51 | } | 97 | } |
52 | expect { | 98 | expect { |
53 | timeout {puts "TESTING ERROR 12.4\n";exit} | 99 | timeout {puts "TESTING ERROR 5.4\n";exit} |
54 | "nameserver 4.2.2.1" | 100 | "nameserver 4.2.2.1" |
55 | } | 101 | } |
56 | after 100 | 102 | after 100 |
57 | expect { | 103 | expect { |
58 | timeout {puts "TESTING ERROR 12.5\n";exit} | 104 | timeout {puts "TESTING ERROR 5.5\n";exit} |
59 | "nameserver ::2" | 105 | "nameserver ::2" |
60 | } | 106 | } |
61 | send -- "exit\r" | 107 | send -- "exit\r" |
@@ -63,15 +109,15 @@ sleep 1 | |||
63 | 109 | ||
64 | send -- "firejail --trace --dns=208.67.222.222 wget -q debian.org\r" | 110 | send -- "firejail --trace --dns=208.67.222.222 wget -q debian.org\r" |
65 | expect { | 111 | expect { |
66 | timeout {puts "TESTING ERROR 1.2\n";exit} | 112 | timeout {puts "TESTING ERROR 6.1\n";exit} |
67 | "connect" | 113 | "connect" |
68 | } | 114 | } |
69 | expect { | 115 | expect { |
70 | timeout {puts "TESTING ERROR 1.2\n";exit} | 116 | timeout {puts "TESTING ERROR 6.2\n";exit} |
71 | "208.67.222.222" | 117 | "208.67.222.222" |
72 | } | 118 | } |
73 | expect { | 119 | expect { |
74 | timeout {puts "TESTING ERROR 1.2\n";exit} | 120 | timeout {puts "TESTING ERROR 6.3\n";exit} |
75 | "53" | 121 | "53" |
76 | } | 122 | } |
77 | after 100 | 123 | after 100 |