2 This file is part of GNUnet.
3 (C) 2010, 2011, 2012 Christian Grothoff
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file dns/gnunet-helper-dns.c
23 * @brief helper to install firewall rules to hijack all DNS traffic
24 * and send it to our virtual interface (except for DNS traffic
25 * that originates on the specified port). We then
26 * allow interacting with our virtual interface via stdin/stdout.
27 * @author Philipp Tölke
28 * @author Christian Grothoff
30 * This program alters the Linux firewall rules so that DNS traffic
31 * that ordinarily exits the system can be intercepted and managed by
32 * a virtual interface. In order to achieve this, DNS traffic is
33 * marked with the DNS_MARK given in below and re-routed to a custom
34 * table with the DNS_TABLE ID given below. Systems and
35 * administrators must take care to not cause conflicts with these
36 * values (it was deemed safest to hardcode them as passing these
37 * values as arguments might permit messing with arbitrary firewall
38 * rules, which would be dangerous). Traffic coming from the same
39 * group ID as the effective group ID that this process is running
40 * as is not intercepted.
42 * The code first sets up the virtual interface, then begins to
43 * redirect the DNS traffic to it, and then on errors or SIGTERM shuts
44 * down the virtual interface and removes the rules for the traffic
48 * Note that having this binary SUID is only partially safe: it will
49 * allow redirecting (and intercepting / mangling) of all DNS traffic
50 * originating from this system by any user who is able to run it.
51 * Furthermore, this code will make it trivial to DoS all DNS traffic
52 * originating from the current system, simply by sending it to
53 * nowhere (redirect stdout to /dev/null).
55 * Naturally, neither of these problems can be helped as this is the
56 * fundamental purpose of the binary. Certifying that this code is
57 * "safe" thus only means that it doesn't allow anything else (such
58 * as local priv. escalation, etc.).
60 * The following list of people have reviewed this code and considered
61 * it safe (within specifications) since the last modification (if you
62 * reviewed it, please have your name added to the list):
64 * - Christian Grothoff
68 #include <linux/if_tun.h>
71 * Need 'struct GNUNET_MessageHeader'.
73 #include "gnunet_crypto_lib.h"
74 #include "gnunet_common.h"
77 * Need DNS message types.
79 #include "gnunet_protocols.h"
82 * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE)
84 #define MAX_SIZE 65536
88 * This is in linux/include/net/ipv6.h, but not always exported...
92 struct in6_addr ifr6_addr;
93 uint32_t ifr6_prefixlen;
94 unsigned int ifr6_ifindex;
99 * Name and full path of IPTABLES binary.
101 static const char *sbin_iptables;
104 * Name and full path of sysctl binary
106 static const char *sbin_sysctl;
109 * Name and full path of IPTABLES binary.
111 static const char *sbin_ip;
114 * Port for DNS traffic.
116 #define DNS_PORT "53"
119 * Marker we set for our hijacked DNS traffic. We use GNUnet's
120 * port (2086) plus the DNS port (53) in HEX to make a 32-bit mark
121 * (which is hopefully long enough to not collide); so
122 * 0x08260035 = 136708149 (hopefully unique enough...).
124 #define DNS_MARK "136708149"
127 * Table we use for our DNS rules. 0-255 is the range and
128 * 0, 253, 254 and 255 are already reserved. As this is about
129 * DNS and as "53" is likely (fingers crossed!) high enough to
130 * not usually conflict with a normal user's setup, we use 53
131 * to give a hint that this has something to do with DNS.
133 #define DNS_TABLE "53"
137 * Control pipe for shutdown via signal. [0] is the read end,
138 * [1] is the write end.
144 * Signal handler called to initiate "nice" shutdown. Signals select
145 * loop via non-bocking pipe 'cpipe'.
147 * @param signal signal number of the signal (not used)
150 signal_handler (int signal)
152 /* ignore return value, as the signal handler could theoretically
153 be called many times before the shutdown can actually happen */
154 (void) write (cpipe[1], "K", 1);
159 * Open '/dev/null' and make the result the given
162 * @param target_fd desired FD to point to /dev/null
163 * @param flags open flags (O_RDONLY, O_WRONLY)
166 open_dev_null (int target_fd,
171 fd = open ("/dev/null", flags);
176 if (-1 == dup2 (fd, target_fd))
186 * Run the given command and wait for it to complete.
188 * @param file name of the binary to run
189 * @param cmd command line arguments (as given to 'execv')
190 * @return 0 on success, 1 on any error
193 fork_and_exec (const char *file,
210 /* we are the child process */
211 /* close stdin/stdout to not cause interference
212 with the helper's main protocol! */
214 open_dev_null (0, O_RDONLY);
216 open_dev_null (1, O_WRONLY);
217 (void) execv (file, cmd);
218 /* can only get here on error */
220 "exec `%s' failed: %s\n",
225 /* keep running waitpid as long as the only error we get is 'EINTR' */
226 while ( (-1 == (ret = waitpid (pid, &status, 0))) &&
231 "waitpid failed: %s\n",
235 if (! (WIFEXITED (status) && (0 == WEXITSTATUS (status))))
237 /* child process completed and returned success, we're happy */
243 * Creates a tun-interface called dev;
245 * @param dev is asumed to point to a char[IFNAMSIZ]
246 * if *dev == '\\0', uses the name supplied by the kernel;
247 * @return the fd to the tun or -1 on error
261 if (-1 == (fd = open ("/dev/net/tun", O_RDWR)))
263 fprintf (stderr, "Error opening `%s': %s\n", "/dev/net/tun",
268 if (fd >= FD_SETSIZE)
270 fprintf (stderr, "File descriptor to large: %d", fd);
275 memset (&ifr, 0, sizeof (ifr));
276 ifr.ifr_flags = IFF_TUN;
279 strncpy (ifr.ifr_name, dev, IFNAMSIZ);
281 if (-1 == ioctl (fd, TUNSETIFF, (void *) &ifr))
283 fprintf (stderr, "Error with ioctl on `%s': %s\n", "/dev/net/tun",
288 strcpy (dev, ifr.ifr_name);
294 * @brief Sets the IPv6-Address given in address on the interface dev
296 * @param dev the interface to configure
297 * @param address the IPv6-Address
298 * @param prefix_len the length of the network-prefix
301 set_address6 (const char *dev, const char *address, unsigned long prefix_len)
304 struct in6_ifreq ifr6;
305 struct sockaddr_in6 sa6;
309 * parse the new address
311 memset (&sa6, 0, sizeof (struct sockaddr_in6));
312 sa6.sin6_family = AF_INET6;
313 if (1 != inet_pton (AF_INET6, address, sa6.sin6_addr.s6_addr))
316 "Failed to parse IPv6 address `%s': %s\n",
322 if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0)))
325 "Error creating IPv6 socket: %s (ignored)\n",
327 /* ignore error, maybe only IPv4 works on this system! */
331 memset (&ifr, 0, sizeof (struct ifreq));
333 * Get the index of the if
335 strncpy (ifr.ifr_name, dev, IFNAMSIZ);
336 if (-1 == ioctl (fd, SIOGIFINDEX, &ifr))
338 fprintf (stderr, "ioctl failed at %d: %s\n", __LINE__, strerror (errno));
343 memset (&ifr6, 0, sizeof (struct in6_ifreq));
344 ifr6.ifr6_addr = sa6.sin6_addr;
345 ifr6.ifr6_ifindex = ifr.ifr_ifindex;
346 ifr6.ifr6_prefixlen = prefix_len;
351 if (-1 == ioctl (fd, SIOCSIFADDR, &ifr6))
353 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
362 if (-1 == ioctl (fd, SIOCGIFFLAGS, &ifr))
364 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
371 * Add the UP and RUNNING flags
373 ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
374 if (-1 == ioctl (fd, SIOCSIFFLAGS, &ifr))
376 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
384 fprintf (stderr, "close failed: %s\n", strerror (errno));
391 * @brief Sets the IPv4-Address given in address on the interface dev
393 * @param dev the interface to configure
394 * @param address the IPv4-Address
395 * @param mask the netmask
398 set_address4 (const char *dev, const char *address, const char *mask)
401 struct sockaddr_in *addr;
404 memset (&ifr, 0, sizeof (struct ifreq));
405 addr = (struct sockaddr_in *) &(ifr.ifr_addr);
406 addr->sin_family = AF_INET;
411 if (1 != inet_pton (AF_INET, address, &addr->sin_addr.s_addr))
414 "Failed to parse IPv4 address `%s': %s\n",
420 if (-1 == (fd = socket (PF_INET, SOCK_DGRAM, 0)))
423 "Error creating IPv4 socket: %s\n",
428 strncpy (ifr.ifr_name, dev, IFNAMSIZ);
433 if (-1 == ioctl (fd, SIOCSIFADDR, &ifr))
435 fprintf (stderr, "ioctl failed at %d: %s\n", __LINE__, strerror (errno));
443 addr = (struct sockaddr_in *) &(ifr.ifr_netmask);
444 if (1 != inet_pton (AF_INET, mask, &addr->sin_addr.s_addr))
446 fprintf (stderr, "Failed to parse address `%s': %s\n", mask,
455 if (-1 == ioctl (fd, SIOCSIFNETMASK, &ifr))
457 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
466 if (-1 == ioctl (fd, SIOCGIFFLAGS, &ifr))
468 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
475 * Add the UP and RUNNING flags
477 ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
478 if (-1 == ioctl (fd, SIOCSIFFLAGS, &ifr))
480 fprintf (stderr, "ioctl failed at line %d: %s\n", __LINE__,
488 fprintf (stderr, "close failed: %s\n", strerror (errno));
496 * Start forwarding to and from the tunnel. This function runs with
497 * "reduced" priviledges (saved UID is still 0, but effective UID is
500 * @param fd_tun tunnel FD
506 * The buffer filled by reading from fd_tun
508 unsigned char buftun[MAX_SIZE];
509 ssize_t buftun_size = 0;
510 unsigned char *buftun_read = NULL;
513 * The buffer filled by reading from stdin
515 unsigned char bufin[MAX_SIZE];
516 ssize_t bufin_size = 0;
517 size_t bufin_rpos = 0;
518 unsigned char *bufin_read = NULL;
529 * We are supposed to read and the buffer is empty
530 * -> select on read from tun
532 if (0 == buftun_size)
533 FD_SET (fd_tun, &fds_r);
536 * We are supposed to read and the buffer is not empty
537 * -> select on write to stdout
543 * We are supposed to write and the buffer is empty
544 * -> select on read from stdin
546 if (NULL == bufin_read)
550 * We are supposed to write and the buffer is not empty
551 * -> select on write to tun
553 if (NULL != bufin_read)
554 FD_SET (fd_tun, &fds_w);
556 FD_SET (cpipe[0], &fds_r);
557 max = (fd_tun > cpipe[0]) ? fd_tun : cpipe[0];
559 int r = select (max + 1, &fds_r, &fds_w, NULL, NULL);
565 fprintf (stderr, "select failed: %s\n", strerror (errno));
571 if (FD_ISSET (cpipe[0], &fds_r))
572 return; /* aborted by signal */
574 if (FD_ISSET (fd_tun, &fds_r))
577 read (fd_tun, buftun + sizeof (struct GNUNET_MessageHeader),
578 MAX_SIZE - sizeof (struct GNUNET_MessageHeader));
579 if (-1 == buftun_size)
581 if ( (errno == EINTR) ||
587 fprintf (stderr, "read-error: %s\n", strerror (errno));
590 if (0 == buftun_size)
592 fprintf (stderr, "EOF on tun\n");
595 buftun_read = buftun;
597 struct GNUNET_MessageHeader *hdr =
598 (struct GNUNET_MessageHeader *) buftun;
599 buftun_size += sizeof (struct GNUNET_MessageHeader);
600 hdr->type = htons (GNUNET_MESSAGE_TYPE_DNS_HELPER);
601 hdr->size = htons (buftun_size);
604 else if (FD_ISSET (1, &fds_w))
606 ssize_t written = write (1, buftun_read, buftun_size);
610 if ( (errno == EINTR) ||
613 fprintf (stderr, "write-error to stdout: %s\n", strerror (errno));
618 fprintf (stderr, "write returned 0\n");
621 buftun_size -= written;
622 buftun_read += written;
625 if (FD_ISSET (0, &fds_r))
627 bufin_size = read (0, bufin + bufin_rpos, MAX_SIZE - bufin_rpos);
628 if (-1 == bufin_size)
631 if ( (errno == EINTR) ||
634 fprintf (stderr, "read-error: %s\n", strerror (errno));
640 fprintf (stderr, "EOF on stdin\n");
644 struct GNUNET_MessageHeader *hdr;
647 bufin_rpos += bufin_size;
648 if (bufin_rpos < sizeof (struct GNUNET_MessageHeader))
650 hdr = (struct GNUNET_MessageHeader *) bufin;
651 if (ntohs (hdr->type) != GNUNET_MESSAGE_TYPE_DNS_HELPER)
653 fprintf (stderr, "protocol violation!\n");
656 if (ntohs (hdr->size) > bufin_rpos)
658 bufin_read = bufin + sizeof (struct GNUNET_MessageHeader);
659 bufin_size = ntohs (hdr->size) - sizeof (struct GNUNET_MessageHeader);
660 bufin_rpos -= bufin_size + sizeof (struct GNUNET_MessageHeader);
663 else if (FD_ISSET (fd_tun, &fds_w))
665 ssize_t written = write (fd_tun, bufin_read, bufin_size);
669 if ( (errno == EINTR) ||
672 fprintf (stderr, "write-error to tun: %s\n", strerror (errno));
677 fprintf (stderr, "write returned 0\n");
681 bufin_size -= written;
682 bufin_read += written;
685 memmove (bufin, bufin_read, bufin_rpos);
686 bufin_read = NULL; /* start reading again */
698 * Main function of "gnunet-helper-dns", which opens a VPN tunnel interface,
699 * redirects all outgoing DNS traffic (except from the specified port) to that
700 * interface and then passes traffic from and to the interface via stdin/stdout.
702 * Once stdin/stdout close or have other errors, the tunnel is closed and the
703 * DNS traffic redirection is stopped.
705 * @param argc number of arguments
706 * @param argv 0: binary name (should be "gnunet-helper-vpn")
707 * 1: tunnel interface name (typically "gnunet-dns")
708 * 2: IPv6 address for the tunnel ("FE80::1")
709 * 3: IPv6 netmask length in bits ("64")
710 * 4: IPv4 address for the tunnel ("1.2.3.4")
711 * 5: IPv4 netmask ("255.255.0.0")
712 * @return 0 on success, otherwise code indicating type of error:
713 * 1 wrong number of arguments
714 * 2 invalid arguments (i.e. port number / prefix length wrong)
715 * 3 iptables not executable
716 * 4 ip not executable
717 * 5 failed to initialize tunnel interface
718 * 6 failed to initialize control pipe
719 * 8 failed to change routing table, cleanup successful
720 * 9-23 failed to change routing table and failed to undo some changes to routing table
721 * 24 failed to drop privs
722 * 25-39 failed to drop privs and then failed to undo some changes to routing table
723 * 40 failed to regain privs
724 * 41-55 failed to regain prisv and then failed to undo some changes to routing table
725 * 254 insufficient priviledges
726 * 255 failed to handle kill signal properly
729 main (int argc, char *const*argv)
739 fprintf (stderr, "Fatal: must supply 6 arguments!\n");
743 /* assert privs so we can modify the firewall rules! */
745 #ifdef HAVE_SETRESUID
746 if (0 != setresuid (uid, 0, 0))
748 fprintf (stderr, "Failed to setresuid to root: %s\n", strerror (errno));
752 if (0 != seteuid (0))
754 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
759 /* verify that the binaries were care about are executable */
760 if (0 == access ("/sbin/iptables", X_OK))
761 sbin_iptables = "/sbin/iptables";
762 else if (0 == access ("/usr/sbin/iptables", X_OK))
763 sbin_iptables = "/usr/sbin/iptables";
767 "Fatal: executable iptables not found in approved directories: %s\n",
771 if (0 == access ("/sbin/ip", X_OK))
772 sbin_ip = "/sbin/ip";
773 else if (0 == access ("/usr/sbin/ip", X_OK))
774 sbin_ip = "/usr/sbin/ip";
778 "Fatal: executable ip not found in approved directories: %s\n",
782 if (0 == access ("/sbin/sysctl", X_OK))
783 sbin_sysctl = "/sbin/sysctl";
784 else if (0 == access ("/usr/sbin/sysctl", X_OK))
785 sbin_sysctl = "/usr/sbin/sysctl";
789 "Fatal: executable sysctl not found in approved directories: %s\n",
794 /* setup 'mygid' string */
795 snprintf (mygid, sizeof (mygid), "%d", (int) getegid());
797 /* do not die on SIGPIPE */
798 if (SIG_ERR == signal (SIGPIPE, SIG_IGN))
800 fprintf (stderr, "Failed to protect against SIGPIPE: %s\n",
805 /* setup pipe to shutdown nicely on SIGINT */
806 if (0 != pipe (cpipe))
809 "Fatal: could not setup control pipe: %s\n",
813 if (cpipe[0] >= FD_SETSIZE)
815 fprintf (stderr, "Pipe file descriptor to large: %d", cpipe[0]);
816 (void) close (cpipe[0]);
817 (void) close (cpipe[1]);
821 /* make pipe non-blocking, as we theoretically could otherwise block
822 in the signal handler */
823 int flags = fcntl (cpipe[1], F_GETFL);
826 fprintf (stderr, "Failed to read flags for pipe: %s", strerror (errno));
827 (void) close (cpipe[0]);
828 (void) close (cpipe[1]);
832 if (0 != fcntl (cpipe[1], F_SETFL, flags))
834 fprintf (stderr, "Failed to make pipe non-blocking: %s", strerror (errno));
835 (void) close (cpipe[0]);
836 (void) close (cpipe[1]);
840 if ( (SIG_ERR == signal (SIGTERM, &signal_handler)) ||
841 #if (SIGTERM != GNUNET_TERM_SIG)
842 (SIG_ERR == signal (GNUNET_TERM_SIG, &signal_handler)) ||
844 (SIG_ERR == signal (SIGINT, &signal_handler)) ||
845 (SIG_ERR == signal (SIGHUP, &signal_handler)) )
848 "Fatal: could not initialize signal handler: %s\n",
850 (void) close (cpipe[0]);
851 (void) close (cpipe[1]);
856 /* get interface name */
857 strncpy (dev, argv[1], IFNAMSIZ);
858 dev[IFNAMSIZ - 1] = '\0';
860 /* Disable rp filtering */
862 char *const sysctl_args[] = {"sysctl", "-w",
863 "net.ipv4.conf.all.rp_filter=0", NULL};
864 char *const sysctl_args2[] = {"sysctl", "-w",
865 "net.ipv4.conf.default.rp_filter=0", NULL};
866 if ((0 != fork_and_exec (sbin_sysctl, sysctl_args)) ||
867 (0 != fork_and_exec (sbin_sysctl, sysctl_args2)))
870 "Failed to disable rp filtering.\n");
876 /* now open virtual interface (first part that requires root) */
877 if (-1 == (fd_tun = init_tun (dev)))
879 fprintf (stderr, "Fatal: could not initialize tun-interface\n");
880 (void) signal (SIGTERM, SIG_IGN);
881 #if (SIGTERM != GNUNET_TERM_SIG)
882 (void) signal (GNUNET_TERM_SIG, SIG_IGN);
884 (void) signal (SIGINT, SIG_IGN);
885 (void) signal (SIGHUP, SIG_IGN);
886 (void) close (cpipe[0]);
887 (void) close (cpipe[1]);
891 /* now set interface addresses */
893 const char *address = argv[2];
894 long prefix_len = atol (argv[3]);
896 if ((prefix_len < 1) || (prefix_len > 127))
898 fprintf (stderr, "Fatal: prefix_len out of range\n");
899 (void) signal (SIGTERM, SIG_IGN);
900 #if (SIGTERM != GNUNET_TERM_SIG)
901 (void) signal (GNUNET_TERM_SIG, SIG_IGN);
903 (void) signal (SIGINT, SIG_IGN);
904 (void) signal (SIGHUP, SIG_IGN);
905 (void) close (cpipe[0]);
906 (void) close (cpipe[1]);
909 set_address6 (dev, address, prefix_len);
913 const char *address = argv[4];
914 const char *mask = argv[5];
916 set_address4 (dev, address, mask);
920 /* update routing tables -- next part why we need SUID! */
921 /* Forward everything from our EGID (which should only be held
922 by the 'gnunet-service-dns') and with destination
923 to port 53 on UDP, without hijacking */
924 r = 8; /* failed to fully setup routing table */
926 char *const mangle_args[] =
928 "iptables", "-m", "owner", "-t", "mangle", "-I", "OUTPUT", "1", "-p",
929 "udp", "--gid-owner", mygid, "--dport", DNS_PORT, "-j",
932 if (0 != fork_and_exec (sbin_iptables, mangle_args))
935 /* Mark all of the other DNS traffic using our mark DNS_MARK */
937 char *const mark_args[] =
939 "iptables", "-t", "mangle", "-I", "OUTPUT", "2", "-p",
940 "udp", "--dport", DNS_PORT, "-j", "MARK", "--set-mark", DNS_MARK,
943 if (0 != fork_and_exec (sbin_iptables, mark_args))
944 goto cleanup_mangle_1;
946 /* Forward all marked DNS traffic to our DNS_TABLE */
948 char *const forward_args[] =
950 "ip", "rule", "add", "fwmark", DNS_MARK, "table", DNS_TABLE, NULL
952 if (0 != fork_and_exec (sbin_ip, forward_args))
955 /* Finally, add rule in our forwarding table to pass to our virtual interface */
957 char *const route_args[] =
959 "ip", "route", "add", "default", "dev", dev,
960 "table", DNS_TABLE, NULL
962 if (0 != fork_and_exec (sbin_ip, route_args))
963 goto cleanup_forward_3;
966 /* drop privs *except* for the saved UID; this is not perfect, but better
967 than doing nothing */
968 #ifdef HAVE_SETRESUID
969 if (0 != setresuid (uid, uid, 0))
971 fprintf (stderr, "Failed to setresuid: %s\n", strerror (errno));
973 goto cleanup_route_4;
976 /* Note: no 'setuid' here as we must keep our saved UID as root */
977 if (0 != seteuid (uid))
979 fprintf (stderr, "Failed to seteuid: %s\n", strerror (errno));
981 goto cleanup_route_4;
985 r = 0; /* did fully setup routing table (if nothing else happens, we were successful!) */
987 /* now forward until we hit a problem */
990 /* now need to regain privs so we can remove the firewall rules we added! */
991 #ifdef HAVE_SETRESUID
992 if (0 != setresuid (uid, 0, 0))
994 fprintf (stderr, "Failed to setresuid back to root: %s\n", strerror (errno));
996 goto cleanup_route_4;
999 if (0 != seteuid (0))
1001 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
1003 goto cleanup_route_4;
1007 /* update routing tables again -- this is why we could not fully drop privs */
1008 /* now undo updating of routing tables; normal exit or clean-up-on-error case */
1011 char *const route_clean_args[] =
1013 "ip", "route", "del", "default", "dev", dev,
1014 "table", DNS_TABLE, NULL
1016 if (0 != fork_and_exec (sbin_ip, route_clean_args))
1021 char *const forward_clean_args[] =
1023 "ip", "rule", "del", "fwmark", DNS_MARK, "table", DNS_TABLE, NULL
1025 if (0 != fork_and_exec (sbin_ip, forward_clean_args))
1030 char *const mark_clean_args[] =
1032 "iptables", "-t", "mangle", "-D", "OUTPUT", "-p", "udp",
1033 "--dport", DNS_PORT, "-j", "MARK", "--set-mark", DNS_MARK, NULL
1035 if (0 != fork_and_exec (sbin_iptables, mark_clean_args))
1040 char *const mangle_clean_args[] =
1042 "iptables", "-m", "owner", "-t", "mangle", "-D", "OUTPUT", "-p", "udp",
1043 "--gid-owner", mygid, "--dport", DNS_PORT, "-j", "ACCEPT",
1046 if (0 != fork_and_exec (sbin_iptables, mangle_clean_args))
1051 /* close virtual interface */
1052 (void) close (fd_tun);
1053 /* remove signal handler so we can close the pipes */
1054 (void) signal (SIGTERM, SIG_IGN);
1055 #if (SIGTERM != GNUNET_TERM_SIG)
1056 (void) signal (GNUNET_TERM_SIG, SIG_IGN);
1058 (void) signal (SIGINT, SIG_IGN);
1059 (void) signal (SIGHUP, SIG_IGN);
1060 (void) close (cpipe[0]);
1061 (void) close (cpipe[1]);
1065 /* end of gnunet-helper-dns.c */