fix memleak
[oweals/gnunet.git] / src / dns / test_gnunet_dns.sh
1 #!/bin/bash
2
3 ME=`whoami`
4 if [ "$ME" != "root" ]
5 then
6   echo "This test only works if run as root.  Skipping."
7   exit 0
8 fi
9 if ! which sudo > /dev/null 
10 then
11   echo "This test requires sudo.  Skipping."
12 fi
13 if [ ! -x `which sudo` ]
14 then
15   echo "This test requires sudo.  Skipping."
16   exit 0
17 fi
18 if ! which nslookup
19 then 
20   echo "This test requires nslookup.  Skipping."
21   exit 0
22 fi
23 if [ ! -x `which nslookup` ]
24 then
25   echo "This test requires nslookup.  Skipping."
26   exit 0
27 fi
28 export PATH=".:$PATH"
29 gnunet-service-dns -c dns.conf &
30 gnunet-dns-redirector -c dns.conf -4 127.0.0.1 &
31 sleep 1
32 # need to run 'nslookup' as 'nobody', as gnunet-service-dns runs as root
33 # and thus 'root' is excepted from DNS interception!
34 LO=`sudo -u nobody nslookup gnunet.org | grep Address | tail -n1`
35 if [ "$LO" != "Address: 127.0.0.1" ]
36 then
37  echo "Fail: got address $LO, wanted 127.0.0.1"
38  ret=1
39 else
40  ret=0
41 fi
42 kill `jobs -p`
43 exit $ret