interfaces: l2tp/pptp cleanup; closes #2707

The interfaces are created by mpd5 daemon during configuration.
We do not seem to have more than one issue here: IPv6 disable
is too soon but that is easily fixed.  Device creation moves
on ok and there is no apparent error in functionality with or
without it.

While here fix the link when a $pppid is set and properly protect
the redirect url.  Previously empty() was too strict and it ignored
$pppid of zero.

Also remove spurious "IP Address" help text from PPP device
configuration.
This commit is contained in:
Franco Fichtner 2021-01-03 20:43:01 +01:00
parent 6b407b51dd
commit 7fda1670ce
3 changed files with 22 additions and 30 deletions

View File

@ -1225,7 +1225,8 @@ function interface_ppps_configure($interface)
$gateways = isset($ppp['gateway']) ? explode(',', $ppp['gateway']) : array();
$subnets = isset($ppp['subnet']) ? explode(',', $ppp['subnet']) : array();
/* We bring up the parent interface first because if DHCP is configured on the parent we need
/*
* We bring up the parent interface first because if DHCP is configured on the parent we need
* to obtain an address first so we can write it in the mpd .conf file for PPTP and L2TP configs
*/
foreach ($ports as $pid => $port) {
@ -2173,9 +2174,11 @@ EOD;
fclose($fd_set);
/* Making sure regulatory settings have actually changed
* before applying, because changing them requires bringing
* down all wireless networks on the interface. */
/*
* Making sure regulatory settings have actually changed
* before applying, because changing them requires bringing
* down all wireless networks on the interface.
*/
exec("{$ifconfig} " . escapeshellarg($if), $output);
$ifconfig_str = implode($output);
unset($output);
@ -2396,9 +2399,6 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
}
}
/* Disable Accepting router advertisements unless specifically requested */
mwexecf('/sbin/ifconfig %s inet6 -accept_rtadv', array($realif));
/* wireless configuration? */
if (isset($wancfg['wireless']) && is_array($wancfg['wireless']) && !$linkupevent) {
interface_wireless_configure($realif, $wancfg, $wancfg['wireless']);
@ -2460,6 +2460,9 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
break;
}
/* disable accepting router advertisements unless specifically requested */
mwexecf('/sbin/ifconfig %s inet6 -accept_rtadv', array($realif));
if (isset($wancfg['ipaddrv6'])) {
switch ($wancfg['ipaddrv6']) {
case 'slaac':

View File

@ -435,9 +435,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['ipaddrv6'] = null;
}
/*
locate PPP details (if any)
*/
/* locate PPP details (if any) */
$pppid = count($a_ppps);
foreach ($a_ppps as $key => $ppp) {
if ($a_interfaces[$if]['if'] == $ppp['if']) {
@ -472,9 +470,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pppid = count($a_ppps);
}
/*
Wireless interface
*/
if (isset($a_interfaces[$if]['wireless'])) {
/* Sync first to be sure it displays the actual settings that will be used */
interface_sync_wireless_clones($a_interfaces[$if], false);
@ -2289,10 +2284,10 @@ include("head.inc");
<tr>
<td><?=gettext("Advanced PPP"); ?></td>
<td>
<?php if (!empty($pconfig['pppid'])): ?>
<?= sprintf(gettext('%sClick here%s to edit PPP configuration.'),'<a href="/interfaces_ppps_edit.php?id=' . htmlspecialchars($pconfig['pppid']) . '" class="navlnk">', '</a>') ?>
<?php if (!empty($a_ppps[$pppid])): ?>
<?= sprintf(gettext('%sClick here%s to edit PPP configuration.'), url_safe('<a href="/interfaces_ppps_edit.php?id=%d">', $pppid), '</a>') ?>
<?php else: ?>
<?= sprintf(gettext("%sClick here%s to create a PPP configuration."), '<a href="/interfaces_ppps_edit.php" class="navlnk">', '</a>') ?>
<?= sprintf(gettext("%sClick here%s to create a PPP configuration."), '<a href="/interfaces_ppps_edit.php">', '</a>') ?>
<?php endif; ?>
</td>
</tr>
@ -2361,13 +2356,13 @@ include("head.inc");
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Advanced and MLPPP"); ?></td>
<?php if (isset($pconfig['pppid'])): ?>
<?php if (!empty($a_ppps[$pppid])): ?>
<td>
<?= sprintf(gettext('%sClick here%s for additional PPPoE configuration options. Save first if you made changes.'),'<a href="/interfaces_ppps_edit.php?id='.$pconfig['pppid'].'" class="navlnk">','</a>') ?>
<?= sprintf(gettext('%sClick here%s for additional PPPoE configuration options. Save first if you made changes.'), url_safe('<a href="/interfaces_ppps_edit.php?id=%d">', $pppid), '</a>') ?>
</td>
<?php else: ?>
<td>
<?= sprintf(gettext('%sClick here%s for advanced PPPoE configuration options and MLPPP configuration.'),'<a href="/interfaces_ppps_edit.php" class="navlnk">','</a>') ?>
<?= sprintf(gettext('%sClick here%s for advanced PPPoE configuration options and MLPPP configuration.'),'<a href="/interfaces_ppps_edit.php">','</a>') ?>
</td>
<?php endif; ?>
</tr>
@ -2443,10 +2438,10 @@ include("head.inc");
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Advanced"); ?></td>
<td>
<?php if (!empty($pconfig['pppid'])): ?>
<?= sprintf(gettext("%sClick here%s for additional PPTP and L2TP configuration options. Save first if you made changes."),'<a href="/interfaces_ppps_edit.php?id='.$pconfig['pppid'].'" class="navlnk">','</a>') ?>
<?php if (!empty($a_ppps[$pppid])): ?>
<?= sprintf(gettext("%sClick here%s for additional PPTP and L2TP configuration options. Save first if you made changes."), url_safe('<a href="/interfaces_ppps_edit.php?id=%d">', $pppid), '</a>') ?>
<?php else: ?>
<?= sprintf(gettext('%sClick here%s for advanced PPTP and L2TP configuration options.'),'<a href="/interfaces_ppps_edit.php" class="navlnk">','</a>') ?>
<?= sprintf(gettext('%sClick here%s for advanced PPTP and L2TP configuration options.'),'<a href="/interfaces_ppps_edit.php">','</a>') ?>
<?php endif; ?>
</td>
</tr>

View File

@ -557,7 +557,7 @@ include("head.inc");
<?php
for ($intf_idx=0; $intf_idx <= count($portlist) ; ++$intf_idx):?>
<tr style="display:none" class="intf_select_<?=$intf_idx;?>">
<td style="width:22%"><a id="help_for_localip_<?=$intf_idx;?>" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Local IP");?> <span class="intf_select_txt_<?=$intf_idx;?>"> </span></td>
<td style="width:22%"><i class="fa fa-info-circle text-muted"></i> <?=gettext("Local IP");?> <span class="intf_select_txt_<?=$intf_idx;?>"> </span></td>
<td style="width:78%">
<input name="localip[]" type="text" class="intf_select_<?=$intf_idx;?>" value="<?=isset($pconfig['localip'][$intf_idx]) ? $pconfig['localip'][$intf_idx] : "";?>" />
/
@ -568,18 +568,12 @@ include("head.inc");
</option>
<?php endfor; ?>
</select>
<div class="hidden" data-for="help_for_localip_<?=$intf_idx;?>">
<?= gettext("IP Address"); ?>
</div>
</td>
</tr>
<tr style="display:none" class="intf_select_<?=$intf_idx;?>">
<td style="width:22%"><a id="help_for_gateway_<?=$intf_idx;?>" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Gateway");?> <span class="intf_select_txt_<?=$intf_idx;?>"> </span></td>
<td style="width:22%"><i class="fa fa-info-circle text-muted"></i> <?=gettext("Gateway");?> <span class="intf_select_txt_<?=$intf_idx;?>"> </span></td>
<td style="width:78%">
<input name="gateway[]" type="text" class="intf_select_<?=$intf_idx;?>" value="<?=isset($pconfig['gateway'][$intf_idx]) ? $pconfig['gateway'][$intf_idx] : "";?>" />
<div class="hidden" data-for="help_for_gateway_<?=$intf_idx;?>">
<?= gettext("IP Address"); ?>
</div>
</td>
</tr>
<?php