void services_die(const char *msg, int rboot) { ilog(L_NOTICE, "Dying: %s", msg); cleanup_channel_modes(); cleanup_conf(); #ifdef HAVE_RUBY cleanup_ruby(); #endif cleanup_db(); cleanup_modules(); EVP_cleanup(); send_queued_all(); exit_client(&me, &me, "Services shutting down"); send_queued_all(); if(me.uplink != NULL) MyFree(me.uplink->server); cleanup_client(); cleanup_channel(); cleanup_interface(); cleanup_mqueue(); cleanup_tor(); unregister_callback(iorecv_cb); unregister_callback(connected_cb); unregister_callback(iosend_cb); libio_cleanup(); exit(rboot); }
int setup_ethernetinterface(struct config_interfaces * cur) { int retries = 1; struct config_ssid *match = cur->ssids; /* * If 8021.1X, run the supplicant stuff the same as wireless. * If not using 8021.1X, just go straight to dhclient. */ printf("%s\n", cur->if_name); if (!connection_active(cur->if_name, 0)) { char command [50]; snprintf(command, sizeof(command), "ifconfig %s up\n", config->if_name); printf("%s\n", command); system(command); printf("try bringing up interface\n"); /* * Check if a password has been set; if yes, we want to use * the supplicant. */ if (match->ssid_pass[0] == '\0') strlcpy(match->ssid_auth, "none", sizeof(match->ssid_auth)); else strlcpy(match->ssid_auth, "802.1x", sizeof(match->ssid_auth)); /* * Remove wireless settings from wireless interface before * trying ethernet. */ cleanup_interface(cur, 1); if (strcmp(cur->ssids->ssid_auth, "802.1x") == 0) { /* Do supplicant stuff. */ if (!cur->supplicant_pid) cur->supplicant_pid = start_wpa_supplicant(cur->if_name, cur->supplicant_pid, 0); sleep(3); config_wpa_supplicant(cur->if_name, match, 1); } if (cur->ipv6_auto) set_ipv6_auto(cur->if_name); start_dhclient(cur->if_name); if (connection_active(cur->if_name, 0)) { /* * If we are successfully connected to the network * and we don't need additional auth, then we are good. */ if (internet_connectivity_check(match) == 1) return 1; /* All is ok, sleep. */ } } else { /* * If we are successfully connected to the network, * then we are good. Otherwise try another connection. */ if (internet_connectivity_check(match) == 1) return 1; /* All is ok, sleep. */ } return 0; }
int setup_wlaninterface(struct config_interfaces * target) { int retries = 1, res = 0; struct config_ssid *match, *all = all_matching_network(target); char *if_name = target->if_name; match = all; if (!match) return 0; if (network_matches(if_name, match)) { printf("already using matched ssid, we do nothing\n"); clear_ssid(all); return 1; } while (match) { printf("setting up network: %s\n", match->ssid_name); set_network_id((char *) match->ssid_name, if_name); printf("%s\n", match->ssid_auth); update_status(CONNECTING, match->ssid_name); if (strcmp(match->ssid_auth, "802.1x") == 0) { printf("do 8021x stuff\n"); if (!target->supplicant_pid) target->supplicant_pid = start_wpa_supplicant(target->if_name, target->supplicant_pid, 1); cleanup_interface(target, 8); set_bssid((char *) match->ssid_bssid, if_name, 1); set_wpa8021x(if_name, 1); sleep(3); config_wpa_supplicant(if_name, match, 1); } else if (strcmp(match->ssid_auth, "wpa") == 0) { printf("do wpa stuff\n"); cleanup_interface(target, 4); set_psk_key((char *) match->ssid_name, (char *) match->ssid_pass, if_name, 1); } else if (strcmp(match->ssid_auth, "wep") == 0) { printf("do wep stuff\n"); cleanup_interface(target, 2); set_wep_key((char *) match->ssid_pass, if_name, 1); } else if (strcmp(match->ssid_auth, "none") == 0) { printf("no security has been set\n"); cleanup_interface(target, 1); } if (target->ipv6_auto) set_ipv6_auto(if_name); start_dhclient(if_name); while (retries != 0) { if (connection_active(if_name, 1)) { /* * If we are successfully connected to the network * and we don't need additional auth, then we are good. */ sleep(1); res = internet_connectivity_check(match); if (res == 1) { update_status(CONNECTED, match->ssid_name); return 1; } else if (res == 2) { /* * This is a hotspot; run user-defined command * or open default web browser. */ if (!config->additional_auth_exec) hotspot(match); return 1; } else { printf("not active, waiting...\n"); sleep(5); retries--; } } } match = match->next; retries = 1; } clear_ssid(all); return res; }