From fc5edbced21973e4309d5f77f5384f70defa0cd8 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 6 Apr 2016 10:28:04 -0400 Subject: grsecurity: --dns.print --- src/firejail/network_main.c | 2 ++ test/dns-print.exp | 21 +++++++++++++++++++++ test/test.sh | 3 +++ 3 files changed, 26 insertions(+) create mode 100755 test/dns-print.exp diff --git a/src/firejail/network_main.c b/src/firejail/network_main.c index 80f3bd579..e6d5cd5d7 100644 --- a/src/firejail/network_main.c +++ b/src/firejail/network_main.c @@ -247,7 +247,9 @@ void net_dns_print(pid_t pid) { // drop privileges - will not be able to read /etc/resolv.conf for --noroot option // if the pid is that of a firejail process, use the pid of the first child process + EUID_ROOT(); char *comm = pid_proc_comm(pid); + EUID_USER(); if (comm) { if (strcmp(comm, "firejail") == 0) { pid_t child; diff --git a/test/dns-print.exp b/test/dns-print.exp new file mode 100755 index 000000000..ee7b08e5e --- /dev/null +++ b/test/dns-print.exp @@ -0,0 +1,21 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test --dns=1.2.3.4\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --dns.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "nameserver 1.2.3.4" +} +sleep 1 +puts "\nall done\n" diff --git a/test/test.sh b/test/test.sh index 417d41810..d36fbcb75 100755 --- a/test/test.sh +++ b/test/test.sh @@ -9,6 +9,9 @@ echo "TESTING: fs.print (fs-print.exp)" ./fs-print.exp +echo "TESTING: dns.print (dns-print.exp)" +./dns-print.exp + echo "TESTING: caps.print (caps-print.exp)" ./caps-print.exp -- cgit v1.2.3-54-g00ecf