Commit 9c0d27fc authored by Franco Fichtner's avatar Franco Fichtner

src: remove L2TP, PPTP and PPPoE from base

Clean-cut move to individual plugins.  Ad finished his interface
plugin rework so now it's time.  :)
parent 64ba953f
<?php
/*
* Coypright (C) 2016 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2008 Shrew Soft Inc
* Copyright (C) 2008 Ermal Luçi
* Copyright (C) 2004 Scott Ullrich
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
function if_l2tp_configure()
{
return array('if_l2tp_configure_do');
}
function if_l2tp_services()
{
global $config;
$services = array();
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
$services[] = array(
'description' => gettext('L2TP Server'),
'pidfile' => '/var/run/l2tp-vpn.pid',
'php' => array(
'restart' => array('if_l2tp_configure_do'),
'start' => array('if_l2tp_configure_do'),
),
'name' => 'l2tpd',
);
}
return $services;
}
/**
* request syslog facilities for this plugin
* @return array
*/
function if_l2tp_syslog()
{
$logfacilities = array();
$logfacilities['l2tps'] = array('facility' => array('l2tps'), 'remote' => null);
return $logfacilities;
}
function if_l2tp_link_scripts($rootdir, $logtype = 'l2tp')
{
$up = <<<'EOD'
#!/bin/sh
/usr/bin/logger -p local3.info "login,%s,$4,$5"
EOD;
$down = <<<'EOD'
#!/bin/sh
/usr/bin/logger -p local3.info "logout,%s,$4,$5"
/sbin/pfctl -i $1 -Fs
/sbin/pfctl -K $4/32
EOD;
file_put_contents($rootdir . '/linkup', sprintf($up, $logtype));
file_put_contents($rootdir . '/linkdown', sprintf($down, $logtype));
chmod($rootdir . '/linkup', 0755);
chmod($rootdir . '/linkdown', 0755);
}
function if_l2tp_configure_do()
{
global $config;
killbypid('/var/run/l2tp-vpn.pid', 'TERM', true);
mwexec('rm -rf /var/etc/l2tp-vpn');
$syscfg = $config['system'];
if (isset($config['l2tp'])) {
$l2tpcfg = $config['l2tp'];
} else {
return 0;
}
if (!isset($l2tpcfg['mode']) || $l2tpcfg['mode'] != 'server') {
return 0;
}
if (file_exists('/var/run/booting')) {
echo gettext('Configuring L2TP VPN service...');
}
switch ($l2tpcfg['mode']) {
case 'server':
mkdir('/var/etc/l2tp-vpn');
if_l2tp_link_scripts('/var/etc/l2tp-vpn');
$fd = fopen("/var/etc/l2tp-vpn/mpd.conf", "w");
if (!$fd) {
printf(gettext("Error: cannot open mpd.conf in if_l2tp_configure().") . "\n");
return 1;
}
$iprange = $l2tpcfg['remoteip'] . ' ';
$iprange .= long2ip32(ip2long($l2tpcfg['remoteip']) + $l2tpcfg['n_l2tp_units'] - 1);
$iptype = "ippool pool1";
if (isset($l2tpcfg['radius']['enable']) && isset($l2tpcfg['radius']['radiusissueips'])) {
$iptype = "0.0.0.0/0";
}
$mpdconf = <<<EOD
startup:
l2tps:
set ippool add pool1 {$iprange}
create bundle template B
set iface disable on-demand
set iface enable proxy-arp
set iface up-script /var/etc/l2tp-vpn/linkup
set iface down-script /var/etc/l2tp-vpn/linkdown
set ipcp ranges {$l2tpcfg['localip']}/32 {$iptype}
set ipcp yes vjcomp
EOD;
if (is_ipaddr($l2tpcfg['wins'])) {
$mpdconf .= " set ipcp nbns {$l2tpcfg['wins']}\n";
}
if (is_ipaddr($l2tpcfg['dns1'])) {
$mpdconf .= " set ipcp dns " . $l2tpcfg['dns1'];
if (is_ipaddr($l2tpcfg['dns2'])) {
$mpdconf .= " " . $l2tpcfg['dns2'];
}
$mpdconf .= "\n";
} elseif (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if (isset($syscfg['dnsserver'][0])) {
$mpdconf .= " " . $syscfg['dnsserver'][0];
}
$mpdconf .= "\n";
} elseif (isset($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
if ($l2tpcfg['paporchap'] == "chap") {
$paporchap = "set link enable chap";
} else {
$paporchap = "set link enable pap";
}
$mpdconf .= <<<EOD
set bundle enable crypt-reqd
set bundle enable compression
set ccp yes mppc
create link template L l2tp
set link action bundle B
set link enable multilink
set link yes acfcomp protocomp
set link no pap chap eap
{$paporchap}
set link keep-alive 10 60
set link mtu 1460
set l2tp self ${l2tpcfg['localip']}
set link enable incoming
EOD;
if (!empty($l2tpcfg['secret'])) {
$mpdconf .= " set l2tp secret {$l2tpcfg['secret']}\n";
}
if (isset($l2tpcfg['radius']['enable'])) {
$mpdconf .=<<<EOD
set radius server {$l2tpcfg['radius']['server']} "{$l2tpcfg['radius']['secret']}"
set radius retries 3
set radius timeout 10
set auth enable radius-auth
EOD;
if (isset($l2tpcfg['radius']['accounting'])) {
$mpdconf .=<<<EOD
set auth enable radius-acct
EOD;
}
}
fwrite($fd, $mpdconf);
fclose($fd);
unset($mpdconf);
$fd = fopen("/var/etc/l2tp-vpn/mpd.secret", "w");
if (!$fd) {
printf(gettext("Error: cannot open mpd.secret in if_l2tp_configure().") . "\n");
return 1;
}
$mpdsecret = "\n\n";
if (is_array($l2tpcfg['user'])) {
foreach ($l2tpcfg['user'] as $user) {
$mpdsecret .= "{$user['name']} \"{$user['password']}\" {$user['ip']}\n";
}
}
fwrite($fd, $mpdsecret);
fclose($fd);
unset($mpdsecret);
chmod('/var/etc/l2tp-vpn/mpd.secret', 0600);
legacy_netgraph_attach(get_real_interface($l2tpcfg['interface']));
mwexec('/usr/local/sbin/mpd5 -b -d /var/etc/l2tp-vpn -p /var/run/l2tp-vpn.pid -s l2tps l2tps');
break;
}
if (file_exists('/var/run/booting')) {
echo gettext("done") . "\n";
}
return 0;
}
function l2tp_interfaces()
{
global $config;
$interfaces = array();
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] == 'server') {
$oic = array("enable" => true);
$oic['virtual'] = true;
$oic['networks'] = array();
$oic['if'] = 'l2tp';
$oic['descr'] = 'L2TP';
$mask = !empty($config['l2tp']['l2tp_subnet']) ? $config['l2tp']['l2tp_subnet'] : 32;
$oic['networks'][] = array("network" => gen_subnet($config['l2tp']['remoteip'], $mask), "mask" => $mask);
$interfaces['l2tp'] = $oic;
}
return $interfaces;
}
This diff is collapsed.
<?php
/*
* Coypright (C) 2016 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2008 Shrew Soft Inc
* Copyright (C) 2008 Ermal Luçi
* Copyright (C) 2004 Scott Ullrich
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
function if_pptp_configure()
{
return array('if_pptp_configure_do');
}
function if_pptp_services()
{
global $config;
$services = array();
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
$services[] = array(
'description' => gettext('PPTP Server'),
'pidfile' => '/var/run/pptp-vpn.pid',
'php' => array(
'restart' => array('if_pptp_configure_do'),
'start' => array('if_pptp_configure_do'),
),
'name' => 'pptpd',
);
}
return $services;
}
/**
* request syslog facilities for this plugin
* @return array
*/
function if_pptp_syslog()
{
$logfacilities = array();
$logfacilities['pptps'] = array('facility' => array('pptps'), 'remote' => null);
return $logfacilities;
}
function if_pptp_link_scripts($rootdir, $logtype = 'pptp')
{
$up = <<<'EOD'
#!/bin/sh
/usr/bin/logger -p local3.info "login,%s,$4,$5"
EOD;
$down = <<<'EOD'
#!/bin/sh
/usr/bin/logger -p local3.info "logout,%s,$4,$5"
/sbin/pfctl -i $1 -Fs
/sbin/pfctl -K $4/32
EOD;
file_put_contents($rootdir . '/linkup', sprintf($up, $logtype));
file_put_contents($rootdir . '/linkdown', sprintf($down, $logtype));
chmod($rootdir . '/linkup', 0755);
chmod($rootdir . '/linkdown', 0755);
}
function if_pptp_configure_do()
{
global $config;
$syscfg = $config['system'];
$pptpdcfg = $config['pptpd'];
killbypid('/var/run/pptp-vpn.pid', 'TERM', true);
mwexec('rm -rf /var/etc/pptp-vpn');
if (!isset($pptpdcfg['mode']) || $pptpdcfg['mode'] != 'server') {
return 0;
}
if (file_exists('/var/run/booting')) {
echo gettext("Configuring PPTP VPN service...");
}
switch ($pptpdcfg['mode']) {
case 'server':
mkdir('/var/etc/pptp-vpn');
if_pptp_link_scripts('/var/etc/pptp-vpn');
$fd = fopen('/var/etc/pptp-vpn/mpd.conf', 'w');
if (!$fd) {
printf(gettext("Error: cannot open mpd.conf in if_pptp_configure().") . "\n");
return 1;
}
$iprange = $pptpdcfg['remoteip'] . ' ';
$iprange .= long2ip32(ip2long($pptpdcfg['remoteip']) + $pptpdcfg['n_pptp_units'] - 1);
$mpdconf = <<<EOD
startup:
pptps:
set ippool add pool1 {$iprange}
create bundle template B
set iface disable on-demand
set iface enable proxy-arp
set iface enable tcpmssfix
set iface idle 1800
set iface up-script /var/etc/pptp-vpn/linkup
set iface down-script /var/etc/pptp-vpn/linkdown
set ipcp ranges {$pptpdcfg['localip']}/32 ippool pool1
set ipcp yes vjcomp
EOD;
if (isset($pptpdcfg["wins"]) && $pptpdcfg['wins'] != "") {
$mpdconf .= " set ipcp nbns {$pptpdcfg['wins']}\n";
}
if (!empty($pptpdcfg['dns1'])) {
$mpdconf .= " set ipcp dns " . $pptpdcfg['dns1'];
if (!empty($pptpdcfg['dns2'])) {
$mpdconf .= " " . $pptpdcfg['dns2'];
}
$mpdconf .= "\n";
} elseif (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable'])) {
$mpdconf .= " set ipcp dns " . get_interface_ip("lan");
if (isset($syscfg['dnsserver'][0])) {
$mpdconf .= " " . $syscfg['dnsserver'][0];
}
$mpdconf .= "\n";
} elseif (isset($syscfg['dnsserver'][0])) {
$mpdconf .= " set ipcp dns " . join(" ", $syscfg['dnsserver']) . "\n";
}
$mpdconf .= <<<EOD
set bundle enable crypt-reqd
set bundle enable compression
set ccp yes mppc
set mppc yes e128
set mppc yes stateless
EOD;
if (!isset($pptpdcfg['req128'])) {
$mpdconf .=<<<EOD
set mppc yes e40
set mppc yes e56
EOD;
}
$mpdconf .= <<<EOD
create link template L pptp
set link action bundle B
set link enable multilink
set link yes acfcomp protocomp
set link no pap chap eap
set link enable chap-msv2
set link mtu 1460
set link keep-alive 10 60
set pptp self {$pptpdcfg['localip']}
set link enable incoming
EOD;
if (isset($pptpdcfg['radius']['server']['enable'])) {
$authport = (isset($pptpdcfg['radius']['server']['port']) && strlen($pptpdcfg['radius']['server']['port']) > 1) ? $pptpdcfg['radius']['server']['port'] : 1812;
$acctport = $authport + 1;
$mpdconf .=<<<EOD
set radius server {$pptpdcfg['radius']['server']['ip']} "{$pptpdcfg['radius']['server']['secret']}" {$authport} {$acctport}
EOD;
if (isset($pptpdcfg['radius']['server2']['enable'])) {
$authport = (isset($pptpdcfg['radius']['server2']['port']) && strlen($pptpdcfg['radius']['server2']['port']) > 1) ? $pptpdcfg['radius']['server2']['port'] : 1812;
$acctport = $authport + 1;
$mpdconf .=<<<EOD
set radius server {$pptpdcfg['radius']['server2']['ip']} "{$pptpdcfg['radius']['server2']['secret2']}" {$authport} {$acctport}
EOD;
}
$mpdconf .=<<<EOD
set radius retries 3
set radius timeout 10
set auth enable radius-auth
EOD;
if (isset($pptpdcfg['radius']['accounting'])) {
$mpdconf .=<<<EOD
set auth enable radius-acct
set radius acct-update 300
EOD;
}
}
fwrite($fd, $mpdconf);
fclose($fd);
unset($mpdconf);
$fd = fopen('/var/etc/pptp-vpn/mpd.secret', 'w');
if (!$fd) {
printf(gettext("Error: cannot open mpd.secret in if_pptp_configure().") . "\n");
return 1;
}
$mpdsecret = "";
if (is_array($pptpdcfg['user'])) {
foreach ($pptpdcfg['user'] as $user) {
$pass = str_replace('\\', '\\\\', $user['password']);
$pass = str_replace('"', '\"', $pass);
$mpdsecret .= "{$user['name']} \"{$pass}\" {$user['ip']}\n";
}
}
fwrite($fd, $mpdsecret);
fclose($fd);
unset($mpdsecret);
chmod('/var/etc/pptp-vpn/mpd.secret', 0600);
/* fixed to WAN elsewhere, no need to extend, but at least make it work */
legacy_netgraph_attach(get_real_interface('wan'));
mwexec('/usr/local/sbin/mpd5 -b -d /var/etc/pptp-vpn -p /var/run/pptp-vpn.pid -s pptps pptps');
break;
}
if (file_exists('/var/run/booting')) {
echo gettext("done") . "\n";
}
return 0;
}
function if_pptp_interfaces()
{
global $config;
$interfaces = array();
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] == 'server') {
$oic = array("enable" => true);
$oic['networks'] = array();
$oic['virtual'] = true;
$oic['if'] = 'pptp';
$oic['descr'] = 'pptp';
$mask = !empty($config['pptpd']['pptp_subnet']) ? $config['pptpd']['pptp_subnet'] : 32;
if (isset($config['pptpd']['n_pptp_units']) && is_numeric($config['pptpd']['n_pptp_units'])) {
$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'],
long2ip32(ip2long($config['pptpd']['remoteip'])+($config['pptpd']['n_pptp_units']-1)));
} else {
$pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'],
long2ip32(ip2long($config['pptpd']['remoteip'])));
}
foreach ($pptp_subnets as $pptp_subnet) {
$snparts = explode("/", $pptp_subnet);
$oic['networks'][] = array("network" => $snparts[0], "mask" => $snparts[1]);
}
$interfaces['pptp'] = $oic;
}
return $interfaces;
}
<acl>
<!-- unique acl key, must be globally unique for all acl's -->
<page-diagnostics-logs-l2tp>
<name>WebCfg - Diagnostics: Logs: L2TP page</name>
<description>Allow access to the 'Diagnostics: Logs: L2TP' page.</description>
<patterns>
<pattern>diag_logs_l2tp.php*</pattern>
</patterns>
</page-diagnostics-logs-l2tp>
<page-vpn-vpnl2tp>
<name>WebCfg - VPN: L2TP page</name>
<description>Allow access to the 'VPN: L2TP' page.</description>
<patterns>
<pattern>vpn_l2tp.php*</pattern>
</patterns>
</page-vpn-vpnl2tp>
<page-vpn-vpnl2tp-users-edit>
<name>WebCfg - VPN: L2TP: Users : Edit page</name>
<description>Allow access to the 'VPN: L2TP: Users : Edit' page.</description>
<patterns>
<pattern>vpn_l2tp_users_edit.php*</pattern>
</patterns>
</page-vpn-vpnl2tp-users-edit>
<page-vpn-vpnl2tp-users>
<name>WebCfg - VPN: L2TP: Users page</name>
<description>Allow access to the 'VPN: L2TP : Users' page.</description>
<patterns>
<pattern>vpn_l2tp_users.php*</pattern>
</patterns>
</page-vpn-vpnl2tp-users>
</acl>
<menu>
<VPN>
<L2TP cssClass="fa fa-unlock fa-fw" order="100">
<Settings order="10" url="/vpn_l2tp.php"/>
<Users order="20" url="/vpn_l2tp_users.php">
<Edit url="/vpn_l2tp_users_edit.php*" visibility="hidden"/>
</Users>
<LogFile order="30" VisibleName="Log File" url="/diag_logs_l2tp.php">
<Type url="/diag_logs_l2tp.php*" visibility="hidden"/>
</LogFile>
</L2TP>
</VPN>
</menu>
<acl>
<!-- unique acl key, must be globally unique for all acl's -->
<page-diagnostics-logs-poes>
<name>WebCfg - Diagnostics: Logs: PPPoE page</name>
<description>Allow access to the 'Diagnostics: Logs: PPPoE' page.</description>
<patterns>
<pattern>diag_logs_poes.php*</pattern>
</patterns>
</page-diagnostics-logs-poes>
<page-services-pppoeserver>
<name>WebCfg - Services: PPPoE Server page</name>
<description>Allow access to the 'Services: PPPoE Server' page.</description>
<patterns>
<pattern>vpn_pppoe.php*</pattern>
</patterns>
</page-services-pppoeserver>
<page-services-pppoeserver-edit>
<name>WebCfg - Services: PPPoE Server: Edit page</name>
<description>Allow access to the 'Services: PPPoE Server: Edit' page.</description>
<patterns>
<pattern>vpn_pppoe_edit.php*</pattern>
</patterns>
</page-services-pppoeserver-edit>
</acl>
<menu>
<VPN>
<PPPoE cssClass="fa fa-tty fa-fw" order="110">
<Settings order="10" url="/vpn_pppoe.php">
<Edit url="/vpn_pppoe_edit.php*" visibility="hidden"/>
</Settings>
<LogFile order="20" VisibleName="Log File" url="/diag_logs_poes.php">
<Type url="/diag_logs_poes.php*" visibility="hidden"/>
</LogFile>
</PPPoE>
</VPN>
</menu>
<acl>
<!-- unique acl key, must be globally unique for all acl's -->
<page-diagnostics-logs-pptp>
<name>WebCfg - Diagnostics: Logs: PPTP page</name>
<description>Allow access to the 'Diagnostics: Logs: PPTP' page.</description>
<patterns>
<pattern>diag_logs_pptp.php*</pattern>
</patterns>
</page-diagnostics-logs-pptp>
<page-vpn-vpnpptp>
<name>WebCfg - VPN: PPTP page</name>
<description>Allow access to the 'VPN: PPTP' page.</description>
<patterns>
<pattern>vpn_pptp.php*</pattern>
</patterns>
</page-vpn-vpnpptp>
<page-vpn-vpnpptp-user-edit>
<name>WebCfg - VPN: PPTP: User: Edit page</name>
<description>Allow access to the 'VPN: PPTP: User: Edit' page.</description>
<patterns>
<pattern>vpn_pptp_users_edit.php*</pattern>
</patterns>
</page-vpn-vpnpptp-user-edit>
<page-vpn-vpnpptp-users>
<name>WebCfg - VPN: PPTP: Users page</name>
<description>Allow access to the 'VPN: PPTP: Users' page.</description>
<patterns>
<pattern>vpn_pptp_users.php*</pattern>
</patterns>
</page-vpn-vpnpptp-users>
</acl>
<menu>
<VPN>
<PPTP cssClass="fa fa-unlock fa-fw" order="120">
<Settings order="10" url="/vpn_pptp.php"/>
<Users order="20" url="/vpn_pptp_users.php">
<Edit url="/vpn_pptp_users_edit.php*" visibility="hidden"/>
</Users>
<LogFile order="30" VisibleName="Log File" url="/diag_logs_pptp.php">
<Type url="/diag_logs_pptp.php*" visibility="hidden"/>
</LogFile>
</PPTP>
</VPN>
</menu>
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("system.inc");
require_once('services.inc');
require_once('plugins.inc');
require_once("interfaces.inc");
if (empty($config['syslog']['nentries'])) {
$nentries = 50;
} else {
$nentries = $config['syslog']['nentries'];
}
if ($_POST['clear']) {
clear_clog($logfile);
}
function dump_clog_vpn($file, $tail, $type)
{
global $config;
$sort = isset($config['syslog']['reverse']) ? '-r' : '';
$logarr = array();
exec("/usr/local/sbin/clog " . escapeshellarg($file) . " | tail {$sort} -n " . escapeshellarg($tail), $logarr);
foreach ($logarr as $logent) {
$logent = preg_split('/\s+/', $logent, 6);
$llent = explode(',', $logent[5]);
if ($llent[1] !== $type) {
continue;
}
echo "<tr>\n";
echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
if ($llent[0] == "login") {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-right\" aria-hidden=\"true\" alt=\"in\"></span></td>\n";
} else {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\" alt=\"out\"></span></td>\n";
}
echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
echo "</tr>\n";
}
}
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped table-sort">
<tr>
<td colspan="4">
<ul class="nav nav-pills" role="tablist">
<?php foreach ($tab_array as $tab): ?>
<li role="presentation" <?php if (str_replace('amp;','', $tab[2]) == $_SERVER['REQUEST_URI']):?>class="active"<?php endif; ?>><a href="<?=$tab[2];?>"><?=$tab[0];?></a></li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php if ($mode != "raw"): ?>
<tr>
<td class="listhdrr"><?=gettext("Time");?></td>
<td class="listhdrr"><?=gettext("Action");?></td>
<td class="listhdrr"><?=gettext("User");?></td>
<td class="listhdrr"><?=gettext("IP address");?></td>
</tr>
<?php dump_clog_vpn($logfile, $nentries, $logtype); ?>
<?php else:
dump_clog($logfile, $nentries);
endif; ?>
<tr>
<td colspan="4">
<form method="post">
<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
</form>
</td>
</tr>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
if (htmlspecialchars($_POST['mode'])) {
$mode = htmlspecialchars($_POST['mode']);
} elseif (htmlspecialchars($_GET['mode'])) {
$mode = htmlspecialchars($_GET['mode']);
} else {
$mode = "login";
}
if ($mode != 'raw') {
$logfile = '/var/log/vpn.log';
} else {
$logfile = '/var/log/l2tps.log';
}
$logtype = 'l2tp';
$tab_array = array();
$tab_array[] = array(gettext("L2TP Logins"), $mode != "raw", "/diag_logs_l2tp.php");
$tab_array[] = array(gettext("L2TP Raw"), $mode == "raw", "/diag_logs_l2tp.php?mode=raw");
$service_hook = 'l2tpd';
require_once 'diag_logs_l2tp.inc';
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("system.inc");
require_once('services.inc');
require_once('plugins.inc');
require_once("interfaces.inc");
if (empty($config['syslog']['nentries'])) {
$nentries = 50;
} else {
$nentries = $config['syslog']['nentries'];
}
if ($_POST['clear']) {
clear_clog($logfile);
}
function dump_clog_vpn($file, $tail, $type)
{
global $config;
$sort = isset($config['syslog']['reverse']) ? '-r' : '';
$logarr = array();
exec("/usr/local/sbin/clog " . escapeshellarg($file) . " | tail {$sort} -n " . escapeshellarg($tail), $logarr);
foreach ($logarr as $logent) {
$logent = preg_split('/\s+/', $logent, 6);
$llent = explode(',', $logent[5]);
if ($llent[1] !== $type) {
continue;
}
echo "<tr>\n";
echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
if ($llent[0] == "login") {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-right\" aria-hidden=\"true\" alt=\"in\"></span></td>\n";
} else {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\" alt=\"out\"></span></td>\n";
}
echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
echo "</tr>\n";
}
}
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped table-sort">
<tr>
<td colspan="4">
<ul class="nav nav-pills" role="tablist">
<?php foreach ($tab_array as $tab): ?>
<li role="presentation" <?php if (str_replace('amp;','', $tab[2]) == $_SERVER['REQUEST_URI']):?>class="active"<?php endif; ?>><a href="<?=$tab[2];?>"><?=$tab[0];?></a></li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php if ($mode != "raw"): ?>
<tr>
<td class="listhdrr"><?=gettext("Time");?></td>
<td class="listhdrr"><?=gettext("Action");?></td>
<td class="listhdrr"><?=gettext("User");?></td>
<td class="listhdrr"><?=gettext("IP address");?></td>
</tr>
<?php dump_clog_vpn($logfile, $nentries, $logtype); ?>
<?php else:
dump_clog($logfile, $nentries);
endif; ?>
<tr>
<td colspan="4">
<form method="post">
<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
</form>
</td>
</tr>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
if (htmlspecialchars($_POST['mode'])) {
$mode = htmlspecialchars($_POST['mode']);
} elseif (htmlspecialchars($_GET['mode'])) {
$mode = htmlspecialchars($_GET['mode']);
} else {
$mode = "login";
}
if ($mode != 'raw') {
$logfile = '/var/log/vpn.log';
} else {
$logfile = '/var/log/poes.log';
}
$logtype = 'poes';
$tab_array = array();
$tab_array[] = array(gettext("PPPoE Logins"), $mode != "raw", "/diag_logs_poes.php");
$tab_array[] = array(gettext("PPPoE Raw"), $mode == "raw", "/diag_logs_poes.php?mode=raw");
require_once 'diag_logs_poes.inc';
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("system.inc");
require_once('services.inc');
require_once('plugins.inc');
require_once("interfaces.inc");
if (empty($config['syslog']['nentries'])) {
$nentries = 50;
} else {
$nentries = $config['syslog']['nentries'];
}
if ($_POST['clear']) {
clear_clog($logfile);
}
function dump_clog_vpn($file, $tail, $type)
{
global $config;
$sort = isset($config['syslog']['reverse']) ? '-r' : '';
$logarr = array();
exec("/usr/local/sbin/clog " . escapeshellarg($file) . " | tail {$sort} -n " . escapeshellarg($tail), $logarr);
foreach ($logarr as $logent) {
$logent = preg_split('/\s+/', $logent, 6);
$llent = explode(',', $logent[5]);
if ($llent[1] !== $type) {
continue;
}
echo "<tr>\n";
echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
if ($llent[0] == "login") {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-right\" aria-hidden=\"true\" alt=\"in\"></span></td>\n";
} else {
echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\" alt=\"out\"></span></td>\n";
}
echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
echo "</tr>\n";
}
}
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped table-sort">
<tr>
<td colspan="4">
<ul class="nav nav-pills" role="tablist">
<?php foreach ($tab_array as $tab): ?>
<li role="presentation" <?php if (str_replace('amp;','', $tab[2]) == $_SERVER['REQUEST_URI']):?>class="active"<?php endif; ?>><a href="<?=$tab[2];?>"><?=$tab[0];?></a></li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php if ($mode != "raw"): ?>
<tr>
<td class="listhdrr"><?=gettext("Time");?></td>
<td class="listhdrr"><?=gettext("Action");?></td>
<td class="listhdrr"><?=gettext("User");?></td>
<td class="listhdrr"><?=gettext("IP address");?></td>
</tr>
<?php dump_clog_vpn($logfile, $nentries, $logtype); ?>
<?php else:
dump_clog($logfile, $nentries);
endif; ?>
<tr>
<td colspan="4">
<form method="post">
<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
</form>
</td>
</tr>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
if (htmlspecialchars($_POST['mode'])) {
$mode = htmlspecialchars($_POST['mode']);
} elseif (htmlspecialchars($_GET['mode'])) {
$mode = htmlspecialchars($_GET['mode']);
} else {
$mode = "login";
}
if ($mode != 'raw') {
$logfile = '/var/log/vpn.log';
} else {
$logfile = '/var/log/pptps.log';
}
$logtype = 'pptp';
$tab_array = array();
$tab_array[] = array(gettext("PPTP Logins"), $mode != "raw", "/diag_logs_pptp.php");
$tab_array[] = array(gettext("PPTP Raw"), $mode == "raw", "/diag_logs_pptp.php?mode=raw");
$service_hook = 'pptpd';
require_once 'diag_logs_pptp.inc';
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2005 Scott Ullrich (sullrich@gmail.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("services.inc");
require_once("system.inc");
require_once("plugins.inc");
require_once("plugins.inc.d/vpn.inc");
if (!isset($config['l2tp']['user'])) {
$config['l2tp']['user'] = array();
}
$a_secret = &$config['l2tp']['user'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// delete entry
if (isset($_POST['act']) && $_POST['act'] == "del" && isset($_POST['id'])) {
if (!empty($a_secret[$_POST['id']])) {
unset($a_secret[$_POST['id']]);
write_config();
}
exit;
} elseif (!empty($_POST['apply'])) {
vpn_l2tp_configure();
clear_subsystem_dirty('l2tpusers');
header("Location: vpn_l2tp_users.php");
exit;
}
}
$service_hook = 'l2tpd';
include("head.inc");
$main_buttons = array(
array('label'=>gettext("add user"), 'href'=>'vpn_l2tp_users_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete host action
$(".act_delete_user").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?=gettext("delete user"); ?>",
message: "<?=gettext("Do you really want to delete this user?");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
location.reload();
});
}
}]
});
});
});
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php
if (isset($savemsg)) {
print_info_box($savemsg);
}
if (isset($config['l2tp']['radius']['enable'])) {
print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used."));
}
if (is_subsystem_dirty('l2tpusers')) :?><br/>
<?php print_info_box_apply(gettext("The l2tp user list has been modified") . ".<br />" . gettext("You must apply the changes in order for them to take effect") . ".<br /><b>" . gettext("Warning: this will terminate all current l2tp sessions!") . "</b>");?>
<?php
endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped">
<tr>
<td><?=gettext("Username");?></td>
<td><?=gettext("IP address");?></td>
<td></td>
</tr>
<?php
$i = 0;
foreach ($a_secret as $secretent) :?>
<tr>
<td><?=htmlspecialchars($secretent['name']);?></td>
<td>
<?php
if ($secretent['ip'] == "") {
$secretent['ip'] = "Dynamic";
} ?>
<?=htmlspecialchars($secretent['ip']);?>&nbsp;
</td>
<td>
<a href="vpn_l2tp_users_edit.php?id=<?=$i;?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-edit"></span></a>
<button data-id="<?=$i;?>" type="button" class="act_delete_user btn btn-xs btn-default"><span class="fa fa-trash text-muted"></span></button>
</td>
</tr>
<?php
$i++;
endforeach; ?>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc");
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2006 Scott Ullrich (sullrich@gmail.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function l2tpusercmp($a, $b)
{
return strcasecmp($a['name'], $b['name']);
}
function l2tp_users_sort()
{
global $config;
if (!is_array($config['l2tp']['user'])) {
return;
}
usort($config['l2tp']['user'], "l2tpusercmp");
}
require_once("guiconfig.inc");
require_once("services.inc");
require_once("system.inc");
require_once("plugins.inc");
require_once("plugins.inc.d/vpn.inc");
if (empty($config['l2tp']['user']) || !is_array($config['l2tp']['user'])) {
$config['l2tp']['user'] = array();
}
$a_secret = &$config['l2tp']['user'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['id']) && !empty($a_secret[$_GET['id']])) {
$id = $_GET['id'];
}
if (isset($id)) {
$pconfig['usernamefld'] = $a_secret[$id]['name'];
$pconfig['ip'] = $a_secret[$id]['ip'];
} else {
$pconfig['usernamefld'] = null;
$pconfig['ip'] = null;
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['id']) && !empty($a_secret[$_POST['id']])) {
$id = $_POST['id'];
}
unset($input_errors);
$pconfig = $_POST;
/* input validation */
if (isset($id) && ($a_secret[$id])) {
$reqdfields = explode(" ", "usernamefld");
$reqdfieldsn = array(gettext("Username"));
} else {
$reqdfields = explode(" ", "usernamefld passwordfld");
$reqdfieldsn = array(gettext("Username"),gettext("Password"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['usernamefld'])) {
$input_errors[] = gettext("The username contains invalid characters.");
}
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['passwordfld'])) {
$input_errors[] = gettext("The password contains invalid characters.");
}
if (($_POST['passwordfld']) && ($_POST['passwordfld'] != $_POST['password2'])) {
$input_errors[] = gettext("The passwords do not match.");
}
if (($_POST['ip'] && !is_ipaddr($_POST['ip']))) {
$input_errors[] = gettext("The IP address entered is not valid.");
}
if (!$input_errors && !(isset($id) && $a_secret[$id])) {
/* make sure there are no dupes */
foreach ($a_secret as $secretent) {
if ($secretent['name'] == $_POST['usernamefld']) {
$input_errors[] = gettext("Another entry with the same username already exists.");
break;
}
}
}
if (!$input_errors) {
if (isset($id) && $a_secret[$id]) {
$secretent = $a_secret[$id];
}
$secretent['name'] = $_POST['usernamefld'];
$secretent['ip'] = $_POST['ip'];
if ($_POST['passwordfld']) {
$secretent['password'] = $_POST['passwordfld'];
}
if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
} else {
$a_secret[] = $secretent;
}
l2tp_users_sort();
write_config();
vpn_l2tp_configure();
header("Location: vpn_l2tp_users.php");
exit;
}
}
$service_hook = 'l2tpd';
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php
if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors);
} ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped opnsense_standard_table_form">
<tr>
<td width="22%">
<strong><?=gettext("Edit User");?></strong>
</td>
<td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page"></i>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Username");?></td>
<td>
<input name="usernamefld" type="text" value="<?=$pconfig['usernamefld'];?>" />
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Password");?></td>
<td>
<input name="passwordfld" type="password" /><br />
<input name="password2" type="password" />
&nbsp;(<?=gettext("confirmation");?>)
<?php if (isset($id)):?><br />
<div class="text-muted"><em><small><?=gettext("If you want to change the users password, enter it here twice.");?></small></em></div>
<?php endif; ?>
</td>
</tr>
<tr>
<td><a id="help_for_ip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IP address");?></td>
<td>
<input name="ip" type="text" value="<?=$pconfig['ip'];?>" />
<div class="hidden" for="help_for_ip">
<?=gettext("If you want the user to be assigned a specific IP address, enter it here.");?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input id="submit" name="Submit" type="submit" class="btn btn-primary" value="<?=gettext('Save');?>" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/vpn_l2tp_users.php');?>'" />
<?php if (isset($id)) :?>
<input name="id" type="hidden" value="<?=$id;?>" />
<?php endif; ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc");
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2010 Ermal Luci
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("plugins.inc.d/vpn.inc");
require_once("interfaces.inc");
if (empty($config['pppoes']['pppoe']) || !is_array($config['pppoes']['pppoe'])) {
$config['pppoes'] = array();
$config['pppoes']['pppoe'] = array();
}
$a_pppoes = &$config['pppoes']['pppoe'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['apply'])) {
if (file_exists('/tmp/.vpn_pppoe.apply')) {
$toapplylist = unserialize(file_get_contents('/tmp/.vpn_pppoe.apply'));
foreach ($toapplylist as $pppoeid) {
if (!is_numeric($pppoeid)) {
continue;
}
if (isset($config['pppoes']['pppoe'])) {
foreach ($config['pppoes']['pppoe'] as $pppoe) {
if ($pppoe['pppoeid'] == $pppoeid) {
vpn_pppoe_configure($pppoe);
break;
}
}
}
}
@unlink('/tmp/.vpn_pppoe.apply');
}
filter_configure();
clear_subsystem_dirty('vpnpppoe');
header("Location: vpn_pppoe.php");
exit;
} elseif (!empty($_POST['act']) && $_POST['act'] == "del") {
if (!empty($a_pppoes[$_POST['id']])) {
killbypid("/var/run/pppoe{$a_pppoes[$_POST['id']]['pppoeid']}-vpn.pid");
mwexecf('/bin/rm -r %s', "/var/etc/pppoe{$a_pppoes[$_POST['id']]['pppoeid']}");
unset($a_pppoes[$_POST['id']]);
write_config();
exit;
}
}
}
include("head.inc");
legacy_html_escape_form_data($a_pppoes);
$main_buttons = array(
array('label'=>gettext("add a new pppoe instance"), 'href'=>'vpn_pppoe_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete pppoe action
$(".act_delete_pppoe").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("PPPoE");?>",
message: "<?=gettext("Do you really want to delete this entry? All elements that still use it will become invalid (e.g. filter rules)!");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
location.reload();
});
}
}]
});
});
});
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('vpnpppoe')) : ?><br/>
<?php print_info_box_apply(gettext("The PPPoE entry list has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?>
<?php endif; ?>
<section class="col-xs-12">
<div class="content-box">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped">
<tr>
<td><?=gettext("Interface");?></td>
<td><?=gettext("Local IP");?></td>
<td><?=gettext("Number of users");?></td>
<td><?=gettext("Description");?></td>
<td>
</td>
</tr>
<?php
$i = 0;
foreach ($a_pppoes as $pppoe) :?>
<tr>
<td><?=strtoupper($pppoe['interface']);?></td>
<td><?=$pppoe['localip'];?></td>
<td><?=$pppoe['n_pppoe_units'];?></td>
<td><?=$pppoe['descr'];?></td>
<td>
<a href="vpn_pppoe_edit.php?id=<?=$i;?>" title="<?=gettext("edit pppoe instance"); ?>" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<button data-id="<?=$i;?>" type="button" class="act_delete_pppoe btn btn-xs btn-default"><span class="fa fa-trash text-muted"></span></button>
</td>
</tr>
<?php
$i++;
endforeach; ?>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc");
This diff is collapsed.
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once('guiconfig.inc');
require_once('services.inc');
require_once("system.inc");
require_once("plugins.inc");
require_once('plugins.inc.d/vpn.inc');
if (!is_array($config['pptpd']['user'])) {
$config['pptpd']['user'] = array();
}
$a_secret = &$config['pptpd']['user'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// delete entry
if (isset($_POST['act']) && $_POST['act'] == "del" && isset($_POST['id'])) {
if (!empty($a_secret[$_POST['id']])) {
unset($a_secret[$_POST['id']]);
mark_subsystem_dirty('pptpusers');
write_config();
}
exit;
} elseif (!empty($_POST['apply'])) {
vpn_pptpd_configure();
clear_subsystem_dirty('pptpusers');
header("Location: vpn_pptp_users.php");
exit;
}
}
$service_hook = 'pptpd';
include("head.inc");
$main_buttons = array(
array('label'=>gettext("add user"), 'href'=>'vpn_pptp_users_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete host action
$(".act_delete_user").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?=gettext("delete user"); ?>",
message: "<?=gettext("Do you really want to delete this user?");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
location.reload();
});
}
}]
});
});
});
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php
if (isset($config['pptpd']['radius']['enable'])) {
print_info_box(gettext("Warning: RADIUS is enabled. The local user database will not be used."));
}
if (is_subsystem_dirty('pptpusers')) :?><br/>
<?php print_info_box_apply(gettext("The PPTP user list has been modified").".<br />".gettext("You must apply the changes in order for them to take effect").".<br /></b><b>".gettext("Warning: this will terminate all current PPTP sessions")."!");?></b><br />
<?php
endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped table-sort">
<tr>
<td><?=gettext("Username");?></td>
<td><?=gettext("IP address");?></td>
<td></td>
</tr>
<?php
$i = 0;
foreach ($a_secret as $secretent) :?>
<tr>
<td><?=htmlspecialchars($secretent['name']);?></td>
<td><?=htmlspecialchars($secretent['ip']);?></td>
<td>
<a href="vpn_pptp_users_edit.php?id=<?=$i;?>" class="btn btn-xs btn-default"><span class="glyphicon glyphicon-edit"></span></a>
<button data-id="<?=$i;?>" type="button" class="act_delete_user btn btn-xs btn-default"><span class="fa fa-trash text-muted"></span></button>
</td>
</tr>
<?php
$i++;
endforeach; ?>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc");
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
function pptpusercmp($a, $b)
{
return strcasecmp($a['name'], $b['name']);
}
function pptpd_users_sort()
{
global $config;
if (!is_array($config['ppptpd']['user'])) {
return;
}
usort($config['pptpd']['user'], "pptpusercmp");
}
require_once('guiconfig.inc');
require_once('services.inc');
require_once("system.inc");
require_once("plugins.inc");
require_once('plugins.inc.d/vpn.inc');
if (!is_array($config['pptpd']['user'])) {
$config['pptpd']['user'] = array();
}
$a_secret = &$config['pptpd']['user'];
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($_GET['id']) && !empty($a_secret[$_GET['id']])) {
$id = $_GET['id'];
}
if (isset($id)) {
$pconfig['username'] = $a_secret[$id]['name'];
$pconfig['ip'] = $a_secret[$id]['ip'];
} else {
$pconfig['username'] = null;
$pconfig['ip'] = null;
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['id']) && !empty($a_secret[$_POST['id']])) {
$id = $_POST['id'];
}
unset($input_errors);
$pconfig = $_POST;
/* input validation */
if (isset($id) && ($a_secret[$id])) {
$reqdfields = explode(" ", "username");
$reqdfieldsn = array(gettext("Username"));
} else {
$reqdfields = explode(" ", "username password");
$reqdfieldsn = array(gettext("Username"),gettext("Password"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['username'])) {
$input_errors[] = gettext("The username contains invalid characters.");
}
if (preg_match("/^!/", $_POST['password'])) {
$input_errors[] = gettext("The password cannot start with '!'.");
}
if (!preg_match("/^[\x20-\x7E]*$/", $_POST['password'])) {
$input_errors[] = gettext("The password contains invalid characters.");
}
if (($_POST['password']) && ($_POST['password'] != $_POST['password2'])) {
$input_errors[] = gettext("The passwords do not match.");
}
if (($_POST['ip'] && !is_ipaddr($_POST['ip']))) {
$input_errors[] = gettext("The IP address entered is not valid.");
}
if (!$input_errors && !(isset($id) && $a_secret[$id])) {
/* make sure there are no dupes */
foreach ($a_secret as $secretent) {
if ($secretent['name'] == $_POST['username']) {
$input_errors[] = gettext("Another entry with the same username already exists.");
break;
}
}
}
if (!$input_errors) {
if (isset($id) && $a_secret[$id]) {
$secretent = $a_secret[$id];
}
$secretent['name'] = $_POST['username'];
$secretent['ip'] = $_POST['ip'];
if ($_POST['password']) {
$secretent['password'] = $_POST['password'];
}
if (isset($id) && $a_secret[$id]) {
$a_secret[$id] = $secretent;
} else {
$a_secret[] = $secretent;
}
pptpd_users_sort();
write_config();
vpn_pptpd_configure();
header("Location: vpn_pptp_users.php");
exit;
}
}
$service_hook = 'pptpd';
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors);
} ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped opnsense_standard_table_form">
<tr>
<td width="22%">
<strong><?=gettext("Edit User");?></strong>
</td>
<td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page"></i>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Username");?></td>
<td>
<input name="username" type="text" id="username" value="<?=$pconfig['username'];?>" />
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Password");?></td>
<td>
<input name="password" type="password" class="form-control pwd" id="password" />
<br /><input name="password2" type="password" class="form-control pwd" id="password2" />
&nbsp;(<?=gettext("confirmation");?>)
<?php
if (isset($id)) :?><br />
<?=gettext("If you want to change the users' password, ".
"enter it here twice.");?>
<?php
endif; ?>
</td>
</tr>
<tr>
<td><a id="help_for_ip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("IP address");?></td>
<td>
<input name="ip" type="text" class="form-control unknown" id="ip" value="<?=htmlspecialchars($pconfig['ip']);?>" />
<div class="hidden" for="help_for_ip">
<?=gettext("If you want the user to be assigned a specific IP address, enter it here.");?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
<?php
if (isset($id)) :?>
<input name="id" type="hidden" value="<?=$id;?>" />
<?php
endif; ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc");
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