summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac56
-rw-r--r--src/dns/gnunet-helper-dns.c22
-rw-r--r--src/exit/gnunet-helper-exit.c12
-rw-r--r--src/util/os_network.c52
-rw-r--r--src/util/test_os_network.c30
6 files changed, 157 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 81ddd090e..31b0b637e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri 05 Apr 2019 11:38:53 PM CEST
+ Use paths of sysctl, ip, ifconfig and ip(6)tables from configure
+ if they work. (#5352). -CG
+
Thu 04 Apr 2019 12:39:44 PM CEST
Hotfix for build issue. Releasing GNUnet 0.11.2. -CG/MS
diff --git a/configure.ac b/configure.ac
index d9e6af74d..fbc447acb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,6 +244,49 @@ else
AC_MSG_WARN([warning: 'iptables' not found.])
fi
+# ip6tables is a soft requirement for some features
+AC_PATH_TARGET_TOOL(VAR_IP6TABLES_BINARY, ip6tables, false)
+
+if test x"$VAR_IP6TABLES_BINARY" = x"false"
+then
+ if test -x "/sbin/ip6tables"
+ then
+ VAR_IP6TABLES_BINARY="/sbin/ip6tables"
+ elif test -x "/usr/sbin/ip6tables"
+ then
+ VAR_IP6TABLES_BINARY="/usr/sbin/ip6tables"
+ fi
+fi
+
+if test x"$VAR_IP6TABLES_BINARY" != x"false"
+then
+AC_DEFINE_UNQUOTED([IP6TABLES], "$VAR_IP6TABLES_BINARY", [Path to ip6tables])
+else
+AC_MSG_WARN([warning: 'ip6tables' not found.])
+fi
+
+# ip is a soft requirement for some features
+AC_PATH_TARGET_TOOL(VAR_IP_BINARY, ip, false)
+
+if test x"$VAR_IP_BINARY" = x"false"
+then
+ if test -x "/sbin/ip"
+ then
+ VAR_IP_BINARY="/sbin/ip"
+ elif test -x "/usr/sbin/ip"
+ then
+ VAR_IP_BINARY="/usr/sbin/ip"
+ fi
+fi
+
+if test x"$VAR_IP_BINARY" != x"false"
+then
+AC_DEFINE_UNQUOTED([PATH_TO_IP], "$VAR_IP_BINARY", [Path to ip])
+else
+AC_MSG_WARN([warning: 'ip' not found.])
+fi
+
+# locate 'ifconfig'
AC_PATH_TARGET_TOOL(VAR_IFCONFIG_BINARY, ifconfig, false)
AC_CHECK_PROG(VAR_IFCONFIG_BINARY, ifconfig, true, false)
@@ -264,6 +307,19 @@ else
AC_MSG_WARN(['ifconfig' not found.])
fi
+
+AC_PATH_TARGET_TOOL(VAR_SYSCTL_BINARY, sysctl, false)
+
+AC_CHECK_PROG(VAR_SYSCTL_BINARY, sysctl, true, false)
+AS_IF([test x"$VAR_SYSCTL_BINARY" = x"false"],
+ [AS_IF([test -x "/sbin/sysctl"],
+ [VAR_SYSCTL_BINARY="/sbin/sysctl"],
+ [AS_IF([test -x "/usr/sbin/sysctl"],
+ [VAR_SYSCTL_BINARY="/usr/sbin/sysctl"])])])
+AS_IF([test x"$VAR_SYSCTL_BINARY" != x"false"],
+ [AC_DEFINE_UNQUOTED([SYSCTL], "$VAR_SYSCTL_BINARY", [Path to sysctl])],
+ [AC_MSG_WARN(['sysctl' not found.])])
+
# miniupnpc / upnpc binary is a soft runtime requirement
AC_PATH_TARGET_TOOL(VAR_UPNPC_BINARY, upnpc, false)
diff --git a/src/dns/gnunet-helper-dns.c b/src/dns/gnunet-helper-dns.c
index fb970224a..554727094 100644
--- a/src/dns/gnunet-helper-dns.c
+++ b/src/dns/gnunet-helper-dns.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -768,6 +768,11 @@ main (int argc, char *const*argv)
if (0 == nortsetup)
{
/* verify that the binaries we care about are executable */
+#ifdef IPTABLES
+ if (0 == access (IPTABLES, X_OK))
+ sbin_iptables = IPTABLES;
+ else
+#endif
if (0 == access ("/sbin/iptables", X_OK))
sbin_iptables = "/sbin/iptables";
else if (0 == access ("/usr/sbin/iptables", X_OK))
@@ -779,6 +784,11 @@ main (int argc, char *const*argv)
strerror (errno));
return 3;
}
+#ifdef IP6TABLES
+ if (0 == access (IP6TABLES, X_OK))
+ sbin_ip6tables = IP6TABLES;
+ else
+#endif
if (0 == access ("/sbin/ip6tables", X_OK))
sbin_ip6tables = "/sbin/ip6tables";
else if (0 == access ("/usr/sbin/ip6tables", X_OK))
@@ -790,6 +800,11 @@ main (int argc, char *const*argv)
strerror (errno));
return 3;
}
+#ifdef PATH_TO_IP
+ if (0 == access (PATH_TO_IP, X_OK))
+ sbin_ip = PATH_TO_IP;
+ else
+#endif
if (0 == access ("/sbin/ip", X_OK))
sbin_ip = "/sbin/ip";
else if (0 == access ("/usr/sbin/ip", X_OK))
@@ -803,6 +818,11 @@ main (int argc, char *const*argv)
strerror (errno));
return 4;
}
+#ifdef SYSCTL
+ if (0 == access (SYSCTL, X_OK))
+ sbin_sysctl = SYSCTL;
+ else
+#endif
if (0 == access ("/sbin/sysctl", X_OK))
sbin_sysctl = "/sbin/sysctl";
else if (0 == access ("/usr/sbin/sysctl", X_OK))
diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c
index de9ea39be..cda38710f 100644
--- a/src/exit/gnunet-helper-exit.c
+++ b/src/exit/gnunet-helper-exit.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -670,6 +670,11 @@ main (int argc, char **argv)
}
if (0 != strcmp (argv[2], "-"))
{
+#ifdef IPTABLES
+ if (0 == access (IPTABLES, X_OK))
+ sbin_iptables = IPTABLES;
+ else
+#endif
if (0 == access ("/sbin/iptables", X_OK))
sbin_iptables = "/sbin/iptables";
else if (0 == access ("/usr/sbin/iptables", X_OK))
@@ -681,6 +686,11 @@ main (int argc, char **argv)
strerror (errno));
return 1;
}
+#ifdef SYSCTL
+ if (0 == access (SYSCTL, X_OK))
+ sbin_sysctl = SYSCTL;
+ else
+#endif
if (0 == access ("/sbin/sysctl", X_OK))
sbin_sysctl = "/sbin/sysctl";
else if (0 == access ("/usr/sbin/sysctl", X_OK))
diff --git a/src/util/os_network.c b/src/util/os_network.c
index dba61f1e4..9008c5c5a 100644
--- a/src/util/os_network.c
+++ b/src/util/os_network.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -67,15 +67,29 @@ try_ifconfig (GNUNET_OS_NetworkInterfaceProcessor proc,
struct sockaddr *pass_bcaddr;
struct sockaddr *pass_netmask;
int prefixlen;
+ static char *pcall;
+
+ if (NULL == pcall)
+ {
+ const char *sbin_ifconfig;
- if (system ("ifconfig -a > /dev/null 2> /dev/null"))
- if (0 == system ("/sbin/ifconfig -a > /dev/null 2> /dev/null"))
- f = popen ("/sbin/ifconfig -a 2> /dev/null", "r");
+#ifdef IFCONFIG
+ if (0 == access (IFCONFIG, X_OK))
+ sbin_ifconfig = IFCONFIG;
else
- f = NULL;
- else
- f = popen ("ifconfig -a 2> /dev/null", "r");
- if (! f)
+#endif
+ if (0 == access ("/sbin/ifconfig", X_OK))
+ sbin_ifconfig = "/sbin/ifconfig";
+ else if (0 == access ("/usr/sbin/ifconfig", X_OK))
+ sbin_ifconfig = "/usr/sbin/ifconfig";
+ else
+ sbin_ifconfig = "ifconfig";
+ GNUNET_asprintf (&pcall,
+ "%s -a 2> /dev/null",
+ sbin_ifconfig);
+ }
+ f = popen (pcall, "r");
+ if (NULL == f)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
"popen",
@@ -238,8 +252,28 @@ try_ip (GNUNET_OS_NetworkInterfaceProcessor proc,
struct sockaddr_in6 netmask6;
unsigned int i;
unsigned int prefixlen;
+ static char *pcall;
- f = popen ("ip -o add 2> /dev/null", "r");
+ if (NULL == pcall)
+ {
+ const char *sbin_ip;
+
+#ifdef IFCONFIG
+ if (0 == access (PATH_TO_IP, X_OK))
+ sbin_ip = PATH_TO_IP;
+ else
+#endif
+ if (0 == access ("/sbin/ip", X_OK))
+ sbin_ip = "/sbin/ip";
+ else if (0 == access ("/usr/sbin/ip", X_OK))
+ sbin_ip = "/usr/sbin/ip";
+ else
+ sbin_ip = "if";
+ GNUNET_asprintf (&pcall,
+ "%s -o add 2> /dev/null",
+ sbin_ip);
+ }
+ f = popen (pcall, "r");
if (! f)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
diff --git a/src/util/test_os_network.c b/src/util/test_os_network.c
index b6e981bc3..fa769de6f 100644
--- a/src/util/test_os_network.c
+++ b/src/util/test_os_network.c
@@ -11,7 +11,7 @@
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -31,8 +31,12 @@
* (success).
*/
static int
-proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr,
- const struct sockaddr *broadcast_addr, const struct sockaddr *netmask,
+proc (void *cls,
+ const char *name,
+ int isDefault,
+ const struct sockaddr *addr,
+ const struct sockaddr *broadcast_addr,
+ const struct sockaddr *netmask,
socklen_t addrlen)
{
int *ok = cls;
@@ -46,11 +50,18 @@ proc (void *cls, const char *name, int isDefault, const struct sockaddr *addr,
else
protocol = "IPv6";
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%s Address `%s'\n", protocol, GNUNET_a2s ((const struct sockaddr *) addr,addrlen) );
+ "%s Address `%s'\n",
+ protocol,
+ GNUNET_a2s ((const struct sockaddr *) addr,
+ addrlen) );
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Netmask `%s'\n", GNUNET_a2s ((const struct sockaddr *) netmask, addrlen) );
+ "Netmask `%s'\n",
+ GNUNET_a2s ((const struct sockaddr *) netmask,
+ addrlen) );
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s'\n", GNUNET_a2s ((const struct sockaddr *) broadcast_addr,addrlen) );
+ "`%s'\n",
+ GNUNET_a2s ((const struct sockaddr *) broadcast_addr,
+ addrlen) );
inet_ntop (addr->sa_family,
(addr->sa_family ==
AF_INET) ? (void *) &((struct sockaddr_in *) addr)->sin_addr
@@ -67,9 +78,12 @@ main (int argc, char *argv[])
{
int ret;
- GNUNET_log_setup ("test-os-network", "WARNING", NULL);
+ GNUNET_log_setup ("test-os-network",
+ "WARNING",
+ NULL);
ret = 1;
- GNUNET_OS_network_interfaces_list (&proc, &ret);
+ GNUNET_OS_network_interfaces_list (&proc,
+ &ret);
return ret;
}