aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-12-27 18:41:29 +0100
committerLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-12-30 02:38:59 +0100
commitd3d806ddb25249cf0c404904b3f5ffc7011204ce (patch)
tree3295aef69b5933420df1f68d73b666aee93d83be /src
parentDo not try to set up default gateway without an IP address (diff)
downloadfirejail-d3d806ddb25249cf0c404904b3f5ffc7011204ce.tar.gz
firejail-d3d806ddb25249cf0c404904b3f5ffc7011204ce.tar.zst
firejail-d3d806ddb25249cf0c404904b3f5ffc7011204ce.zip
Allow resolv.conf be written by dhclient
When dhclient is used to assign and IP to the container, it should be able to overwrite resolv.conf Therefore, we do the /etc mirroring similarly to the situation with manually configured nameservers. When both DHCP and manually set nameservers are in use, warn that the manual ones will be overwritten
Diffstat (limited to 'src')
-rw-r--r--src/firejail/firejail.h18
-rw-r--r--src/firejail/fs_hostname.c10
2 files changed, 25 insertions, 3 deletions
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index a5eeb4067..bfe680d24 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -239,6 +239,24 @@ static inline int any_interface_configured(void) {
239 return 0; 239 return 0;
240} 240}
241 241
242static inline int any_ip_dhcp(void) {
243 if (cfg.bridge0.arg_ip_dhcp || cfg.bridge1.arg_ip_dhcp || cfg.bridge2.arg_ip_dhcp || cfg.bridge3.arg_ip_dhcp)
244 return 1;
245 else
246 return 0;
247}
248
249static inline int any_ip6_dhcp(void) {
250 if (cfg.bridge0.arg_ip6_dhcp || cfg.bridge1.arg_ip6_dhcp || cfg.bridge2.arg_ip6_dhcp || cfg.bridge3.arg_ip6_dhcp)
251 return 1;
252 else
253 return 0;
254}
255
256static inline int any_dhcp(void) {
257 return any_ip_dhcp() || any_ip6_dhcp();
258}
259
242extern int arg_private; // mount private /home 260extern int arg_private; // mount private /home
243extern int arg_private_cache; // private home/.cache 261extern int arg_private_cache; // private home/.cache
244extern int arg_debug; // print debug messages 262extern int arg_debug; // print debug messages
diff --git a/src/firejail/fs_hostname.c b/src/firejail/fs_hostname.c
index 9da01b24c..60c65746b 100644
--- a/src/firejail/fs_hostname.c
+++ b/src/firejail/fs_hostname.c
@@ -89,7 +89,7 @@ errexit:
89} 89}
90 90
91void fs_resolvconf(void) { 91void fs_resolvconf(void) {
92 if (cfg.dns1 == NULL) 92 if (cfg.dns1 == NULL && !any_dhcp())
93 return; 93 return;
94 94
95 if (arg_debug) 95 if (arg_debug)
@@ -108,7 +108,8 @@ void fs_resolvconf(void) {
108 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) 108 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
109 continue; 109 continue;
110 // for resolv.conf we create a brand new file 110 // for resolv.conf we create a brand new file
111 if (strcmp(entry->d_name, "resolv.conf") == 0) 111 if (strcmp(entry->d_name, "resolv.conf") == 0 ||
112 strcmp(entry->d_name, "resolv.conf.dhclient-new") == 0)
112 continue; 113 continue;
113// printf("linking %s\n", entry->d_name); 114// printf("linking %s\n", entry->d_name);
114 115
@@ -169,8 +170,11 @@ void fs_resolvconf(void) {
169 exit(1); 170 exit(1);
170 } 171 }
171 172
172 if (cfg.dns1) 173 if (cfg.dns1) {
174 if (any_dhcp())
175 fwarning("network setup uses DHCP, nameservers will likely be overwritten\n");
173 fprintf(fp, "nameserver %s\n", cfg.dns1); 176 fprintf(fp, "nameserver %s\n", cfg.dns1);
177 }
174 if (cfg.dns2) 178 if (cfg.dns2)
175 fprintf(fp, "nameserver %s\n", cfg.dns2); 179 fprintf(fp, "nameserver %s\n", cfg.dns2);
176 if (cfg.dns3) 180 if (cfg.dns3)