/* * Unset most relevant seen flags to allow to correct preseeded values * when mirror is bad. */ void unset_seen_flags(void) { char *hostname, *directory; hostname = add_protocol("hostname"); debconf_fset(debconf, hostname, "seen", "false"); free(hostname); directory = add_protocol("directory"); debconf_fset(debconf, directory, "seen", "false"); free(directory); debconf_fset(debconf, DEBCONF_BASE "country", "seen", "false"); debconf_fset(debconf, DEBCONF_BASE "suite", "seen", "false"); }
static int choose_country(void) { if (country) free(country); country = NULL; #if defined (WITH_FTP_MANUAL) assert(protocol != NULL); if (strcasecmp(protocol,"ftp") == 0) return 0; #endif debconf_get(debconf, DEBCONF_BASE "country"); if (! strlen(debconf->value)) { /* Not set yet. Seed with a default value. */ if ((debconf_get(debconf, "debian-installer/country") == 0) && (debconf->value != NULL) ) { country = strdup (debconf->value); debconf_set(debconf, DEBCONF_BASE "country", country); } } else { country = debconf->value; } /* Ensure 'country' is set to something. */ if (country == NULL || *country == 0) { country = "GB"; } char *countries; countries = add_protocol("countries"); if (has_mirror(country)) { const char *default_country = MANUAL_ENTRY; /* TODO: duplicates much of mirrors_in and has_mirror, since * those don't let us get the country at the moment */ if (strcmp(country, MANUAL_ENTRY) != 0 && strcmp(country, MANUAL_ENTRY_OLD) != 0) { int i = 0; struct mirror_t *mirrors = mirror_list(); for (i = 0; mirrors[i].country != NULL; i++) { if (strcmp(mirrors[i].country, country) == 0 || mirrors[i].wildcard) { default_country = mirrors[i].country; break; } } } debconf_set(debconf, countries, default_country); debconf_fget(debconf, DEBCONF_BASE "country", "seen"); debconf_fset(debconf, countries, "seen", debconf->value); } debconf_input(debconf, base_on_cd ? "medium" : "high", countries); free (countries); return 0; }
void test3(struct debconfclient *client) { debconf_input(client, "high", "foo/bar"); debconf_go(client); debconf_fset(client, "foo/bar", "seen", "false"); debconf_input(client, "medium", "foo/bar"); debconf_go(client); debconf_input(client, "high", "foo/bar"); debconf_go(client); }
static int choose_country(void) { if (country) free(country); country = NULL; #if defined (WITH_FTP_MANUAL) assert(protocol != NULL); if (strcasecmp(protocol,"ftp") == 0) return 0; #endif debconf_get(debconf, DEBCONF_BASE "country"); if (! strlen(debconf->value)) { /* Not set yet. Seed with a default value. */ if ((debconf_get(debconf, "debian-installer/country") == 0) && (debconf->value != NULL) ) { country = strdup (debconf->value); debconf_set(debconf, DEBCONF_BASE "country", country); } } else { country = debconf->value; } /* Ensure 'country' is set to something. */ if (country == NULL || *country == 0) { country = "GB"; } char *countries; countries = add_protocol("countries"); if (has_mirror(country)) { debconf_set(debconf, countries, country); debconf_fget(debconf, DEBCONF_BASE "country", "seen"); debconf_fset(debconf, countries, "seen", debconf->value); } debconf_input(debconf, base_on_cd ? "medium" : "high", countries); free (countries); return 0; }
int netcfg_wireless_choose_essid_manually(struct debconfclient *client, struct netcfg_interface *interface, char *question) { wireless_config wconf; iw_get_basic_config (wfd, interface->name, &wconf); debconf_subst(client, question, "iface", interface->name); debconf_subst(client, "netcfg/wireless_adhoc_managed", "iface", interface->name); if (debconf_go(client) == CMD_GOBACK) { debconf_fset(client, question, "seen", "false"); return GO_BACK; } debconf_get(client, "netcfg/wireless_adhoc_managed"); if (!strcmp(client->value, "Ad-hoc network (Peer to peer)")) { interface->mode = ADHOC; } wconf.has_mode = 1; wconf.mode = interface->mode; get_essid: debconf_input(client, "high", question); if (debconf_go(client) == CMD_GOBACK) { return GO_BACK; } debconf_get(client, question); if (client->value && strlen(client->value) > IW_ESSID_MAX_SIZE) { char max_len_string[5]; sprintf(max_len_string, "%d", IW_ESSID_MAX_SIZE); debconf_capb(client, ""); debconf_subst(client, "netcfg/invalid_essid", "essid", client->value); debconf_subst(client, "netcfg/invalid_essid", "max_essid_len", max_len_string); debconf_input(client, "critical", "netcfg/invalid_essid"); debconf_go(client); debconf_fset(client, question, "seen", "false"); debconf_capb(client, "backup"); goto get_essid; } interface->essid = strdup(client->value); memset(wconf.essid, 0, IW_ESSID_MAX_SIZE + 1); snprintf(wconf.essid, IW_ESSID_MAX_SIZE + 1, "%s", interface->essid); wconf.has_essid = 1; wconf.essid_on = 1; iw_set_basic_config(wfd, interface->name, &wconf); di_info("Network chosen: %s. Proceeding to connect.", interface->essid); return 0; }
int netcfg_wireless_show_essids(struct debconfclient *client, struct netcfg_interface *interface) { wireless_scan_head network_list; wireless_config wconf; char *buffer; int essid_list_len = 1; iw_get_basic_config (wfd, interface->name, &wconf); interface_up(interface->name); if (iw_scan(wfd, interface->name, iw_get_kernel_we_version(), &network_list) >= 0 ) { wireless_scan *network; di_info("Scan of wireless interface %s succeeded.", interface->name); /* Determine the actual length of the buffer. */ for (network = network_list.result; network; network = network->next) { if (!exists_in_network_list(network_list, network)) { essid_list_len += (strlen(network->b.essid) + 2); } } /* Buffer initialization. */ buffer = malloc(essid_list_len * sizeof(char)); if (buffer == NULL) { /* Error in memory allocation. */ di_warning("Unable to allocate memory for network list buffer."); return ENTER_MANUALLY; } strcpy(buffer, ""); /* Create list of available ESSIDs. */ for (network = network_list.result; network; network = network->next) { if (!exists_in_network_list(network_list, network)) { strcat(buffer, network->b.essid); strcat(buffer, ", "); } } /* Asking the user. */ debconf_capb(client, "backup"); debconf_subst(client, "netcfg/wireless_show_essids", "essid_list", buffer); debconf_fset(client, "netcfg/wireless_show_essids", "seen", "false"); debconf_input(client, "high", "netcfg/wireless_show_essids"); if (debconf_go(client) == CMD_GOBACK) { debconf_fset(client, "netcfg/wireless_show_essids", "seen", "false"); free_network_list(&network_list.result); free(buffer); return GO_BACK; } debconf_get(client, "netcfg/wireless_show_essids"); /* User wants to enter an ESSID manually. */ if (strcmp(client->value, "manual") == 0) { free_network_list(&network_list.result); free(buffer); return ENTER_MANUALLY; } /* User has chosen a network from the list, need to find which one and * get its cofiguration. */ for (network = network_list.result; network; network = network->next) { if (strcmp(network->b.essid, client->value) == 0) { wconf = network->b; interface->essid = strdup(network->b.essid); break; } } /* Free the network list. */ free_network_list(&network_list.result); free(buffer); } else { /* Go directly to choosing manually, use the wireless_essid_again * question. */ if (netcfg_wireless_choose_essid_manually(client, interface, "netcfg/wireless_essid_again") == GO_BACK) { return GO_BACK; } return 0; } iw_set_basic_config(wfd, interface->name, &wconf); interface_down(interface->name); di_info("Network chosen: %s. Proceeding to connect.", interface->essid); return 0; }