Commit 15910882 authored by Franco Fichtner's avatar Franco Fichtner

config: more fixes and sanity; #5

parent c0b388ad
...@@ -162,62 +162,68 @@ EOD; ...@@ -162,62 +162,68 @@ EOD;
} }
} while (!$lanif); } while (!$lanif);
while ($lanif != '') { $done = !$lanif; /* only if lan was set */
while (!$done) {
/* optional interfaces */ /* optional interfaces */
$optif = array(); $optif = array();
$i = 0; $i = 0;
while (1) { while (1) {
if ($optif[$i]) if ($optif[$i]) {
$i++; $i++;
}
$io = $i + 1; $io = $i + 1;
if($config['interfaces']['opt' . $io]['descr']) if ($config['interfaces']['opt' . $io]['descr']) {
printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']); printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']);
}
printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" . printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" .
"(or nothing if finished):%s"), "\n", $io, "\n", " "); "(or nothing if finished):%s"), "\n", $io, "\n", " ");
$optif[$i] = chop(fgets($fp)); $optif[$i] = chop(fgets($fp));
if ($optif[$i]) { if ($optif[$i] == '') {
if ($optif[$i] === "a") { unset($optif[$i]);
$ad = autodetect_interface(gettext("Optional") . " " . $io, $fp); $done = true;
if ($ad) break;
$optif[$i] = $ad; }
else
unset($optif[$i]); if ($optif[$i] == 'a') {
} else if (!array_key_exists($optif[$i], $iflist)) { $ad = autodetect_interface(gettext("Optional") . " " . $io, $fp);
printf(gettext("%sInvalid interface name '%s'%s"), "\n", $optif[$i], "\n"); if (!$ad) {
unset($optif[$i]); unset($optif[$i]);
continue; continue;
} }
} else { $optif[$i] = $ad;
unset($optif[$i]);
break;
} }
}
/* check for double assignments */ if (!array_key_exists($optif[$i], $iflist)) {
$ifarr = array_merge(array($lanif, $wanif), $optif); printf(gettext("%sInvalid interface name '%s'%s"), "\n", $optif[$i], "\n");
unset($optif[$i]);
continue;
}
$again = false; /* check for double assignments */
$ifarr = array_merge(array($lanif, $wanif), $optif);
$again = false;
for ($i = 0; $i < (count($ifarr)-1); $i++) { for ($k = 0; $k < (count($ifarr)-1); $k++) {
for ($j = ($i+1); $j < count($ifarr); $j++) { for ($j = ($k+1); $j < count($ifarr); $j++) {
if ($ifarr[$i] == $ifarr[$j]) { if ($ifarr[$k] == $ifarr[$j]) {
$again = true; $again = true;
echo <<<EOD echo <<<EOD
Error: you cannot assign the same interface name twice! Error: you cannot assign the same interface name twice!
EOD; EOD;
}
} }
} }
}
if ($again) { if ($again) {
continue; unset($optif[$i]);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment