mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-24 16:28:23 -05:00
wpa_supplicant: Add option -I for additional config file
This option can be used only for global parameters that are not going to be changed from settings. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com> Signed-off-by: Iliyan Malchev <malchev@google.com>
This commit is contained in:
parent
adc96dc2ad
commit
e6304cad47
@ -213,6 +213,9 @@ char * os_rel2abs_path(const char *rel_path)
|
|||||||
size_t len = 128, cwd_len, rel_len, ret_len;
|
size_t len = 128, cwd_len, rel_len, ret_len;
|
||||||
int last_errno;
|
int last_errno;
|
||||||
|
|
||||||
|
if (!rel_path)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (rel_path[0] == '/')
|
if (rel_path[0] == '/')
|
||||||
return os_strdup(rel_path);
|
return os_strdup(rel_path);
|
||||||
|
|
||||||
|
@ -912,6 +912,7 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line);
|
|||||||
* wpa_config_read - Read and parse configuration database
|
* wpa_config_read - Read and parse configuration database
|
||||||
* @name: Name of the configuration (e.g., path and file name for the
|
* @name: Name of the configuration (e.g., path and file name for the
|
||||||
* configuration file)
|
* configuration file)
|
||||||
|
* @cfgp: Pointer to previously allocated configuration data or %NULL if none
|
||||||
* Returns: Pointer to allocated configuration data or %NULL on failure
|
* Returns: Pointer to allocated configuration data or %NULL on failure
|
||||||
*
|
*
|
||||||
* This function reads configuration data, parses its contents, and allocates
|
* This function reads configuration data, parses its contents, and allocates
|
||||||
@ -920,7 +921,7 @@ int wpa_config_process_global(struct wpa_config *config, char *pos, int line);
|
|||||||
*
|
*
|
||||||
* Each configuration backend needs to implement this function.
|
* Each configuration backend needs to implement this function.
|
||||||
*/
|
*/
|
||||||
struct wpa_config * wpa_config_read(const char *name);
|
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wpa_config_write - Write or update configuration data
|
* wpa_config_write - Write or update configuration data
|
||||||
|
@ -345,7 +345,7 @@ static int wpa_config_process_blob(struct wpa_config *config, FILE *f,
|
|||||||
#endif /* CONFIG_NO_CONFIG_BLOBS */
|
#endif /* CONFIG_NO_CONFIG_BLOBS */
|
||||||
|
|
||||||
|
|
||||||
struct wpa_config * wpa_config_read(const char *name)
|
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char buf[512], *pos;
|
char buf[512], *pos;
|
||||||
@ -356,12 +356,19 @@ struct wpa_config * wpa_config_read(const char *name)
|
|||||||
int id = 0;
|
int id = 0;
|
||||||
int cred_id = 0;
|
int cred_id = 0;
|
||||||
|
|
||||||
config = wpa_config_alloc_empty(NULL, NULL);
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (cfgp)
|
||||||
|
config = cfgp;
|
||||||
|
else
|
||||||
|
config = wpa_config_alloc_empty(NULL, NULL);
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
wpa_printf(MSG_ERROR, "Failed to allocate config file "
|
wpa_printf(MSG_ERROR, "Failed to allocate config file "
|
||||||
"structure");
|
"structure");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
head = config->ssid;
|
||||||
|
cred_head = config->cred;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "Reading configuration file '%s'", name);
|
wpa_printf(MSG_DEBUG, "Reading configuration file '%s'", name);
|
||||||
f = fopen(name, "r");
|
f = fopen(name, "r");
|
||||||
|
@ -17,11 +17,16 @@
|
|||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
|
|
||||||
struct wpa_config * wpa_config_read(const char *name)
|
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
|
||||||
{
|
{
|
||||||
struct wpa_config *config;
|
struct wpa_config *config;
|
||||||
|
|
||||||
config = wpa_config_alloc_empty(NULL, NULL);
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (cfgp)
|
||||||
|
config = cfgp;
|
||||||
|
else
|
||||||
|
config = wpa_config_alloc_empty(NULL, NULL);
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* TODO: fill in configuration data */
|
/* TODO: fill in configuration data */
|
||||||
|
@ -434,7 +434,7 @@ static int wpa_config_read_networks(struct wpa_config *config, HKEY hk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct wpa_config * wpa_config_read(const char *name)
|
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
|
||||||
{
|
{
|
||||||
TCHAR buf[256];
|
TCHAR buf[256];
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
@ -442,7 +442,12 @@ struct wpa_config * wpa_config_read(const char *name)
|
|||||||
HKEY hk;
|
HKEY hk;
|
||||||
LONG ret;
|
LONG ret;
|
||||||
|
|
||||||
config = wpa_config_alloc_empty(NULL, NULL);
|
if (name == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (cfgp)
|
||||||
|
config = cfgp;
|
||||||
|
else
|
||||||
|
config = wpa_config_alloc_empty(NULL, NULL);
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
wpa_printf(MSG_DEBUG, "Reading configuration profile '%s'", name);
|
wpa_printf(MSG_DEBUG, "Reading configuration profile '%s'", name);
|
||||||
|
@ -1232,7 +1232,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
os_memset(&wpa_s, 0, sizeof(wpa_s));
|
os_memset(&wpa_s, 0, sizeof(wpa_s));
|
||||||
eapol_test.wpa_s = &wpa_s;
|
eapol_test.wpa_s = &wpa_s;
|
||||||
wpa_s.conf = wpa_config_read(conf);
|
wpa_s.conf = wpa_config_read(conf, NULL);
|
||||||
if (wpa_s.conf == NULL) {
|
if (wpa_s.conf == NULL) {
|
||||||
printf("Failed to parse configuration file '%s'.\n", conf);
|
printf("Failed to parse configuration file '%s'.\n", conf);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -32,7 +32,8 @@ static void usage(void)
|
|||||||
" [-o<override driver>] [-O<override ctrl>] \\\n"
|
" [-o<override driver>] [-O<override ctrl>] \\\n"
|
||||||
" [-N -i<ifname> -c<conf> [-C<ctrl>] "
|
" [-N -i<ifname> -c<conf> [-C<ctrl>] "
|
||||||
"[-D<driver>] \\\n"
|
"[-D<driver>] \\\n"
|
||||||
" [-p<driver_param>] [-b<br_ifname>] ...]\n"
|
" [-p<driver_param>] [-b<br_ifname>] [-I<config file>] "
|
||||||
|
"...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"drivers:\n",
|
"drivers:\n",
|
||||||
wpa_supplicant_version, wpa_supplicant_license);
|
wpa_supplicant_version, wpa_supplicant_license);
|
||||||
@ -50,6 +51,7 @@ static void usage(void)
|
|||||||
" -c = Configuration file\n"
|
" -c = Configuration file\n"
|
||||||
" -C = ctrl_interface parameter (only used if -c is not)\n"
|
" -C = ctrl_interface parameter (only used if -c is not)\n"
|
||||||
" -i = interface name\n"
|
" -i = interface name\n"
|
||||||
|
" -I = additional configuration file\n"
|
||||||
" -d = increase debugging verbosity (-dd even more)\n"
|
" -d = increase debugging verbosity (-dd even more)\n"
|
||||||
" -D = driver name (can be multiple drivers: nl80211,wext)\n"
|
" -D = driver name (can be multiple drivers: nl80211,wext)\n"
|
||||||
" -e = entropy file\n");
|
" -e = entropy file\n");
|
||||||
@ -155,7 +157,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = getopt(argc, argv,
|
c = getopt(argc, argv,
|
||||||
"b:Bc:C:D:de:f:g:hi:KLNo:O:p:P:qsTtuvW");
|
"b:Bc:C:D:de:f:g:hi:I:KLNo:O:p:P:qsTtuvW");
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
break;
|
break;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -202,6 +204,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'i':
|
case 'i':
|
||||||
iface->ifname = optarg;
|
iface->ifname = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'I':
|
||||||
|
iface->confanother = optarg;
|
||||||
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
params.wpa_debug_show_keys++;
|
params.wpa_debug_show_keys++;
|
||||||
break;
|
break;
|
||||||
|
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
os_memset(&wpa_s, 0, sizeof(wpa_s));
|
os_memset(&wpa_s, 0, sizeof(wpa_s));
|
||||||
wpa_s.conf = wpa_config_read(argv[1]);
|
wpa_s.conf = wpa_config_read(argv[1], NULL);
|
||||||
if (wpa_s.conf == NULL) {
|
if (wpa_s.conf == NULL) {
|
||||||
printf("Failed to parse configuration file '%s'.\n", argv[1]);
|
printf("Failed to parse configuration file '%s'.\n", argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -399,6 +399,9 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
|
|||||||
os_free(wpa_s->confname);
|
os_free(wpa_s->confname);
|
||||||
wpa_s->confname = NULL;
|
wpa_s->confname = NULL;
|
||||||
|
|
||||||
|
os_free(wpa_s->confanother);
|
||||||
|
wpa_s->confanother = NULL;
|
||||||
|
|
||||||
wpa_sm_set_eapol(wpa_s->wpa, NULL);
|
wpa_sm_set_eapol(wpa_s->wpa, NULL);
|
||||||
eapol_sm_deinit(wpa_s->eapol);
|
eapol_sm_deinit(wpa_s->eapol);
|
||||||
wpa_s->eapol = NULL;
|
wpa_s->eapol = NULL;
|
||||||
@ -760,12 +763,14 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
|
|||||||
|
|
||||||
if (wpa_s->confname == NULL)
|
if (wpa_s->confname == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
conf = wpa_config_read(wpa_s->confname);
|
conf = wpa_config_read(wpa_s->confname, NULL);
|
||||||
if (conf == NULL) {
|
if (conf == NULL) {
|
||||||
wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
|
wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
|
||||||
"file '%s' - exiting", wpa_s->confname);
|
"file '%s' - exiting", wpa_s->confname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
wpa_config_read(wpa_s->confanother, conf);
|
||||||
|
|
||||||
conf->changed_parameters = (unsigned int) -1;
|
conf->changed_parameters = (unsigned int) -1;
|
||||||
|
|
||||||
reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
|
reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
|
||||||
@ -2801,12 +2806,14 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
|
|||||||
#else /* CONFIG_BACKEND_FILE */
|
#else /* CONFIG_BACKEND_FILE */
|
||||||
wpa_s->confname = os_strdup(iface->confname);
|
wpa_s->confname = os_strdup(iface->confname);
|
||||||
#endif /* CONFIG_BACKEND_FILE */
|
#endif /* CONFIG_BACKEND_FILE */
|
||||||
wpa_s->conf = wpa_config_read(wpa_s->confname);
|
wpa_s->conf = wpa_config_read(wpa_s->confname, NULL);
|
||||||
if (wpa_s->conf == NULL) {
|
if (wpa_s->conf == NULL) {
|
||||||
wpa_printf(MSG_ERROR, "Failed to read or parse "
|
wpa_printf(MSG_ERROR, "Failed to read or parse "
|
||||||
"configuration '%s'.", wpa_s->confname);
|
"configuration '%s'.", wpa_s->confname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
wpa_s->confanother = os_rel2abs_path(iface->confanother);
|
||||||
|
wpa_config_read(wpa_s->confanother, wpa_s->conf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Override ctrl_interface and driver_param if set on command
|
* Override ctrl_interface and driver_param if set on command
|
||||||
|
@ -55,6 +55,14 @@ struct wpa_interface {
|
|||||||
*/
|
*/
|
||||||
const char *confname;
|
const char *confname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* confanother - Additional configuration name (file or profile) name
|
||||||
|
*
|
||||||
|
* This can also be %NULL when the additional configuration file is not
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
const char *confanother;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ctrl_interface - Control interface parameter
|
* ctrl_interface - Control interface parameter
|
||||||
*
|
*
|
||||||
@ -307,6 +315,7 @@ struct wpa_supplicant {
|
|||||||
char bridge_ifname[16];
|
char bridge_ifname[16];
|
||||||
|
|
||||||
char *confname;
|
char *confname;
|
||||||
|
char *confanother;
|
||||||
struct wpa_config *conf;
|
struct wpa_config *conf;
|
||||||
int countermeasures;
|
int countermeasures;
|
||||||
os_time_t last_michael_mic_error;
|
os_time_t last_michael_mic_error;
|
||||||
|
Loading…
Reference in New Issue
Block a user