diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-18 12:47:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-18 12:47:52 +0000 |
commit | eaed2cc24c95f9c6188182b1373459d0855015b1 (patch) | |
tree | a0ecbba0ea5e5c3eecb19a53df7145597fb11fbd /src/exit/gnunet-helper-exit.c | |
parent | 6bdc9878c8027ca7e6c4fca5410d7569cea6fe12 (diff) | |
download | gnunet-eaed2cc24c95f9c6188182b1373459d0855015b1.tar.gz gnunet-eaed2cc24c95f9c6188182b1373459d0855015b1.zip |
-fixing #2082 -- allow iptables/ip/sysctl to also be in /usr/sbin
Diffstat (limited to 'src/exit/gnunet-helper-exit.c')
-rw-r--r-- | src/exit/gnunet-helper-exit.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c index d1db2a6e6..57944cf61 100644 --- a/src/exit/gnunet-helper-exit.c +++ b/src/exit/gnunet-helper-exit.c | |||
@@ -62,12 +62,12 @@ | |||
62 | /** | 62 | /** |
63 | * Path to 'sysctl' binary. | 63 | * Path to 'sysctl' binary. |
64 | */ | 64 | */ |
65 | #define SBIN_SYSCTL "/sbin/sysctl" | 65 | static const char *sbin_sysctl; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Path to 'iptables' binary. | 68 | * Path to 'iptables' binary. |
69 | */ | 69 | */ |
70 | #define SBIN_IPTABLES "/sbin/iptables" | 70 | static const char *sbin_iptables; |
71 | 71 | ||
72 | 72 | ||
73 | #ifndef _LINUX_IN6_H | 73 | #ifndef _LINUX_IN6_H |
@@ -615,6 +615,28 @@ main (int argc, char **argv) | |||
615 | fprintf (stderr, "Fatal: disabling both IPv4 and IPv6 makes no sense.\n"); | 615 | fprintf (stderr, "Fatal: disabling both IPv4 and IPv6 makes no sense.\n"); |
616 | return 1; | 616 | return 1; |
617 | } | 617 | } |
618 | if (0 == access ("/sbin/iptables", X_OK)) | ||
619 | sbin_iptables = "/sbin/iptables"; | ||
620 | else if (0 == access ("/usr/sbin/iptables", X_OK)) | ||
621 | sbin_iptables = "/usr/sbin/iptables"; | ||
622 | else | ||
623 | { | ||
624 | fprintf (stderr, | ||
625 | "Fatal: executable iptables not found in approved directories: %s\n", | ||
626 | strerror (errno)); | ||
627 | return 1; | ||
628 | } | ||
629 | if (0 == access ("/sbin/sysctl", X_OK)) | ||
630 | sbin_sysctl = "/sbin/sysctl"; | ||
631 | else if (0 == access ("/usr/sbin/sysctl", X_OK)) | ||
632 | sbin_sysctl = "/usr/sbin/sysctl"; | ||
633 | else | ||
634 | { | ||
635 | fprintf (stderr, | ||
636 | "Fatal: executable sysctl not found in approved directories: %s\n", | ||
637 | strerror (errno)); | ||
638 | return 1; | ||
639 | } | ||
618 | 640 | ||
619 | strncpy (dev, argv[1], IFNAMSIZ); | 641 | strncpy (dev, argv[1], IFNAMSIZ); |
620 | dev[IFNAMSIZ - 1] = '\0'; | 642 | dev[IFNAMSIZ - 1] = '\0'; |
@@ -643,7 +665,7 @@ main (int argc, char **argv) | |||
643 | { | 665 | { |
644 | "sysctl", "-w", "net.ipv6.conf.all.forwarding=1", NULL | 666 | "sysctl", "-w", "net.ipv6.conf.all.forwarding=1", NULL |
645 | }; | 667 | }; |
646 | if (0 != fork_and_exec (SBIN_SYSCTL, | 668 | if (0 != fork_and_exec (sbin_sysctl, |
647 | sysctl_args)) | 669 | sysctl_args)) |
648 | { | 670 | { |
649 | fprintf (stderr, | 671 | fprintf (stderr, |
@@ -665,7 +687,7 @@ main (int argc, char **argv) | |||
665 | { | 687 | { |
666 | "sysctl", "-w", "net.ipv4.ip_forward=1", NULL | 688 | "sysctl", "-w", "net.ipv4.ip_forward=1", NULL |
667 | }; | 689 | }; |
668 | if (0 != fork_and_exec (SBIN_SYSCTL, | 690 | if (0 != fork_and_exec (sbin_sysctl, |
669 | sysctl_args)) | 691 | sysctl_args)) |
670 | { | 692 | { |
671 | fprintf (stderr, | 693 | fprintf (stderr, |
@@ -678,7 +700,7 @@ main (int argc, char **argv) | |||
678 | { | 700 | { |
679 | "iptables", "-t", "nat", "-A", "POSTROUTING", "-o", argv[2], "-j", "MASQUERADE", NULL | 701 | "iptables", "-t", "nat", "-A", "POSTROUTING", "-o", argv[2], "-j", "MASQUERADE", NULL |
680 | }; | 702 | }; |
681 | if (0 != fork_and_exec (SBIN_IPTABLES, | 703 | if (0 != fork_and_exec (sbin_iptables, |
682 | iptables_args)) | 704 | iptables_args)) |
683 | { | 705 | { |
684 | fprintf (stderr, | 706 | fprintf (stderr, |