/* Processes Reaver command line options */ int process_arguments(int argc, char **argv) { int ret_val = EXIT_SUCCESS; int c = 0, channel = 0; int long_opt_index = 0; char bssid[MAC_ADDR_LEN] = { 0 }; char mac[MAC_ADDR_LEN] = { 0 }; char *short_options = "b:e:m:i:t:d:c:T:x:r:g:l:o:p:s:C:KZA5ELfnqvDShwN6J"; struct option long_options[] = { { "pixie-dust", no_argument, NULL, 'K' }, { "interface", required_argument, NULL, 'i' }, { "bssid", required_argument, NULL, 'b' }, { "essid", required_argument, NULL, 'e' }, { "mac", required_argument, NULL, 'm' }, { "timeout", required_argument, NULL, 't' }, { "m57-timeout", required_argument, NULL, 'T' }, { "delay", required_argument, NULL, 'd' }, { "lock-delay", required_argument, NULL, 'l' }, { "fail-wait", required_argument, NULL, 'x' }, { "channel", required_argument, NULL, 'c' }, { "session", required_argument, NULL, 's' }, { "recurring-delay", required_argument, NULL, 'r' }, { "max-attempts", required_argument, NULL, 'g' }, { "out-file", required_argument, NULL, 'o' }, { "pin", required_argument, NULL, 'p' }, { "exec", required_argument, NULL, 'C' }, { "no-associate", no_argument, NULL, 'A' }, { "ignore-locks", no_argument, NULL, 'L' }, { "no-nacks", no_argument, NULL, 'N' }, { "eap-terminate", no_argument, NULL, 'E' }, { "dh-small", no_argument, NULL, 'S' }, { "fixed", no_argument, NULL, 'f' }, { "daemonize", no_argument, NULL, 'D' }, { "5ghz", no_argument, NULL, '5' }, { "repeat-m6", no_argument, NULL, '6' }, { "nack", no_argument, NULL, 'n' }, { "quiet", no_argument, NULL, 'q' }, { "verbose", no_argument, NULL, 'v' }, { "win7", no_argument, NULL, 'w' }, { "help", no_argument, NULL, 'h' }, { "timeout-is-nack", no_argument, NULL, 'J' }, { 0, 0, 0, 0 } }; /* Since this function may be called multiple times, be sure to set opt index to 0 each time */ optind = 0; while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1) { switch(c) { case 'Z': case 'K': pixie.do_pixie = 1; break; case 'i': set_iface(optarg); break; case 'b': str2mac(optarg, (unsigned char *) &bssid); set_bssid((unsigned char *) &bssid); break; case 'e': set_ssid(optarg); break; case 'm': str2mac(optarg, (unsigned char *) &mac); set_mac((unsigned char *) &mac); break; case 't': set_rx_timeout(atoi(optarg)); break; case 'T': set_m57_timeout(strtof(optarg, NULL) * SEC_TO_US); break; case 'c': channel = strtod(optarg, NULL); set_fixed_channel(1); break; case '5': set_wifi_band(AN_BAND); break; case '6': set_repeat_m6(1); break; case 'd': set_delay(atoi(optarg)); break; case 'l': set_lock_delay(atoi(optarg)); break; case 'p': parse_static_pin(optarg); break; case 's': set_session(optarg); break; case 'C': set_exec_string(optarg); break; case 'A': set_external_association(1); break; case 'L': set_ignore_locks(1); break; case 'o': set_log_file(fopen(optarg, "w")); break; case 'x': set_fail_delay(atoi(optarg)); break; case 'r': parse_recurring_delay(optarg); break; case 'g': set_max_pin_attempts(atoi(optarg)); break; case 'D': daemonize(); break; case 'E': set_eap_terminate(1); break; case 'S': set_dh_small(1); break; case 'n': cprintf(INFO, "[+] ignoring obsolete -n switch\n"); break; case 'J': set_timeout_is_nack(1); break; case 'f': set_fixed_channel(1); break; case 'v': set_debug(get_debug() + 1); break; case 'q': set_debug(CRITICAL); break; case 'w': set_win7_compat(1); break; case 'N': set_oo_send_nack(0); break; default: ret_val = EXIT_FAILURE; } } if(channel) { change_channel(channel); } return ret_val; }
int main(int argc, char *argv[]) { int c = 0; FILE *fp = NULL; int long_opt_index = 0, i = 0, channel = 0, passive = 0, mode = 0; int source = INTERFACE, ret_val = EXIT_FAILURE; struct bpf_program bpf = { 0 }; char *out_file = NULL, *last_optarg = NULL, *target = NULL, *bssid = NULL; char *short_options = "i:c:n:o:b:5sfuCDh"; struct option long_options[] = { { "bssid", required_argument, NULL, 'b' }, { "interface", required_argument, NULL, 'i' }, { "channel", required_argument, NULL, 'c' }, { "out-file", required_argument, NULL, 'o' }, { "probes", required_argument, NULL, 'n' }, { "daemonize", no_argument, NULL, 'D' }, { "file", no_argument, NULL, 'f' }, { "ignore-fcs", no_argument, NULL, 'C' }, { "5ghz", no_argument, NULL, '5' }, { "scan", no_argument, NULL, 's' }, { "survey", no_argument, NULL, 'u' }, { "help", no_argument, NULL, 'h' }, { 0, 0, 0, 0 } }; fprintf(stderr, "\nWash v%s WiFi Protected Setup Scan Tool\n", PACKAGE_VERSION); fprintf(stderr, "Copyright (c) 2011, Tactical Network Solutions, Craig Heffner <*****@*****.**>\n\n"); globule_init(); sql_init(); create_ap_table(); set_auto_channel_select(0); set_wifi_band(BG_BAND); set_debug(INFO); set_validate_fcs(1); set_log_file(stdout); set_max_num_probes(DEFAULT_MAX_NUM_PROBES); while((c = getopt_long(argc, argv, short_options, long_options, &long_opt_index)) != -1) { switch(c) { case 'f': source = PCAP_FILE; break; case 'i': set_iface(optarg); break; case 'b': bssid = strdup(optarg); break; case 'c': channel = atoi(optarg); set_fixed_channel(1); break; case '5': set_wifi_band(AN_BAND); break; case 'n': set_max_num_probes(atoi(optarg)); break; case 'o': out_file = strdup(optarg); break; case 's': mode = SCAN; break; case 'u': mode = SURVEY; break; case 'C': set_validate_fcs(0); break; case 'D': daemonize(); break; default: usage(argv[0]); goto end; } /* Track the last optarg. This is used later when looping back through any specified pcap files. */ if(optarg) { if(last_optarg) { free(last_optarg); } last_optarg = strdup(optarg); } } /* The interface value won't be set if capture files were specified; else, there should have been an interface specified */ if(!get_iface() && source != PCAP_FILE) { usage(argv[0]); goto end; } if(get_iface() && source == PCAP_FILE) { cprintf(CRITICAL, "[X] ERROR: -i and -f options cannot be used together.\n"); usage(argv[0]); goto end; } /* If we're reading from a file, be sure we don't try to transmit probe requests */ if(source == PCAP_FILE) { passive = 1; } /* Open the output file, if any. If none, write to stdout. */ if(out_file) { fp = fopen(out_file, "wb"); if(!fp) { cprintf(CRITICAL, "[X] ERROR: Failed to open '%s' for writing\n", out_file); goto end; } set_log_file(fp); } /* * Loop through all of the specified capture sources. If an interface was specified, this will only loop once and the * call to monitor() will block indefinitely. If capture files were specified, this will loop through each file specified * on the command line and monitor() will return after each file has been processed. */ for(i=argc-1; i>0; i--) { /* If the source is a pcap file, get the file name from the command line */ if(source == PCAP_FILE) { /* If we've gotten to the arguments, we're done */ if((argv[i][0] == '-') || (last_optarg && (memcmp(argv[i], last_optarg, strlen(last_optarg)) == 0)) ) { break; } else { target = argv[i]; } } /* Else, use the specified interface name */ else { target = get_iface(); } set_handle(capture_init(target)); if(!get_handle()) { cprintf(CRITICAL, "[X] ERROR: Failed to open '%s' for capturing\n", get_iface()); goto end; } if(pcap_compile(get_handle(), &bpf, PACKET_FILTER, 0, 0) != 0) { cprintf(CRITICAL, "[X] ERROR: Failed to compile packet filter\n"); goto end; } if(pcap_setfilter(get_handle(), &bpf) != 0) { cprintf(CRITICAL, "[X] ERROR: Failed to set packet filter\n"); goto end; } /* Do it. */ monitor(bssid, passive, source, channel, mode); printf("\n"); } ret_val = EXIT_SUCCESS; end: globule_deinit(); sql_cleanup(); if(bssid) free(bssid); if(out_file) free(out_file); if(wpsmon.fp) fclose(wpsmon.fp); return ret_val; }
int start_supplicant(const struct _SUPPLICANT_PARA_T * prTar, const char *pcIface) { char daemon_cmd[PROPERTY_VALUE_MAX]; char supp_status[PROPERTY_VALUE_MAX] = {'\0'}; int count = 200; /* wait at most 20 seconds for completion */ #ifdef HAVE_LIBC_SYSTEM_PROPERTIES const prop_info *pi; unsigned serial = 0; #endif /* Check whether already running */ if (property_get(prTar->acSuppPropName, supp_status, NULL) && strcmp(supp_status, "running") == 0) { return 0; } /* Before starting the daemon, make sure its config file exists */ if (ensure_config_file_exists(prTar->acSuppConfigFile, prTar->acSuppConfigTemplate) < 0) { LOGE("[%s] %s will not be enabled", pcIface, prTar->acSuppName); return -1; } /*Set interface UP (ifconfig "iface" up)*/ if(set_iface(pcIface, 1) < 0 ) { /*If interface up failed, skip the following actions*/ return -1; } /* Clear out any stale socket files that might be left over. */ LOGD("[%s] clear out stale sockets with prefix \"%s\" in %s", pcIface, prTar->acSuppCtrlPrefix, CONFIG_CTRL_IFACE_CLIENT_DIR); ctrl_cleanup(prTar->acSuppCtrlPrefix); LOGI("[%s] start %s", pcIface, prTar->acSuppName); #ifdef HAVE_LIBC_SYSTEM_PROPERTIES /* * Get a reference to the status property, so we can distinguish * the case where it goes stopped => running => stopped (i.e., * it start up, but fails right away) from the case in which * it starts in the stopped state and never manages to start * running at all. */ pi = __system_property_find(prTar->acSuppPropName); if (pi != NULL) { serial = pi->serial; } #endif property_get(prTar->acIfPropName, (char *)pcIface, prTar->acIfDefName); snprintf(daemon_cmd, PROPERTY_VALUE_MAX, prTar->acSuppDeamonCmd, prTar->acSuppName, pcIface, prTar->acSuppConfigFile); property_set("ctl.start", daemon_cmd); LOGD("[%s] supplicant start command: \"%s\"", pcIface, daemon_cmd); //property_set("ctl.start", prTar->acSuppName); sched_yield(); while (count-- > 0) { #ifdef HAVE_LIBC_SYSTEM_PROPERTIES if (pi == NULL) { pi = __system_property_find(prTar->acSuppPropName); } if (pi != NULL) { __system_property_read(pi, NULL, supp_status); if (strcmp(supp_status, "running") == 0) { return 0; } else if (pi->serial != serial && strcmp(supp_status, "stopped") == 0) { return -1; } } #else if (property_get(prTar->acSuppPropName, supp_status, NULL)) { if (strcmp(supp_status, "running") == 0) return 0; } #endif usleep(100000); } return -1; }
int ip6tables_process_entry( struct ip6tc_handle* handle, const char* chain_name, int rulenum, const char* target_name, const ip_address_t* src_ip_address, const ip_address_t* dst_ip_address, const char* in_iface, const char* out_iface, uint16_t protocol, uint16_t type, int cmd, bool force) { size_t size; struct ip6t_entry *fw; struct xt_entry_target *target; struct xt_entry_match *match ; ip6t_chainlabel chain; int res; int sav_errno; /* Add an entry */ memset (chain, 0, sizeof (chain)); size = XT_ALIGN (sizeof (struct ip6t_entry)) + XT_ALIGN (sizeof (struct xt_entry_target) + 1); if ( protocol == IPPROTO_ICMPV6 ) size += XT_ALIGN ( sizeof(struct xt_entry_match) ) + XT_ALIGN ( sizeof(struct ip6t_icmp) ) ; fw = (struct ip6t_entry*)MALLOC(size); fw->target_offset = XT_ALIGN ( sizeof ( struct ip6t_entry ) ) ; if ( src_ip_address && src_ip_address->ifa.ifa_family != AF_UNSPEC ) { memcpy(&fw->ipv6.src, &src_ip_address->u.sin6_addr, sizeof ( src_ip_address->u.sin6_addr ) ); memset ( &fw->ipv6.smsk, 0xff, sizeof(fw->ipv6.smsk)); } if ( dst_ip_address && dst_ip_address->ifa.ifa_family != AF_UNSPEC ) { memcpy(&fw->ipv6.dst, &dst_ip_address->u.sin6_addr, sizeof ( dst_ip_address->u.sin6_addr ) ); memset ( &fw->ipv6.dmsk, 0xff, sizeof(fw->ipv6.smsk)); } if (in_iface) set_iface(fw->ipv6.iniface, fw->ipv6.iniface_mask, in_iface); if (out_iface) set_iface(fw->ipv6.outiface, fw->ipv6.outiface_mask, out_iface); if ( protocol != IPPROTO_NONE ) { fw->ipv6.proto = protocol ; fw->ipv6.flags |= IP6T_F_PROTO ; // IPv6 only if ( protocol == IPPROTO_ICMPV6 ) { match = (struct xt_entry_match*)((char*)fw + fw->target_offset); match->u.match_size = XT_ALIGN ( sizeof (struct xt_entry_match) ) + XT_ALIGN ( sizeof (struct ip6t_icmp) ) ; match->u.user.revision = 0; fw->target_offset += match->u.match_size ; strcpy ( match->u.user.name, "icmp6" ) ; struct ip6t_icmp *icmpinfo = (struct ip6t_icmp *) match->data; icmpinfo->type = type ; // type to match icmpinfo->code[0] = 0 ; // code lower icmpinfo->code[1] = 0xff ; // code upper icmpinfo->invflags = 0 ; // don't invert } } // target is XTC_LABEL_DROP/XTC_LABEL_ACCEPT fw->next_offset = size; target = ip6t_get_target ( fw ) ; target->u.user.target_size = XT_ALIGN (sizeof (struct xt_entry_target) + 1); strcpy (target->u.user.name, target_name ); // fw->ip.flags |= IPT_F_GOTO; strcpy (chain, chain_name); // Use iptc_append_entry to add to the chain if (cmd == IPADDRESS_DEL) { unsigned char matchmask[fw->next_offset]; memset(matchmask, 0xff, fw->next_offset); res = ip6tc_delete_entry ( chain, fw, matchmask, handle); } else if ( rulenum == -1 ) res = ip6tc_append_entry (chain, fw, handle ) ; else res = ip6tc_insert_entry (chain, fw, rulenum, handle ) ; sav_errno = errno ; if (res != 1 && (!force || sav_errno != ENOENT)) { log_message(LOG_INFO, "ip6tables_process_entry for chain %s returned %d: %s", chain, res, ip6tc_strerror (sav_errno) ) ; return sav_errno ; } return 0 ; }
int wifi_hotspot_set_iface(int on) { return set_iface(rHotspotSuppInfo.acIfName, on); }
void parse_options(int argc, char **argv) { int c; static struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { "iface", required_argument, NULL, 'i' }, { "lifaces", no_argument, NULL, 'I' }, { "netmask", required_argument, NULL, 'n' }, { "address", required_argument, NULL, 'A' }, { "write", required_argument, NULL, 'w' }, { "read", required_argument, NULL, 'r' }, { "pcapfilter", required_argument, NULL, 'f' }, { "reversed", no_argument, NULL, 'R' }, { "proto", required_argument, NULL, 't' }, { "plugin", required_argument, NULL, 'P' }, { "filter", required_argument, NULL, 'F' }, #ifdef HAVE_EC_LUA { "lua-script", required_argument, NULL, 0 }, { "lua-args", required_argument, NULL, 0 }, #endif { "superquiet", no_argument, NULL, 'Q' }, { "quiet", no_argument, NULL, 'q' }, { "script", required_argument, NULL, 's' }, { "silent", no_argument, NULL, 'z' }, #ifdef WITH_IPV6 { "ip6scan", no_argument, NULL, '6' }, #endif { "unoffensive", no_argument, NULL, 'u' }, { "nosslmitm", no_argument, NULL, 'S' }, { "load-hosts", required_argument, NULL, 'j' }, { "save-hosts", required_argument, NULL, 'k' }, { "wifi-key", required_argument, NULL, 'W' }, { "config", required_argument, NULL, 'a' }, { "dns", no_argument, NULL, 'd' }, { "regex", required_argument, NULL, 'e' }, { "visual", required_argument, NULL, 'V' }, { "ext-headers", no_argument, NULL, 'E' }, { "log", required_argument, NULL, 'L' }, { "log-info", required_argument, NULL, 'l' }, { "log-msg", required_argument, NULL, 'm' }, { "compress", no_argument, NULL, 'c' }, { "text", no_argument, NULL, 'T' }, { "curses", no_argument, NULL, 'C' }, { "daemon", no_argument, NULL, 'D' }, { "gtk", no_argument, NULL, 'G' }, { "mitm", required_argument, NULL, 'M' }, { "only-mitm", no_argument, NULL, 'o' }, { "bridge", required_argument, NULL, 'B' }, { "broadcast", required_argument, NULL, 'b' }, { "promisc", no_argument, NULL, 'p' }, { "gateway", required_argument, NULL, 'Y' }, { "certificate", required_argument, NULL, 0 }, { "private-key", required_argument, NULL, 0 }, { 0 , 0 , 0 , 0} }; for (c = 0; c < argc; c++) DEBUG_MSG("parse_options -- [%d] [%s]", c, argv[c]); /* OPTIONS INITIALIZATION */ GBL_PCAP->promisc = 1; GBL_FORMAT = &ascii_format; GBL_OPTIONS->ssl_mitm = 1; GBL_OPTIONS->broadcast = 0; GBL_OPTIONS->ssl_cert = NULL; GBL_OPTIONS->ssl_pkey = NULL; /* OPTIONS INITIALIZED */ optind = 0; int option_index = 0; while ((c = getopt_long (argc, argv, "A:a:bB:CchDdEe:F:f:GhIi:j:k:L:l:M:m:n:oP:pQqiRr:s:STt:uV:vW:w:Y:z6", long_options, &option_index)) != EOF) { /* used for parsing arguments */ char *opt_end = optarg; while (opt_end && *opt_end) opt_end++; /* enable a loaded filter script? */ switch (c) { case 'M': set_mitm(optarg); break; case 'o': set_onlymitm(); //select_text_interface(); break; case 'b': set_broadcast(); break; case 'B': set_iface_bridge(optarg); break; case 'p': set_promisc(); break; #ifndef JUST_LIBRARY case 'T': select_text_interface(); break; case 'C': select_curses_interface(); break; case 'G': select_gtk_interface(); break; case 'D': select_daemon_interface(); break; #endif case 'R': set_reversed(); break; case 't': set_proto(optarg); break; case 'P': set_plugin(optarg); break; case 'i': set_iface(optarg); break; case 'I': /* this option is only useful in the text interface */ set_lifaces(); break; case 'Y': set_secondary(optarg); break; case 'n': set_netmask(optarg); break; case 'A': set_address(optarg); break; case 'r': set_read_pcap(optarg); break; case 'w': set_write_pcap(optarg); break; case 'f': set_pcap_filter(optarg); break; case 'F': load_filter(opt_end, optarg); break; case 'L': set_loglevel_packet(optarg); case 'l': set_loglevel_info(optarg); break; case 'm': set_loglevel_true(optarg); break; case 'c': set_compress(); break; case 'e': opt_set_regex(optarg); break; case 'Q': set_superquiet(); /* no break, quiet must be enabled */ case 'q': set_quiet(); break; case 's': set_script(optarg); break; case 'z': set_silent(); break; #ifdef WITH_IPV6 case '6': set_ip6scan(); break; #endif case 'u': set_unoffensive(); break; case 'S': disable_sslmitm(); break; case 'd': set_resolve(); break; case 'j': load_hosts(optarg); break; case 'k': save_hosts(optarg); break; case 'V': opt_set_format(optarg); break; case 'E': set_ext_headers(); break; case 'W': set_wifi_key(optarg); break; case 'a': set_conf_file(optarg); break; case 'h': ec_usage(); break; case 'v': printf("%s %s\n", GBL_PROGRAM, GBL_VERSION); clean_exit(0); break; /* Certificate and private key options */ case 0: if (!strcmp(long_options[option_index].name, "certificate")) { GBL_OPTIONS->ssl_cert = strdup(optarg); } else if (!strcmp(long_options[option_index].name, "private-key")) { GBL_OPTIONS->ssl_pkey = strdup(optarg); #ifdef HAVE_EC_LUA } else if (!strcmp(long_options[option_index].name,"lua-args")) { ec_lua_cli_add_args(strdup(optarg)); } else if (!strcmp(long_options[option_index].name,"lua-script")) { ec_lua_cli_add_script(strdup(optarg)); break; #endif } else { fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); } break; case ':': // missing parameter fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); break; case '?': // unknown option fprintf(stdout, "\nTry `%s --help' for more options.\n\n", GBL_PROGRAM); clean_exit(-1); break; } } DEBUG_MSG("parse_options: options parsed"); /* TARGET1 and TARGET2 parsing */ if (argv[optind]) { GBL_OPTIONS->target1 = strdup(argv[optind]); DEBUG_MSG("TARGET1: %s", GBL_OPTIONS->target1); if (argv[optind+1]) { GBL_OPTIONS->target2 = strdup(argv[optind+1]); DEBUG_MSG("TARGET2: %s", GBL_OPTIONS->target2); } } /* create the list form the TARGET format (MAC/IPrange/PORTrange) */ compile_display_filter(); DEBUG_MSG("parse_options: targets parsed"); /* check for other options */ if (GBL_SNIFF->start == NULL) set_unified_sniff(); if (GBL_OPTIONS->read && GBL_PCAP->filter) FATAL_ERROR("Cannot read from file and set a filter on interface"); if (GBL_OPTIONS->read && GBL_SNIFF->type != SM_UNIFIED ) FATAL_ERROR("You can read from a file ONLY in unified sniffing mode !"); if (GBL_OPTIONS->mitm && GBL_SNIFF->type != SM_UNIFIED ) FATAL_ERROR("You can't do mitm attacks in bridged sniffing mode !"); if (GBL_SNIFF->type == SM_BRIDGED && GBL_PCAP->promisc == 0) FATAL_ERROR("During bridged sniffing the iface must be in promisc mode !"); if (GBL_OPTIONS->quiet && GBL_UI->type != UI_TEXT) FATAL_ERROR("The quiet option is useful only with text only UI"); if (GBL_OPTIONS->load_hosts && GBL_OPTIONS->save_hosts) FATAL_ERROR("Cannot load and save at the same time the hosts list..."); if (GBL_OPTIONS->unoffensive && GBL_OPTIONS->mitm) FATAL_ERROR("Cannot use mitm attacks in unoffensive mode"); if (GBL_OPTIONS->read && GBL_OPTIONS->mitm) FATAL_ERROR("Cannot use mitm attacks while reading from file"); #ifndef JUST_LIBRARY if (GBL_UI->init == NULL) FATAL_ERROR("Please select an User Interface"); #endif /* force text interface for only mitm attack */ /* Do not select text interface for only MiTM mode if (GBL_OPTIONS->only_mitm) { if (GBL_OPTIONS->mitm) select_text_interface(); else FATAL_ERROR("Only mitm requires at least one mitm method"); } */ DEBUG_MSG("parse_options: options combination looks good"); return; }
void DeviceSettings::slotApply() { bool succeed = true; /* Manual Settings */ if ( manualButton->isChecked() ) { // SET IP int ret = set_iface( _dev.ascii(), ipaddr->text().ascii(), // we can ommit broadcast and netmask. broadcast->text().length() ? broadcast->text().ascii() : 0, netmask->text().length() ? netmask->text().ascii() : 0 ); if ( ret < 0 ) succeed = false; // SET ROUTE if ( !defaultgw->text().isEmpty() ) { ret = set_default_route( defaultgw->text().ascii() ); if ( ret < 0 ) succeed = false; } ret = writeDnsList(); if ( ret < 0 ) succeed = false; } /* Automatic (DHCP) */ else if ( automaticButton->isChecked() ) { // I don't like to invoke programs directly // but we have no chance for now, // this is clearly a bad hack :(. QFile pidfile( "/var/run/dhcpcd-" + _dev + ".pid" ); if ( pidfile.exists() ) { KProcess killdhcpcd; killdhcpcd << "/sbin/dhcpcd" << "-k" << _dev; killdhcpcd.start(); killdhcpcd.wait(); // how ugly... wait 2 seconds to dhcpcd to finish its work... if ( killdhcpcd.normalExit() ) QTimer::singleShot( 2000, this, SLOT( startDhcpcd() ) ); else printf( "failed (kill)\n" ); } else startDhcpcd(); } writeSettings(); if ( succeed ) { QString msg = i18n( "Successfully configured device: " ) + _dev; KMessageBox::information( this, msg, i18n( "Done!" ) ); } else { QString msg = i18n( "Failed to configure device: " ) + _dev; KMessageBox::error( this, msg, i18n( "Error!" ) ); } done( 0 ); }