2014-05-11 19:39:22 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2019-10-25 00:43:08 +02:00
|
|
|
* Copyright (C) 2013-2019 Intel Corporation. All rights reserved.
|
2014-05-11 19:39:22 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
#include <stdio.h>
|
2014-05-11 19:39:22 +02:00
|
|
|
#include <stdlib.h>
|
2018-05-03 21:45:26 +02:00
|
|
|
#include <errno.h>
|
2014-08-09 06:53:13 +02:00
|
|
|
#include <getopt.h>
|
2018-11-01 22:09:19 +01:00
|
|
|
#include <signal.h>
|
2014-05-11 19:39:22 +02:00
|
|
|
#include <ell/ell.h>
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
#include "linux/nl80211.h"
|
|
|
|
|
2016-05-12 04:59:03 +02:00
|
|
|
#include "src/iwd.h"
|
2019-11-07 23:33:51 +01:00
|
|
|
#include "src/module.h"
|
2014-07-29 21:25:01 +02:00
|
|
|
#include "src/wiphy.h"
|
2014-10-07 04:50:27 +02:00
|
|
|
#include "src/dbus.h"
|
2016-11-15 23:44:07 +01:00
|
|
|
#include "src/eap.h"
|
2015-09-29 02:51:40 +02:00
|
|
|
#include "src/eapol.h"
|
2016-07-02 16:42:39 +02:00
|
|
|
#include "src/rfkill.h"
|
2019-02-07 00:13:32 +01:00
|
|
|
#include "src/storage.h"
|
2019-06-27 00:15:55 +02:00
|
|
|
#include "src/anqp.h"
|
2015-03-02 15:19:08 +01:00
|
|
|
|
2016-04-13 21:07:36 +02:00
|
|
|
#include "src/backtrace.h"
|
|
|
|
|
2018-11-01 19:55:37 +01:00
|
|
|
static struct l_genl *genl;
|
2020-04-08 19:27:49 +02:00
|
|
|
static struct l_netlink *rtnl;
|
2016-11-02 22:04:37 +01:00
|
|
|
static struct l_settings *iwd_config;
|
2016-11-03 18:42:57 +01:00
|
|
|
static struct l_timeout *timeout;
|
2016-06-23 22:49:05 +02:00
|
|
|
static const char *interfaces;
|
|
|
|
static const char *nointerfaces;
|
2017-03-16 22:45:10 +01:00
|
|
|
static const char *phys;
|
|
|
|
static const char *nophys;
|
2018-05-20 01:29:28 +02:00
|
|
|
static const char *debugopt;
|
2021-05-05 20:23:53 +02:00
|
|
|
static bool developeropt;
|
2017-05-03 19:53:52 +02:00
|
|
|
static bool terminating;
|
2019-10-11 21:29:29 +02:00
|
|
|
static bool nl80211_complete;
|
2015-03-02 15:19:08 +01:00
|
|
|
|
|
|
|
static void main_loop_quit(struct l_timeout *timeout, void *user_data)
|
|
|
|
{
|
|
|
|
l_main_quit();
|
|
|
|
}
|
2014-05-21 06:44:13 +02:00
|
|
|
|
2018-09-12 03:06:00 +02:00
|
|
|
static void iwd_shutdown(void)
|
2017-05-03 19:53:51 +02:00
|
|
|
{
|
2017-05-03 19:53:52 +02:00
|
|
|
if (terminating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
terminating = true;
|
|
|
|
|
2019-10-11 21:29:29 +02:00
|
|
|
if (!nl80211_complete) {
|
2018-09-12 03:06:00 +02:00
|
|
|
l_main_quit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-03 19:53:51 +02:00
|
|
|
dbus_shutdown();
|
|
|
|
netdev_shutdown();
|
|
|
|
|
|
|
|
timeout = l_timeout_create(1, main_loop_quit, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2018-11-01 19:56:16 +01:00
|
|
|
static void signal_handler(uint32_t signo, void *user_data)
|
2014-05-11 19:39:22 +02:00
|
|
|
{
|
|
|
|
switch (signo) {
|
|
|
|
case SIGINT:
|
|
|
|
case SIGTERM:
|
|
|
|
l_info("Terminate");
|
2017-05-03 19:53:51 +02:00
|
|
|
iwd_shutdown();
|
2014-05-11 19:39:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 22:04:37 +01:00
|
|
|
const struct l_settings *iwd_get_config(void)
|
|
|
|
{
|
|
|
|
return iwd_config;
|
|
|
|
}
|
|
|
|
|
2019-05-18 00:05:52 +02:00
|
|
|
struct l_genl *iwd_get_genl(void)
|
|
|
|
{
|
|
|
|
return genl;
|
|
|
|
}
|
|
|
|
|
2020-04-08 19:27:49 +02:00
|
|
|
struct l_netlink *iwd_get_rtnl(void)
|
|
|
|
{
|
|
|
|
return rtnl;
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:29:26 +02:00
|
|
|
const char *iwd_get_iface_whitelist(void)
|
|
|
|
{
|
|
|
|
return interfaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *iwd_get_iface_blacklist(void)
|
|
|
|
{
|
|
|
|
return nointerfaces;
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:29:28 +02:00
|
|
|
const char *iwd_get_phy_whitelist(void)
|
|
|
|
{
|
|
|
|
return phys;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *iwd_get_phy_blacklist(void)
|
|
|
|
{
|
|
|
|
return nophys;
|
|
|
|
}
|
|
|
|
|
2021-05-05 20:23:53 +02:00
|
|
|
bool iwd_is_developer_mode(void)
|
|
|
|
{
|
|
|
|
return developeropt;
|
|
|
|
}
|
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
static void usage(void)
|
|
|
|
{
|
|
|
|
printf("iwd - Wireless daemon\n"
|
|
|
|
"Usage:\n");
|
|
|
|
printf("\tiwd [options]\n");
|
|
|
|
printf("Options:\n"
|
2021-05-25 20:30:29 +02:00
|
|
|
"\t-E, --developer Enable developer mode\n"
|
2016-06-23 22:49:05 +02:00
|
|
|
"\t-i, --interfaces Interfaces to manage\n"
|
|
|
|
"\t-I, --nointerfaces Interfaces to ignore\n"
|
2017-03-16 22:45:10 +01:00
|
|
|
"\t-p, --phys Phys to manage\n"
|
|
|
|
"\t-P, --nophys Phys to ignore\n"
|
2018-05-20 01:29:28 +02:00
|
|
|
"\t-d, --debug Enable debug output\n"
|
2019-07-12 10:01:33 +02:00
|
|
|
"\t-v, --version Show version\n"
|
2014-08-09 06:53:13 +02:00
|
|
|
"\t-h, --help Show help options\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct option main_options[] = {
|
2021-05-05 20:23:53 +02:00
|
|
|
{ "developer", no_argument, NULL, 'E' },
|
2016-06-23 22:49:05 +02:00
|
|
|
{ "version", no_argument, NULL, 'v' },
|
|
|
|
{ "interfaces", required_argument, NULL, 'i' },
|
|
|
|
{ "nointerfaces", required_argument, NULL, 'I' },
|
2017-03-16 22:45:10 +01:00
|
|
|
{ "phys", required_argument, NULL, 'p' },
|
|
|
|
{ "nophys", required_argument, NULL, 'P' },
|
2018-05-20 01:29:28 +02:00
|
|
|
{ "debug", optional_argument, NULL, 'd' },
|
2016-06-23 22:49:05 +02:00
|
|
|
{ "help", no_argument, NULL, 'h' },
|
2014-08-09 06:53:13 +02:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2015-09-29 02:51:40 +02:00
|
|
|
static void do_debug(const char *str, void *user_data)
|
|
|
|
{
|
|
|
|
const char *prefix = user_data;
|
|
|
|
|
|
|
|
l_info("%s%s", prefix, str);
|
|
|
|
}
|
|
|
|
|
2019-05-18 00:05:52 +02:00
|
|
|
static void nl80211_appeared(const struct l_genl_family_info *info,
|
|
|
|
void *user_data)
|
2015-09-29 02:51:40 +02:00
|
|
|
{
|
|
|
|
l_debug("Found nl80211 interface");
|
2019-10-11 21:29:29 +02:00
|
|
|
|
|
|
|
nl80211_complete = true;
|
2015-09-29 02:51:40 +02:00
|
|
|
|
2019-10-11 21:29:22 +02:00
|
|
|
if (iwd_modules_init() < 0) {
|
|
|
|
l_main_quit();
|
|
|
|
return;
|
|
|
|
}
|
2015-09-29 02:51:40 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 03:06:00 +02:00
|
|
|
static void request_name_callback(struct l_dbus *dbus, bool success,
|
|
|
|
bool queued, void *user_data)
|
|
|
|
{
|
|
|
|
if (!success) {
|
|
|
|
l_error("Name request failed");
|
|
|
|
goto fail_exit;
|
|
|
|
}
|
|
|
|
|
2019-10-28 21:07:40 +01:00
|
|
|
if (!l_dbus_object_manager_enable(dbus, "/"))
|
2018-09-12 03:06:00 +02:00
|
|
|
l_warn("Unable to register the ObjectManager");
|
|
|
|
|
2021-05-06 23:28:27 +02:00
|
|
|
if (!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
|
|
|
|
IWD_DAEMON_INTERFACE,
|
|
|
|
NULL) ||
|
|
|
|
!l_dbus_object_add_interface(dbus, IWD_BASE_PATH,
|
|
|
|
L_DBUS_INTERFACE_PROPERTIES,
|
|
|
|
NULL))
|
|
|
|
l_info("Unable to add %s and/or %s at %s",
|
|
|
|
IWD_DAEMON_INTERFACE, L_DBUS_INTERFACE_PROPERTIES,
|
|
|
|
IWD_BASE_PATH);
|
|
|
|
|
2019-05-18 00:05:52 +02:00
|
|
|
/* TODO: Always request nl80211 for now, ignoring auto-loading */
|
|
|
|
l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
|
|
|
|
NULL, NULL);
|
2018-09-12 03:06:00 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
fail_exit:
|
|
|
|
l_main_quit();
|
|
|
|
}
|
|
|
|
|
2021-05-06 23:28:27 +02:00
|
|
|
static struct l_dbus_message *iwd_dbus_get_info(struct l_dbus *dbus,
|
|
|
|
struct l_dbus_message *message,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct l_dbus_message *reply;
|
|
|
|
struct l_dbus_message_builder *builder;
|
|
|
|
L_AUTO_FREE_VAR(char *, storage_dir) = storage_get_path(NULL);
|
2021-05-10 10:58:05 +02:00
|
|
|
bool netconfig_enabled;
|
|
|
|
|
|
|
|
if (!l_settings_get_bool(iwd_config, "General",
|
|
|
|
"EnableNetworkConfiguration",
|
|
|
|
&netconfig_enabled))
|
|
|
|
netconfig_enabled = false;
|
2021-05-06 23:28:27 +02:00
|
|
|
|
|
|
|
reply = l_dbus_message_new_method_return(message);
|
|
|
|
builder = l_dbus_message_builder_new(reply);
|
|
|
|
l_dbus_message_builder_enter_array(builder, "{sv}");
|
|
|
|
|
2021-05-10 10:58:05 +02:00
|
|
|
dbus_append_dict_basic(builder, "NetworkConfigurationEnabled", 'b',
|
|
|
|
&netconfig_enabled);
|
2021-05-06 23:28:27 +02:00
|
|
|
dbus_append_dict_basic(builder, "StateDirectory", 's', storage_dir);
|
|
|
|
dbus_append_dict_basic(builder, "Version", 's', VERSION);
|
|
|
|
|
|
|
|
l_dbus_message_builder_leave_array(builder);
|
|
|
|
l_dbus_message_builder_finalize(builder);
|
|
|
|
l_dbus_message_builder_destroy(builder);
|
|
|
|
|
|
|
|
return reply;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwd_setup_deamon_interface(struct l_dbus_interface *interface)
|
|
|
|
{
|
|
|
|
l_dbus_interface_method(interface, "GetInfo", 0, iwd_dbus_get_info,
|
|
|
|
"a{sv}", "", "info");
|
|
|
|
}
|
|
|
|
|
2018-09-12 03:06:00 +02:00
|
|
|
static void dbus_ready(void *user_data)
|
|
|
|
{
|
|
|
|
struct l_dbus *dbus = user_data;
|
|
|
|
|
2019-08-04 09:53:18 +02:00
|
|
|
l_dbus_name_acquire(dbus, "net.connman.iwd", false, false, false,
|
2018-09-12 03:06:00 +02:00
|
|
|
request_name_callback, NULL);
|
2021-05-06 23:28:27 +02:00
|
|
|
|
|
|
|
l_dbus_register_interface(dbus, IWD_DAEMON_INTERFACE,
|
|
|
|
iwd_setup_deamon_interface,
|
|
|
|
NULL, false);
|
2018-09-12 03:06:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dbus_disconnected(void *user_data)
|
|
|
|
{
|
|
|
|
l_info("D-Bus disconnected, quitting...");
|
|
|
|
iwd_shutdown();
|
|
|
|
}
|
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
static void print_koption(const void *key, void *value, void *user_data)
|
|
|
|
{
|
|
|
|
l_info("\t%s", (const char *) key);
|
|
|
|
}
|
|
|
|
|
2020-06-22 17:12:34 +02:00
|
|
|
#define ADD_MISSING(opt) \
|
|
|
|
l_hashmap_replace(options, opt, &r, NULL)
|
|
|
|
|
|
|
|
#define ADD_OPTIONAL(opt) \
|
|
|
|
l_hashmap_replace(optional, opt, &r, NULL)
|
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
static int check_crypto()
|
|
|
|
{
|
2020-06-23 19:25:18 +02:00
|
|
|
int r = 0;
|
2018-05-03 21:45:26 +02:00
|
|
|
struct l_hashmap *options = l_hashmap_string_new();
|
|
|
|
struct l_hashmap *optional = l_hashmap_string_new();
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA1, true)) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("No HMAC(SHA1) support found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_SHA1");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_HMAC");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_SHA1_SSSE3");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_MD5, true)) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("No HMAC(MD5) support found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_MD5");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_HMAC");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_cmac_aes_supported()) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("No CMAC(AES) support found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_AES");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_CMAC");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_AES_X86_64");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_AES_NI_INTEL");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA256, true)) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("No HMAC(SHA256) support not found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_HMAC");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_SHA256");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_SHA256_SSSE3");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_checksum_is_supported(L_CHECKSUM_SHA512, true)) {
|
|
|
|
l_warn("No HMAC(SHA512) support found, "
|
|
|
|
"certain TLS connections might fail");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_SHA512");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_SHA512_SSSE3");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_DES) ||
|
|
|
|
!l_cipher_is_supported(L_CIPHER_DES3_EDE_CBC)) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("DES support not found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_SKCIPHER");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_DES");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_ECB");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_DES3_EDE_X86_64");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_AES)) {
|
2020-06-23 19:25:18 +02:00
|
|
|
r = -ENOTSUP;
|
2018-05-03 21:45:26 +02:00
|
|
|
l_error("AES support not found");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_USER_API_SKCIPHER");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_AES");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_ECB");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_AES_X86_64");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_AES_NI_INTEL");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_DES3_EDE_CBC)) {
|
|
|
|
l_warn("No CBC(DES3_EDE) support found, "
|
|
|
|
"certain TLS connections might fail");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_DES");
|
|
|
|
ADD_MISSING("CONFIG_CRYPTO_CBC");
|
|
|
|
ADD_OPTIONAL("CONFIG_CRYPTO_DES3_EDE_X86_64");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_cipher_is_supported(L_CIPHER_AES_CBC)) {
|
|
|
|
l_warn("No CBC(AES) support found, "
|
|
|
|
"WPS will not be available");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_CRYPTO_CBC");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_key_is_supported(L_KEY_FEATURE_DH)) {
|
|
|
|
l_warn("No Diffie-Hellman support found, "
|
|
|
|
"WPS will not be available");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_KEY_DH_OPERATIONS");
|
2018-05-03 21:45:26 +02:00
|
|
|
}
|
|
|
|
|
2018-11-09 18:50:29 +01:00
|
|
|
if (!l_key_is_supported(L_KEY_FEATURE_RESTRICT)) {
|
|
|
|
l_warn("No keyring restrictions support found.");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_KEYS");
|
2018-11-09 18:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!l_key_is_supported(L_KEY_FEATURE_CRYPTO)) {
|
|
|
|
l_warn("No asymmetric key support found.");
|
|
|
|
l_warn("TLS based WPA-Enterprise authentication methods will"
|
|
|
|
" not function.");
|
|
|
|
l_warn("Kernel 4.20+ is required for this feature.");
|
2020-06-22 17:12:34 +02:00
|
|
|
ADD_MISSING("CONFIG_ASYMMETRIC_KEY_TYPE");
|
|
|
|
ADD_MISSING("CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE");
|
|
|
|
ADD_MISSING("CONFIG_X509_CERTIFICATE_PARSER");
|
|
|
|
ADD_MISSING("CONFIG_PKCS7_MESSAGE_PARSER");
|
|
|
|
ADD_MISSING("CONFIG_PKCS8_PRIVATE_KEY_PARSER");
|
2020-04-10 02:38:29 +02:00
|
|
|
}
|
2018-11-09 18:50:29 +01:00
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
if (l_hashmap_isempty(options))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
l_info("The following options are missing in the kernel:");
|
|
|
|
|
|
|
|
if (l_hashmap_remove(options, "CONFIG_CRYPTO_USER_API_HASH"))
|
|
|
|
l_info("\tCONFIG_CRYPTO_USER_API_HASH");
|
|
|
|
|
|
|
|
if (l_hashmap_remove(options, "CONFIG_CRYPTO_USER_API_SKCIPHER"))
|
|
|
|
l_info("\tCONFIG_CRYPTO_USER_API_SKCIPHER");
|
|
|
|
|
|
|
|
l_hashmap_foreach(options, print_koption, NULL);
|
|
|
|
|
2018-11-05 18:13:24 +01:00
|
|
|
if (!l_hashmap_isempty(optional)) {
|
|
|
|
l_info("The following optimized implementations might be "
|
|
|
|
"available:");
|
|
|
|
l_hashmap_foreach(optional, print_koption, NULL);
|
|
|
|
}
|
2018-05-03 21:45:26 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
l_hashmap_destroy(options, NULL);
|
|
|
|
l_hashmap_destroy(optional, NULL);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2014-05-21 06:44:13 +02:00
|
|
|
int exit_status;
|
2018-09-12 03:06:00 +02:00
|
|
|
struct l_dbus *dbus;
|
2019-09-08 18:17:19 +02:00
|
|
|
const char *config_dir;
|
2019-09-08 10:22:36 +02:00
|
|
|
char **config_dirs;
|
2020-04-10 20:09:42 +02:00
|
|
|
int i;
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2014-08-09 06:53:13 +02:00
|
|
|
for (;;) {
|
|
|
|
int opt;
|
|
|
|
|
2021-05-25 20:20:07 +02:00
|
|
|
opt = getopt_long(argc, argv, "Ei:I:p:P:d::vh",
|
2017-03-16 22:45:10 +01:00
|
|
|
main_options, NULL);
|
2014-08-09 06:53:13 +02:00
|
|
|
if (opt < 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (opt) {
|
2021-05-05 20:23:53 +02:00
|
|
|
case 'E':
|
|
|
|
developeropt = true;
|
|
|
|
break;
|
2016-06-23 22:49:05 +02:00
|
|
|
case 'i':
|
|
|
|
interfaces = optarg;
|
|
|
|
break;
|
|
|
|
case 'I':
|
|
|
|
nointerfaces = optarg;
|
|
|
|
break;
|
2017-03-16 22:45:10 +01:00
|
|
|
case 'p':
|
|
|
|
phys = optarg;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
nophys = optarg;
|
|
|
|
break;
|
2018-05-20 01:29:28 +02:00
|
|
|
case 'd':
|
|
|
|
if (optarg)
|
|
|
|
debugopt = optarg;
|
|
|
|
else if (argv[optind] && argv[optind][0] != '-')
|
|
|
|
debugopt = argv[optind++];
|
|
|
|
else
|
|
|
|
debugopt = "*";
|
|
|
|
break;
|
2018-09-14 15:18:09 +02:00
|
|
|
case 'v':
|
|
|
|
printf("%s\n", VERSION);
|
|
|
|
return EXIT_SUCCESS;
|
2014-08-09 06:53:13 +02:00
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
default:
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc - optind > 0) {
|
|
|
|
fprintf(stderr, "Invalid command line parameters\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-05-03 21:45:26 +02:00
|
|
|
l_log_set_stderr();
|
|
|
|
|
|
|
|
if (check_crypto() < 0)
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2016-06-09 16:38:13 +02:00
|
|
|
if (!l_main_init())
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
2018-05-20 01:29:28 +02:00
|
|
|
if (debugopt)
|
|
|
|
l_debug_enable(debugopt);
|
2014-05-11 19:39:22 +02:00
|
|
|
|
2018-11-24 03:27:04 +01:00
|
|
|
#ifdef HAVE_BACKTRACE
|
2017-03-16 21:13:35 +01:00
|
|
|
__iwd_backtrace_init();
|
2016-04-13 21:07:36 +02:00
|
|
|
#endif
|
|
|
|
|
2014-05-11 19:39:22 +02:00
|
|
|
l_info("Wireless daemon version %s", VERSION);
|
|
|
|
|
2019-09-08 18:17:19 +02:00
|
|
|
config_dir = getenv("CONFIGURATION_DIRECTORY");
|
|
|
|
if (!config_dir)
|
|
|
|
config_dir = DAEMON_CONFIGDIR;
|
2019-09-08 10:22:36 +02:00
|
|
|
|
|
|
|
l_debug("Using configuration directory %s", config_dir);
|
2016-11-02 22:04:37 +01:00
|
|
|
|
|
|
|
iwd_config = l_settings_new();
|
|
|
|
|
2019-09-08 10:22:36 +02:00
|
|
|
config_dirs = l_strsplit(config_dir, ':');
|
2020-04-09 03:44:17 +02:00
|
|
|
|
2020-04-10 20:09:42 +02:00
|
|
|
for (i = 0; config_dirs[i]; i++) {
|
2020-04-09 03:44:17 +02:00
|
|
|
L_AUTO_FREE_VAR(char *, path) =
|
2020-04-10 20:09:42 +02:00
|
|
|
l_strdup_printf("%s/%s", config_dirs[i], "main.conf");
|
2020-04-09 03:44:17 +02:00
|
|
|
|
|
|
|
if (!l_settings_load_from_file(iwd_config, path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
l_info("Loaded configuration from %s", path);
|
|
|
|
break;
|
2019-09-08 10:22:36 +02:00
|
|
|
}
|
2020-04-09 03:44:17 +02:00
|
|
|
|
2019-09-08 10:22:36 +02:00
|
|
|
l_strv_free(config_dirs);
|
2016-11-02 22:04:37 +01:00
|
|
|
|
2018-08-18 06:32:30 +02:00
|
|
|
__eapol_set_config(iwd_config);
|
2019-10-11 21:29:30 +02:00
|
|
|
__eap_set_config(iwd_config);
|
2018-08-18 06:32:30 +02:00
|
|
|
|
|
|
|
exit_status = EXIT_FAILURE;
|
|
|
|
|
2019-09-08 18:24:23 +02:00
|
|
|
if (!storage_create_dirs())
|
2020-04-09 03:44:16 +02:00
|
|
|
goto failed_dirs;
|
2019-06-26 21:20:35 +02:00
|
|
|
|
2019-05-18 00:05:52 +02:00
|
|
|
genl = l_genl_new();
|
|
|
|
if (!genl) {
|
|
|
|
l_error("Failed to open generic netlink socket");
|
2020-04-09 03:44:16 +02:00
|
|
|
goto failed_genl;
|
2019-05-18 00:05:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getenv("IWD_GENL_DEBUG"))
|
|
|
|
l_genl_set_debug(genl, do_debug, "[GENL] ", NULL);
|
|
|
|
|
2020-04-08 19:27:49 +02:00
|
|
|
rtnl = l_netlink_new(NETLINK_ROUTE);
|
|
|
|
if (!rtnl) {
|
|
|
|
l_error("Failed to open route netlink socket");
|
2020-04-09 03:44:16 +02:00
|
|
|
goto failed_rtnl;
|
2020-04-08 19:27:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getenv("IWD_RTNL_DEBUG"))
|
|
|
|
l_netlink_set_debug(rtnl, do_debug, "[RTNL] ", NULL);
|
|
|
|
|
2018-09-12 03:06:00 +02:00
|
|
|
dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
|
|
|
|
if (!dbus) {
|
2018-08-18 06:32:30 +02:00
|
|
|
l_error("Failed to initialize D-Bus");
|
2020-04-09 03:44:16 +02:00
|
|
|
goto failed_dbus;
|
2014-10-07 04:50:27 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 03:06:00 +02:00
|
|
|
l_dbus_set_ready_handler(dbus, dbus_ready, dbus, NULL);
|
|
|
|
l_dbus_set_disconnect_handler(dbus, dbus_disconnected, NULL, NULL);
|
|
|
|
dbus_init(dbus);
|
2015-09-29 02:51:40 +02:00
|
|
|
|
2018-11-01 19:56:16 +01:00
|
|
|
exit_status = l_main_run_with_signal(signal_handler, NULL);
|
2020-04-09 03:44:16 +02:00
|
|
|
|
2019-05-19 19:57:45 +02:00
|
|
|
iwd_modules_exit();
|
2015-09-29 02:51:40 +02:00
|
|
|
dbus_exit();
|
2018-09-12 03:06:00 +02:00
|
|
|
l_dbus_destroy(dbus);
|
2020-04-09 03:44:16 +02:00
|
|
|
|
2020-04-08 23:19:37 +02:00
|
|
|
failed_dbus:
|
2020-04-08 19:27:49 +02:00
|
|
|
l_netlink_destroy(rtnl);
|
2020-04-09 03:44:16 +02:00
|
|
|
|
2020-04-08 23:19:37 +02:00
|
|
|
failed_rtnl:
|
2020-04-09 03:44:16 +02:00
|
|
|
l_genl_unref(genl);
|
|
|
|
|
2020-04-08 23:19:37 +02:00
|
|
|
failed_genl:
|
2020-04-09 03:44:16 +02:00
|
|
|
storage_cleanup_dirs();
|
|
|
|
|
2020-04-08 23:19:37 +02:00
|
|
|
failed_dirs:
|
2016-11-02 22:04:37 +01:00
|
|
|
l_settings_free(iwd_config);
|
2015-03-02 15:19:08 +01:00
|
|
|
l_timeout_remove(timeout);
|
2016-06-09 16:38:13 +02:00
|
|
|
l_main_exit();
|
|
|
|
|
2014-05-21 06:44:13 +02:00
|
|
|
return exit_status;
|
2014-05-11 19:39:22 +02:00
|
|
|
}
|