inline bool app_init_config() { #ifdef _WIN32 std::string global_config_file = "gsmartcontrol.conf"; // installation dir s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; // $HOME/program_name.conf #else std::string global_config_file = std::string(PACKAGE_SYSCONF_DIR) + hz::DIR_SEPARATOR_S + "gsmartcontrol.conf"; s_home_config_file = hz::get_home_dir() + hz::DIR_SEPARATOR_S + ".gsmartcontrolrc"; #endif hz::FsPath gp(global_config_file); // Default system-wide settings. This file is empty by default. hz::FsPath hp(s_home_config_file); // Per-user settings. if (gp.exists() && gp.is_readable()) rconfig::load_from_file(gp.str()); if (hp.exists() && hp.is_readable()) rconfig::load_from_file(hp.str()); rconfig::dump_tree(); init_default_settings(); // initialize /default #ifdef ENABLE_GLIB rconfig::autosave_set_config_file(s_home_config_file); uint32_t autosave_timeout = rconfig::get_data<uint32_t>("system/config_autosave_timeout"); if (autosave_timeout) rconfig::autosave_start(autosave_timeout); #endif return true; }
int reaver_main(int argc, char **argv) { int ret_val = EXIT_FAILURE, r = 0; time_t start_time = 0, end_time = 0; struct wps_data *wps = NULL; globule_init(); init_default_settings(); fprintf(stderr, "\nReaver v%s WiFi Protected Setup Attack Tool\n", get_version()); fprintf(stderr, "Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <*****@*****.**>\n\n"); if(argc < 2) { ret_val = reaver_usage(argv[0]); goto end; } /* Process the command line arguments */ if(process_arguments(argc, argv) == EXIT_FAILURE) { ret_val = reaver_usage(argv[0]); goto end; } /* Double check reaver_usage */ if(!get_iface() || (memcmp(get_bssid(), NULL_MAC, MAC_ADDR_LEN) == 0)) { reaver_usage(argv[0]); goto end; } /* If no MAC address was provided, get it ourselves */ if(memcmp(get_mac(), NULL_MAC, MAC_ADDR_LEN) == 0) { if(!read_iface_mac()) { fprintf(stderr, "[-] Failed to retrieve a MAC address for interface '%s'!\n", get_iface()); goto end; } } /* Sanity checking on the message timeout value */ if(get_m57_timeout() > M57_MAX_TIMEOUT) { set_m57_timeout(M57_MAX_TIMEOUT); } else if(get_m57_timeout() <= 0) { set_m57_timeout(M57_DEFAULT_TIMEOUT); } /* Sanity checking on the receive timeout value */ if(get_rx_timeout() <= 0) { set_rx_timeout(DEFAULT_TIMEOUT); } /* Initialize signal handlers */ sigint_init(); sigalrm_init(); /* Mark the start time */ start_time = time(NULL); /* Do it. */ crack(); /* Mark the end time */ end_time = time(NULL); /* Check our key status */ if(get_key_status() == KEY_DONE) { wps = get_wps(); cprintf(VERBOSE, "[+] Pin cracked in %d seconds\n", (int) (end_time - start_time)); cprintf(CRITICAL, "[+] WPS PIN: '%s'\n", get_pin()); if(wps->key) cprintf(CRITICAL, "[+] WPA PSK: '%s'\n", wps->key); if(wps->essid) cprintf(CRITICAL, "[+] AP SSID: '%s'\n", wps->essid); /* Run user-supplied command */ if(get_exec_string()) { r = system(get_exec_string()); } ret_val = EXIT_SUCCESS; } else { cprintf(CRITICAL, "[-] Failed to recover WPA key\n"); } save_session(); end: globule_deinit(); return ret_val; }
// TODO refactor to match same order in main.h UTOX_SAVE *config_load(void) { UTOX_SAVE *save = utox_load_config(); // TODO: Remove this in ~0.18.0 release if (!save) { LOG_NOTE("Settings", "Unable to load uTox settings from %s. Trying old %s.", config_file_name, config_file_name_old); save = utox_data_load_utox(); } if (!save) { LOG_ERR("Settings", "Unable to load uTox settings. Use defaults."); save = init_default_settings(); } if (save->scale > 30) { save->scale = 30; } else if (save->scale < 5) { save->scale = 10; } if (save->window_width < MAIN_WIDTH) { save->window_width = MAIN_WIDTH; } if (save->window_height < MAIN_HEIGHT) { save->window_height = MAIN_HEIGHT; } /* UX Settings */ dropdown_language.selected = dropdown_language.over = settings.language = save->language; dropdown_dpi.selected = dropdown_dpi.over = save->scale - 5; switch_save_chat_history.switch_on = save->logging_enabled; switch_close_to_tray.switch_on = save->close_to_tray; switch_start_in_tray.switch_on = save->start_in_tray; switch_mini_contacts.switch_on = save->use_mini_flist; switch_magic_sidebar.switch_on = save->magic_flist_enabled; switch_ipv6.switch_on = save->enableipv6; switch_udp.switch_on = !save->disableudp; switch_udp.panel.disabled = save->force_proxy; switch_proxy.switch_on = save->proxyenable; switch_proxy_force.switch_on = save->force_proxy; switch_proxy_force.panel.disabled = !save->proxyenable; switch_auto_startup.switch_on = save->auto_startup; switch_auto_update.switch_on = save->auto_update; settings.group_notifications = dropdown_global_group_notifications.selected = dropdown_global_group_notifications.over = save->group_notifications; switch_audible_notifications.switch_on = save->audible_notifications_enabled; switch_audio_filtering.switch_on = save->audio_filtering_enabled; switch_push_to_talk.switch_on = save->push_to_talk; switch_status_notifications.switch_on = save->status_notifications; dropdown_theme.selected = dropdown_theme.over = save->theme; switch_typing_notes.switch_on = !save->no_typing_notifications; flist_set_filter(save->filter); /* roster list filtering */ /* Network settings */ settings.enable_ipv6 = save->enableipv6; settings.enable_udp = !save->disableudp; settings.use_proxy = !!save->proxyenable; settings.proxy_port = save->proxy_port; settings.force_proxy = save->force_proxy; if (strlen((char *)save->proxy_ip) <= proxy_address_size){ strcpy((char *)proxy_address, (char *)save->proxy_ip); } edit_proxy_ip.length = strlen((char *)save->proxy_ip); strcpy((char *)edit_proxy_ip.data, (char *)save->proxy_ip); if (save->proxy_port) { edit_proxy_port.length = snprintf((char *)edit_proxy_port.data, edit_proxy_port.maxlength + 1, "%u", save->proxy_port); if (edit_proxy_port.length >= edit_proxy_port.maxlength + 1) { edit_proxy_port.length = edit_proxy_port.maxlength; } } /* UX settings */ settings.logging_enabled = save->logging_enabled; settings.close_to_tray = save->close_to_tray; settings.start_in_tray = save->start_in_tray; settings.start_with_system = save->auto_startup; settings.use_mini_flist = save->use_mini_flist; settings.magic_flist_enabled = save->magic_flist_enabled; settings.use_long_time_msg = save->use_long_time_msg; settings.ringtone_enabled = save->audible_notifications_enabled; settings.audiofilter_enabled = save->audio_filtering_enabled; settings.send_typing_status = !save->no_typing_notifications; settings.status_notifications = save->status_notifications; settings.window_width = save->window_width; settings.window_height = save->window_height; settings.last_version = save->utox_last_version; loaded_audio_out_device = save->audio_device_out; loaded_audio_in_device = save->audio_device_in; settings.auto_update = save->auto_update; switch_auto_update.switch_on = save->auto_update; settings.update_to_develop = save->update_to_develop; settings.send_version = save->send_version; settings.video_fps = save->video_fps ? save->video_fps : 25; edit_video_fps.length = snprintf((char *)edit_video_fps.data, edit_video_fps.maxlength + 1, "%u", save->video_fps); if (edit_video_fps.length > edit_video_fps.maxlength) { edit_video_fps.length = edit_video_fps.maxlength; } // TODO: Don't clobber (and start saving) commandline flags. // Allow users to override theme on the cmdline. if (settings.theme == UINT32_MAX) { settings.theme = save->theme; } ui_set_scale(save->scale); if (save->push_to_talk) { init_ptt(); } return save; }
static void load_settings() { init_default_settings(); persist_read_data(SETTINGS_KEY, &settings, sizeof(settings)); }