Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwife.git;a=commitdiff;h=3ad72f3c7d39ea2f9135b6dc817308dde7d28ab5

commit 3ad72f3c7d39ea2f9135b6dc817308dde7d28ab5
Author: Elentir <elen...@mailoo.org>
Date:   Sat Jan 23 20:51:09 2010 +0100

configsource: dhcp detection fixes

* check only for regular files
* add interface name to the interface struct
* move this "netconfig stop" before post_net_config() call

diff --git a/src/plugins/configsource.c b/src/plugins/configsource.c
index 79fe11e..dc2b7fb 100644
--- a/src/plugins/configsource.c
+++ b/src/plugins/configsource.c
@@ -1104,6 +1104,7 @@ int run_net_config(GList **config)
char *lastprof = NULL;
fwnet_interface_t *newinterface = NULL;
struct dirent *ent = NULL;
+       struct stat info;
DIR *dir;
int brk = 0;

@@ -1147,22 +1148,29 @@ int run_net_config(GList **config)
dir=opendir("/var/run/dhcpcd/resolv.conf/");
while((ent = readdir(dir))) {
if(strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) {
-                               ptr = g_strdup_printf(_("An active connection 
seems to have been found on interface %s using dhcp.\nDo you want to use it?"), 
ent->d_name);
-                               switch(fwife_question(ptr))
-                               {
-                                       case GTK_RESPONSE_YES:
-                                               newinterface->dhcp_opts[0]='\0';
-                                               newinterface->options = 
g_list_append(newinterface->options, strdup("dhcp"));
-                                               sprintf(newprofile->name, 
"default");
-                                               newprofile->interfaces = 
g_list_append(newprofile->interfaces, newinterface);
-                                               data_put(config, "netprofile", 
newprofile);
-                                               free(ptr);
-                                               return 0;
-                                       case GTK_RESPONSE_NO:
-                                               brk = 1;
-                                               break;
-                               }
+                               ptr = 
g_strdup_printf("/var/run/dhcpcd/resolv.conf/%s", ent->d_name);
+                               if(stat(ptr, &info))
+                                       continue;
free(ptr);
+                               if(S_ISREG(info.st_mode)) {
+                                       ptr = g_strdup_printf(_("An active 
connection seems to have been found on interface %s using dhcp.\nDo you want to 
use it?"), ent->d_name);
+                                       switch(fwife_question(ptr))
+                                       {
+                                               case GTK_RESPONSE_YES:
+                                                       
snprintf(newinterface->name, IF_NAMESIZE, ent->d_name);
+                                                       
newinterface->dhcp_opts[0]='\0';
+                                                       newinterface->options = 
g_list_append(newinterface->options, strdup("dhcp"));
+                                                       
sprintf(newprofile->name, "default");
+                                                       newprofile->interfaces 
= g_list_append(newprofile->interfaces, newinterface);
+                                                       data_put(config, 
"netprofile", newprofile);
+                                                       free(ptr);
+                                                       return 0;
+                                               case GTK_RESPONSE_NO:
+                                                       brk = 1;
+                                                       break;
+                                       }
+                                       free(ptr);
+                               }
}
}
closedir(dir);
@@ -1179,8 +1187,6 @@ int run_net_config(GList **config)
}
}

-       fw_system("netconfig stop");
-
if(select_interface(newinterface) == -1)
return 0;

@@ -1222,7 +1228,8 @@ int run_net_config(GList **config)
free(newinterface);
return -1;
}
-
+
+       fw_system("netconfig stop");
if(post_net_config(newprofile, newinterface) == -1) {
free(newprofile);
free(newinterface);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to