📄 xsupconfcheck.c
字号:
while (cur) { switch (cur->method_num) { case EAP_TYPE_MSCHAPV2: // No settings that need to be checked. break; case EAP_TYPE_MD5: // No settings that need to be checked. break; case EAP_TYPE_SIM: // No settings that need to be checked. break; case EAP_TYPE_GTC: // No settings that need to be checked. break; case EAP_TYPE_OTP: // No settings that need to be checked. break; default: xsupconfcheck_add_log(errors, "Invalid PEAP phase 2 method in " "network clause '%s'.\n", netname); retval = -1; break; } cur = cur->next; } return retval;}/***************************************************************** * * Check the validity of the PEAP configuration. This will also check * all of the phase 2 methods that are contained in it. * *****************************************************************/int xsupconfcheck_check_eap_peap(struct config_eap_peap *peap, char *netname, cerrs **errors){ int retval = 0; if ((!peap->root_cert) && (!peap->root_dir)) { xsupconfcheck_add_log(errors, "PEAP requires a valid setting for either" " 'root_cert' or 'root_dir' in clause for network" " '%s'.\n", netname); retval = -1; } if (peap->flags == 0) { xsupconfcheck_add_log(errors, "PEAP requires a valid setting for " "'allow_types' in the clause for network '%s'.\n", netname); } if (xsupconfcheck_check_peap_phase2(peap->phase2, netname, errors) != 0) retval = -1; return retval;}/********************************************************************** * * Check that all of our phase 2 data is valid. * **********************************************************************/int xsupconfcheck_check_ttls_phase2(struct config_ttls_phase2 *p2type, char *netname, cerrs **errors){ int retval = 0; // Right now, there is nothing to check. The currently supported phase 2 // methods only require a username and password. If the username is empty, // then we will copy up the phase 1 username. If the password is empty, // we will ask a GUI for one. return retval;}/***************************************************************** * * Check the EAP-TTLS configuration. This will also check the inner methods. * *****************************************************************/int xsupconfcheck_check_eap_ttls(struct config_eap_ttls *ttls, char *netname, cerrs **errors){ int retval = 0; if ((!ttls->root_cert) && (!ttls->root_dir)) { xsupconfcheck_add_log(errors, "EAP-TTLS requires a setting for either" " 'root_cert' or 'root_dir' in network clause " " '%s'.\n", netname); retval = -1; } if ((ttls->phase2_type < TTLS_PHASE2_PAP) || (ttls->phase2_type > TTLS_PHASE2_EAP_MD5)) { xsupconfcheck_add_log(errors, "EAP-TTLS requires a valid setting for the" " 'phase2_type' option in network clause '%s'.\n", netname); retval = -1; } if (!ttls->phase2) { xsupconfcheck_add_log(errors, "EAP-TTLS requires an inner authentication" " method in network clause '%s'.\n", netname); retval = -1; } else { if (xsupconfcheck_check_ttls_phase2(ttls->phase2, netname, errors) != 0) retval = -1; } return retval;}/***************************************************************** * * Loop through all of the EAP methods that are defined in a network clause * and verify that they have valid configuration data. * *****************************************************************/int xsupconfcheck_check_eap_methods(struct config_eap_method *method, char *netname, cerrs **errors){ struct config_eap_method *cur; int retval = 0; cur = method; while (cur) { switch (cur->method_num) { case STATIC_WEP_METHOD: if (xsupconfcheck_check_static_wep_method(cur->method_data, netname, errors) != 0) retval = -1; break; case WPA_PSK: if (xsupconfcheck_check_wpa_psk(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_MD5: if (xsupconfcheck_check_eap_md5(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_OTP: if (xsupconfcheck_check_eap_otp(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_GTC: if (xsupconfcheck_check_eap_gtc(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_TLS: if (xsupconfcheck_check_eap_tls(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_LEAP: if (xsupconfcheck_check_eap_leap(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_SIM: if (xsupconfcheck_check_eap_sim(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_TTLS: if (xsupconfcheck_check_eap_ttls(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_AKA: if (xsupconfcheck_check_eap_aka(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_PEAP: if (xsupconfcheck_check_eap_peap(cur->method_data, netname, errors) != 0) retval = -1; break; case EAP_TYPE_MSCHAPV2: if (xsupconfcheck_check_eap_mschapv2(cur->method_data, netname, errors) != 0) retval = -1; break; default: xsupconfcheck_add_log(errors, "Unknown EAP type %d in clause for " "network '%s'.\n", cur->method_num, netname); retval = -1; break; } cur = cur->next; } return retval;}/***************************************************************** * * Check all of the network clauses. This will also result in all of the * EAP clauses being checked. * *****************************************************************/int xsupconfcheck_check_networks(struct config_network *network, cerrs **errors){ int retval = 0; struct config_network *cur; int clause = 1; cur = network; while (cur) { if (!cur->name) { xsupconfcheck_add_log(errors, "Network clause %d is missing a name!", clause); retval = -1; } if (cur->flags == 0) { xsupconfcheck_add_log(errors, "Network '%s' has no allowed EAP" " methods defined!\n", cur->name); retval = -1; } if ((!cur->identity) && (cur->methods) && (cur->methods->method_num != WPA_PSK)) { xsupconfcheck_add_log(errors, "Network '%s' doesn't have an " "'identity' value set.\n", cur->name); retval = -1; } if (cur->initial_wep) { if (xsupconfcheck_check_initial_wep_method(cur->initial_wep, cur->name, errors) != 0) retval = -1; } if (xsupconfcheck_check_eap_methods(cur->methods, cur->name, errors) != 0) retval = -1; clause++; cur = cur->next; } return retval;}/***************************************************************** * * Check an entire config. If there are errors, a linked list of strings * are returned, and the return value !=0. * *****************************************************************/int xsupconfcheck_check_config(struct config_data *confdata, cerrs **errors){ int retval = 0, worst; if (errors == NULL) { // We are screwed. We can't return any contextual error messages. :-/ return -1; } if (confdata == NULL) { xsupconfcheck_add_log(errors, "No valid configuration information was " "passed in to the configuration checker!\n"); return -1; } retval = xsupconfcheck_check_globals(confdata->globals, errors); if (retval < 0) worst = retval; retval = xsupconfcheck_check_networks(confdata->networks, errors); if (retval < 0) worst = retval; return retval;}/****************************************************************** * * Return the first logline that is in the queue. Once the line is returned, * the node that contains it will be destroyed. * ******************************************************************/char *xsupconfcheck_pop_logline(cerrs **errors){ cerrs *cur; char *line; if (!errors) return NULL; cur = (*errors); if (!cur) { free(errors); errors = NULL; return NULL; } *errors = cur->next; line = cur->line; free(cur); return line;}/***************************************************************** * * Clean up the string list that may be leftover. (Assuming it isn't NULL * already.) And do anything else that needs to be done to quit cleanly. * *****************************************************************/int xsupconfcheck_deinit(cerrs **errors){ cerrs *cur, *cur2; if ((errors) && (*errors)) { cur = (*errors); while (cur) { if (cur->line) free(cur->line); cur->line = NULL; cur2 = cur->next; free(cur); cur = cur2; } } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -