diff --git a/CMakeLists.txt b/CMakeLists.txt index a94c9041..38fce5a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ OPTION(BUILD_ENABLE_DEBUG "Enable Debug" ON ) OPTION(RELY_UDEV "Rely in udev tag to select device" OFF ) OPTION(BUILD_TESTS "Enable TEST" ON ) OPTION(BUILD_ENABLE_CPPCHECK "Enable CPPCheck static analysis" OFF ) +SET(IP_BINARY "/bin/ip" CACHE STRING "Path to ip binary") if(BUILD_ENABLE_DEBUG) add_definitions(-DBUILD_ENABLE_DEBUG) diff --git a/config.h.cmake b/config.h.cmake index ddc0cd19..f4689e44 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -2,6 +2,8 @@ #define CONFIG_H #cmakedefine BUILD_BINDIR "@BUILD_BINDIR@" +#cmakedefine RELY_UDEV @RELY_UDEV@ +#cmakedefine IP_BINARY @IP_BINARY@ #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" diff --git a/configure.ac b/configure.ac index 34a2eb0e..bdbce1b7 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,12 @@ AC_ARG_ENABLE([rely-udev], AS_HELP_STRING([--enable-rely-udev], [Use tagged device with miraclecast]), AC_DEFINE([RELY_UDEV], [], [Rely on udev to find miraclecast device])) AC_ARG_ENABLE([log-debug], AS_HELP_STRING([--disable-log-debug], [Disable log debug]), , AC_DEFINE([BUILD_ENABLE_DEBUG], [], [Enable debug log level])) +AC_ARG_VAR(IP_BINARY, [Path for ip binary]) +if test -z "$IP_BINARY"; then + IP_BINARY=/bin/ip +fi +AC_DEFINE_UNQUOTED([IP_BINARY], [$IP_BINARY], [Path for ip binary]) + # # Mandatory dependencies # @@ -166,6 +172,7 @@ AC_MSG_NOTICE([Build configuration: libdir: $libdir includedir: $includedir sysconfdir: $sysconfdir + ip-binary: $IP_BINARY Miscellaneous Options: building tests: $have_check @@ -183,6 +190,7 @@ AC_MSG_NOTICE([Build configuration: libdir: $libdir includedir: $includedir sysconfdir: $sysconfdir + ip-binary: $IP_BINARY Miscellaneous Options: building tests: $have_check diff --git a/meson.build b/meson.build index c74b9ba3..32beeb79 100644 --- a/meson.build +++ b/meson.build @@ -32,6 +32,8 @@ if get_option('rely-udev') add_project_arguments('-DRELY_UDEV', language: 'c') endif +add_project_arguments('-DIP_BINARY='+get_option('ip-binary'), language: 'c') + glib2 = dependency('glib-2.0') udev = dependency('libudev') libsystemd = dependency('libsystemd') diff --git a/meson_options.txt b/meson_options.txt index 34002ffc..86a6862e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,3 +10,7 @@ option('build-tests', type: 'boolean', value: true, description: 'Enable TEST') +option('ip-binary', + type: 'string', + value: '/bin/ip', + description: 'Path for ip binary') diff --git a/src/dhcp/dhcp.c b/src/dhcp/dhcp.c index 5457764f..6838ae9e 100644 --- a/src/dhcp/dhcp.c +++ b/src/dhcp/dhcp.c @@ -67,8 +67,11 @@ #include "shl_log.h" #include "config.h" +#define XSTR(x) STR(x) +#define STR(x) #x + static const char *arg_netdev; -static const char *arg_ip_binary = "/bin/ip"; +static const char *arg_ip_binary = XSTR(IP_BINARY); static bool arg_server; static char arg_local[INET_ADDRSTRLEN]; static char arg_gateway[INET_ADDRSTRLEN]; @@ -749,7 +752,7 @@ static int help(void) " --log-time Prefix log-messages with timestamp\n" "\n" " --netdev Network device to run on\n" - " --ip-binary Path to 'ip' binary [default: /bin/ip]\n" + " --ip-binary Path to 'ip' binary [default: "XSTR(IP_BINARY)"]\n" " --comm-fd Comm-socket FD passed through execve()\n" "\n" "Server Options:\n" diff --git a/src/wifi/wifid-link.c b/src/wifi/wifid-link.c index 1766e1ae..1093fc44 100644 --- a/src/wifi/wifid-link.c +++ b/src/wifi/wifid-link.c @@ -135,6 +135,7 @@ void link_free(struct link *l) free(l->friendly_name); free(l->ifname); free(l->config_methods); + free(l->ip_binary); free(l); } @@ -164,6 +165,22 @@ int link_set_config_methods(struct link *l, char *config_methods) return 0; } +int link_set_ip_binary(struct link *l, const char *ip_binary) +{ + char *ipb; + + if (!ip_binary) + return log_EINVAL(); + + ipb = strdup(ip_binary); + if (!ipb) + return log_ENOMEM(); + + free(l->ip_binary); + l->ip_binary = ipb; + return 0; +} + bool link_get_managed(struct link *l) { return l->managed; diff --git a/src/wifi/wifid-supplicant.c b/src/wifi/wifid-supplicant.c index fef362df..0f8f728d 100644 --- a/src/wifi/wifid-supplicant.c +++ b/src/wifi/wifid-supplicant.c @@ -397,6 +397,10 @@ static int supplicant_group_spawn_dhcp_server(struct supplicant_group *g, argv[i++] = g->ifname; argv[i++] = "--comm-fd"; argv[i++] = commfd; + if (g->s->l->ip_binary) { + argv[i++] = "--ip-binary"; + argv[i++] = g->s->l->ip_binary; + } argv[i] = NULL; if (execvpe(argv[0], argv, environ)< 0) { @@ -458,6 +462,10 @@ static int supplicant_group_spawn_dhcp_client(struct supplicant_group *g) argv[i++] = g->ifname; argv[i++] = "--comm-fd"; argv[i++] = commfd; + if (g->s->l->ip_binary) { + argv[i++] = "--ip-binary"; + argv[i++] = g->s->l->ip_binary; + } argv[i] = NULL; if (execvpe(argv[0], argv, environ) < 0) { diff --git a/src/wifi/wifid.c b/src/wifi/wifid.c index c8c2b539..7a45b941 100644 --- a/src/wifi/wifid.c +++ b/src/wifi/wifid.c @@ -40,12 +40,16 @@ #include "wifid.h" #include "config.h" +#define XSTR(x) STR(x) +#define STR(x) #x const char *interface_name = NULL; const char *config_methods = NULL; unsigned int arg_wpa_loglevel = LOG_NOTICE; bool arg_wpa_syslog = false; bool use_dev = false; bool lazy_managed = false; +const char *arg_ip_binary = NULL; + /* * Manager Handling @@ -111,6 +115,8 @@ static void manager_add_udev_link(struct manager *m, if(use_dev) link_use_dev(l); + if(arg_ip_binary) + link_set_ip_binary(l, arg_ip_binary); #ifdef RELY_UDEV bool managed = udev_device_has_tag(d, "miracle") && !lazy_managed; @@ -484,6 +490,7 @@ static int help(void) " --wpa-syslog wpa_supplicant use syslog\n" " --use-dev enable workaround for 'no ifname' issue\n" " --lazy-managed manage interface only when user decide to do\n" + " --ip-binary path to 'ip' binary [default: "XSTR(IP_BINARY)"]\n" , program_invocation_short_name); /* * 80-char barrier: @@ -504,6 +511,7 @@ static int parse_argv(int argc, char *argv[]) ARG_USE_DEV, ARG_CONFIG_METHODS, ARG_LAZY_MANAGED, + ARG_IP_BINARY, }; static const struct option options[] = { { "help", no_argument, NULL, 'h' }, @@ -517,6 +525,7 @@ static int parse_argv(int argc, char *argv[]) { "use-dev", no_argument, NULL, ARG_USE_DEV }, { "config-methods", required_argument, NULL, ARG_CONFIG_METHODS }, { "lazy-managed", no_argument, NULL, ARG_LAZY_MANAGED }, + { "ip-binary", required_argument, NULL, ARG_IP_BINARY }, {} }; int c; @@ -552,6 +561,9 @@ static int parse_argv(int argc, char *argv[]) case ARG_WPA_SYSLOG: arg_wpa_syslog = true; break; + case ARG_IP_BINARY: + arg_ip_binary = optarg; + break; case '?': return -EINVAL; } diff --git a/src/wifi/wifid.h b/src/wifi/wifid.h index d07c29f4..db78f189 100644 --- a/src/wifi/wifid.h +++ b/src/wifi/wifid.h @@ -130,6 +130,7 @@ struct link { char *friendly_name; char *wfd_subelements; char *config_methods; + char *ip_binary; size_t peer_cnt; struct shl_htable peers; @@ -159,6 +160,8 @@ void link_free(struct link *l); void link_use_dev(struct link *l); bool link_is_using_dev(struct link *l); +int link_set_ip_binary(struct link *l, const char *ip_binary); + int link_set_managed(struct link *l, bool set); bool link_get_managed(struct link *l); int link_renamed(struct link *l, const char *ifname);