diff options
Diffstat (limited to 'src/util/os_network.c')
-rw-r--r-- | src/util/os_network.c | 52 |
1 files changed, 43 insertions, 9 deletions
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 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
@@ -67,15 +67,29 @@ try_ifconfig (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
67 | struct sockaddr *pass_bcaddr; | 67 | struct sockaddr *pass_bcaddr; |
68 | struct sockaddr *pass_netmask; | 68 | struct sockaddr *pass_netmask; |
69 | int prefixlen; | 69 | int prefixlen; |
70 | static char *pcall; | ||
71 | |||
72 | if (NULL == pcall) | ||
73 | { | ||
74 | const char *sbin_ifconfig; | ||
70 | 75 | ||
71 | if (system ("ifconfig -a > /dev/null 2> /dev/null")) | 76 | #ifdef IFCONFIG |
72 | if (0 == system ("/sbin/ifconfig -a > /dev/null 2> /dev/null")) | 77 | if (0 == access (IFCONFIG, X_OK)) |
73 | f = popen ("/sbin/ifconfig -a 2> /dev/null", "r"); | 78 | sbin_ifconfig = IFCONFIG; |
74 | else | 79 | else |
75 | f = NULL; | 80 | #endif |
76 | else | 81 | if (0 == access ("/sbin/ifconfig", X_OK)) |
77 | f = popen ("ifconfig -a 2> /dev/null", "r"); | 82 | sbin_ifconfig = "/sbin/ifconfig"; |
78 | if (! f) | 83 | else if (0 == access ("/usr/sbin/ifconfig", X_OK)) |
84 | sbin_ifconfig = "/usr/sbin/ifconfig"; | ||
85 | else | ||
86 | sbin_ifconfig = "ifconfig"; | ||
87 | GNUNET_asprintf (&pcall, | ||
88 | "%s -a 2> /dev/null", | ||
89 | sbin_ifconfig); | ||
90 | } | ||
91 | f = popen (pcall, "r"); | ||
92 | if (NULL == f) | ||
79 | { | 93 | { |
80 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 94 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
81 | "popen", | 95 | "popen", |
@@ -238,8 +252,28 @@ try_ip (GNUNET_OS_NetworkInterfaceProcessor proc, | |||
238 | struct sockaddr_in6 netmask6; | 252 | struct sockaddr_in6 netmask6; |
239 | unsigned int i; | 253 | unsigned int i; |
240 | unsigned int prefixlen; | 254 | unsigned int prefixlen; |
255 | static char *pcall; | ||
241 | 256 | ||
242 | f = popen ("ip -o add 2> /dev/null", "r"); | 257 | if (NULL == pcall) |
258 | { | ||
259 | const char *sbin_ip; | ||
260 | |||
261 | #ifdef IFCONFIG | ||
262 | if (0 == access (PATH_TO_IP, X_OK)) | ||
263 | sbin_ip = PATH_TO_IP; | ||
264 | else | ||
265 | #endif | ||
266 | if (0 == access ("/sbin/ip", X_OK)) | ||
267 | sbin_ip = "/sbin/ip"; | ||
268 | else if (0 == access ("/usr/sbin/ip", X_OK)) | ||
269 | sbin_ip = "/usr/sbin/ip"; | ||
270 | else | ||
271 | sbin_ip = "if"; | ||
272 | GNUNET_asprintf (&pcall, | ||
273 | "%s -o add 2> /dev/null", | ||
274 | sbin_ip); | ||
275 | } | ||
276 | f = popen (pcall, "r"); | ||
243 | if (! f) | 277 | if (! f) |
244 | { | 278 | { |
245 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 279 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |