From 23586eb49f2377bc031fcc68ff6e8ffda18fb146 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 12 Jun 2022 22:59:08 +0200 Subject: [PATCH] configure_network: remove hardcoded paths to ifup/ifdown Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/a897aafb6e22f1823f6e26405ac2582c173ab0c9 Author: vanhofen Date: 2022-06-12 (Sun, 12 Jun 2022) Origin message was: ------------------ - configure_network: remove hardcoded paths to ifup/ifdown --- src/system/configure_network.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/system/configure_network.cpp b/src/system/configure_network.cpp index 9d3ea4668..6a0570cac 100644 --- a/src/system/configure_network.cpp +++ b/src/system/configure_network.cpp @@ -214,26 +214,37 @@ void CNetworkConfig::commitConfig(void) void CNetworkConfig::startNetwork(void) { - std::string cmd = "/sbin/ifup " + ifname; + std::string ifup = find_executable("ifup"); + if (ifup.empty()) + { + printf("CNetworkConfig::startNetwork: ifup not found\n"); + return; + } + + std::string cmd = ifup + " " + ifname; #ifdef DEBUG printf("CNetworkConfig::startNetwork: %s\n", cmd.c_str()); #endif my_system(3, "/bin/sh", "-c", cmd.c_str()); - if (!inet_static) { + if (!inet_static) init_vars(); - } - //mysystem((char *) "ifup", (char *) "-v", (char *) "eth0"); } void CNetworkConfig::stopNetwork(void) { - std::string cmd = "/sbin/ifdown " + ifname; + std::string ifdown = find_executable("ifdown"); + if (ifdown.empty()) + { + printf("CNetworkConfig::stopNetwork: ifdown not found\n"); + return; + } + + std::string cmd = ifdown + " " + ifname; #ifdef DEBUG printf("CNetworkConfig::stopNetwork: %s\n", cmd.c_str()); #endif my_system(3, "/bin/sh", "-c", cmd.c_str()); - } void CNetworkConfig::readWpaConfig()