mirror of
https://github.com/troglobit/finit.git
synced 2026-11-15 19:13:11 +00:00
networking(): check first ifup exists
Check first ifup exists before using it since this is really something only exits on some distros an in different ways. Debian/Ubunu has an package for this while others have it in the initscripts package(s) , meaning the file can be around even without the prog. Signed-off-by: crazy <crazy@frugalware.org>
This commit is contained in:
1 parent
a44daf20cb
commit
885056a6c9
1 file changed
+27
-24
+27
-24
@@ -155,36 +155,39 @@ static void networking(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Debian/Ubuntu/Busybox interfaces file */
|
/* Debian/Ubuntu/Busybox/RH/Suse */
|
||||||
fp = fopen("/etc/network/interfaces", "r");
|
if (fexist("/sbin/ifup")) {
|
||||||
if (fp) {
|
/* interfaces file */
|
||||||
int i = 0;
|
fp = fopen("/etc/network/interfaces", "r");
|
||||||
char buf[160];
|
if (fp) {
|
||||||
|
int i = 0;
|
||||||
|
char buf[160];
|
||||||
|
|
||||||
/* Bring up all 'auto' interfaces */
|
/* Bring up all 'auto' interfaces */
|
||||||
while (fgets(buf, sizeof(buf), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
char cmd[80];
|
char cmd[80];
|
||||||
char *line, *ifname = NULL;
|
char *line, *ifname = NULL;
|
||||||
|
|
||||||
chomp(buf);
|
chomp(buf);
|
||||||
line = strip_line(buf);
|
line = strip_line(buf);
|
||||||
|
|
||||||
if (!strncmp(line, "auto", 4))
|
if (!strncmp(line, "auto", 4))
|
||||||
ifname = &line[5];
|
ifname = &line[5];
|
||||||
if (!strncmp(line, "allow-hotplug", 13))
|
if (!strncmp(line, "allow-hotplug", 13))
|
||||||
ifname = &line[14];
|
ifname = &line[14];
|
||||||
|
|
||||||
if (!ifname)
|
if (!ifname)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(cmd, 80, "/sbin/ifup %s", ifname);
|
snprintf(cmd, 80, "/sbin/ifup %s", ifname);
|
||||||
run_interactive(cmd, "Bringing up interface %s", ifname);
|
run_interactive(cmd, "Bringing up interface %s", ifname);
|
||||||
i++;
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
if (i)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
if (i)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fall back to bring up at least loopback */
|
/* Fall back to bring up at least loopback */
|
||||||
|
|||||||
Reference in new issue
Block a user