initial commit of file from CVS for e-smith-pptpd on Wed 12 Jul 09:04:53 BST 2023

This commit is contained in:
Brian Read
2023-07-12 09:04:53 +01:00
parent 84706b10f8
commit d6305d2c67
66 changed files with 1924 additions and 2 deletions

View File

@@ -0,0 +1 @@
1723

View File

@@ -0,0 +1 @@
public

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@
disabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1,4 @@
{
# We don't need $pptpd{StartIP} any more
$DB->get_prop_and_delete('pptpd', 'StartIP');
}

View File

@@ -0,0 +1,3 @@
#! /bin/sh
exec /sbin/e-smith/config delprop pptpd Interfaces

View File

@@ -0,0 +1,63 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2002 Mitel Networks Corporaton.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Technical support for this program is available from e-smith, inc.
# For details, please visit our web site at www.e-smith.com or
# call us on 1 888 ESMITH 1 (US/Canada toll free) or +1 613 564 8000
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use esmith::util;
use esmith::ConfigDB;
use constant SIGEVENT => '/sbin/e-smith/signal-event';
my $db = esmith::ConfigDB->open;
my $pptpd = $db->get('pptpd');
my %ifaces = map { $_ => 1 } split /,/, $pptpd->prop('Interfaces') || '';
my $event = $ARGV[0] || die "Event name must be given\n";
my $ipparam = $ARGV[6] || "(none)";
exit 0 unless ($ipparam eq "pptpd");
my $interface = $ARGV[1] || die "Couldn't determine interface name\n";
if ($event eq "ip-down")
{
# Remove this interface.
if (exists $ifaces{$interface})
{
delete $ifaces{$interface};
}
}
elsif ($event eq "ip-up.pptpd")
{
# Add this interface.
$ifaces{$interface} = 1;
}
else
{
die "Don't know what to do for event $event\n";
}
$pptpd->set_prop('Interfaces', join ',', keys %ifaces);
exit(0);

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -0,0 +1,3 @@
PERMS=0644
UID="root"
GID="root"

View File

@@ -0,0 +1,3 @@
PERMS=0644
UID="root"
GID="root"

View File

@@ -0,0 +1,21 @@
{
my $pptpd_status = $pptpd{status} || 'disabled';
my $pptpd_sessions = $pptpd{sessions} || 0;
# Do nothing unless we have to
return "" unless ($pptpd_status eq 'enabled' && $pptpd_sessions);
# Calculate pptpd start and end addresses
$pptpd_end_addr = esmith::util::IPquadToAddr($endDynamicIPRange);
$pptpd_start_addr = $pptpd_end_addr - $pptpd_sessions + 1;
# and correct the DHCP dynamic address range
$endDynamicIPRange = esmith::util::IPaddrToQuad($pptpd_end_addr - $pptpd_sessions);
return "# Addresses from " .
esmith::util::IPaddrToQuad($pptpd_start_addr) .
" to " .
esmith::util::IPaddrToQuad($pptpd_start_addr + $pptpd_sessions - 1) .
" taken for PPTP sessions";
}

View File

@@ -0,0 +1,6 @@
{
my $status = $pptpd{status} || 'disabled';
$sessions = $pptpd{sessions} || 0;
$status = 'disabled' unless $sessions > 0;
$OUT = $status eq 'enabled' ? "pptpd: ALL" : "# pptpd is disabled";
}

View File

@@ -0,0 +1,3 @@
pptpd)
/sbin/e-smith/signal-event ip-up.pptpd "$@"
;;

View File

@@ -0,0 +1 @@
auth

View File

@@ -0,0 +1,4 @@
{
my $debug = $pptpd{debug} || 'no';
$OUT = $debug eq 'yes' ? "debug" : "# debug is not enabled";
}

View File

@@ -0,0 +1 @@
domain { "$DomainName" }

View File

@@ -0,0 +1,2 @@
# Tell ip-up and ip-down who is running them
ipparam pptpd

View File

@@ -0,0 +1,2 @@
lcp-echo-interval 15
lcp-echo-failure 10

View File

@@ -0,0 +1 @@
lock

View File

@@ -0,0 +1,5 @@
nodeflate
nobsdcomp
require-mppe-128
nomppe-40
nomppe-stateful # refuse stateful mode, i.e. use stateless

View File

@@ -0,0 +1 @@
{ $pptpd{mru} ? "mru $pptpd{mru}" : "# mru not set" }

View File

@@ -0,0 +1 @@
ms-dns { "$LocalIP" }

View File

@@ -0,0 +1,8 @@
{
# Grab our local WINS server setting, unless another fragment
# has already set it
$_WINSServer ||= $DB->wins_server;
$OUT .= defined $_WINSServer ?
"ms-wins $_WINSServer" :
"# Network has no WINS server set";
}

View File

@@ -0,0 +1 @@
{ $pptpd{mtu} ? "mtu $pptpd{mtu}" : "# mtu not set" }

View File

@@ -0,0 +1 @@
name { "$SystemName" }

View File

@@ -0,0 +1 @@
netmask { "$LocalNetmask" }

View File

@@ -0,0 +1 @@
nologfd

View File

@@ -0,0 +1,4 @@
{
my $passive = $pptpd{Passive} || 'enabled';
$OUT = ($passive eq 'enabled') ? "passive" : "# passive mode is disabled in db";
}

View File

@@ -0,0 +1 @@
proxyarp

View File

@@ -0,0 +1 @@
plugin radius.so

View File

@@ -0,0 +1,4 @@
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2 # Need MSCHAP-v2 to initialise encryption key

View File

@@ -0,0 +1,4 @@
{
my $debug = $pptpd{debug} || 'no';
$OUT = $debug eq 'yes' ? "debug" : "# debug is not enabled";
}

View File

@@ -0,0 +1,27 @@
{
# TAG: localip
#
# Specifies the local and remote IP address ranges.
#
# You can specify single IP addresses seperated by commas or you can
# specify ranges, or both. For example:
#
# 192.168.0.234,192.168.0.245-249,192.168.0.254
#
# IMPORTANT RESTRICTIONS:
#
# 1. No spaces are permitted between commas or within addresses.
#
# 2. If you give more IP addresses than MAX_CONNECTIONS, it will
# start at the beginning of the list and go until it gets
# MAX_CONNECTIONS IPs. Others will be ignored.
#
# 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,
# you must type 234-238 if you mean this.
#
# 4. If you give a single localIP, that's ok - all local IPs will
# be set to the given one. You MUST still give at least one remote
# IP for each simultaneous client.
#
}
localip { $LocalIP }

View File

@@ -0,0 +1,7 @@
{
# TAG: noipparam
# Suppress the passing of the client's IP address to PPP, which is
# done by default otherwise.
#
}
noipparam

View File

@@ -0,0 +1,8 @@
{
# TAG: option
#
# Specifies the location of the PPP options file.
# By default PPP looks in '/etc/ppp/options'
#
}
option /etc/ppp/options.pptpd

View File

@@ -0,0 +1,8 @@
{
# TAG: pidfile
#
# This defines the file name in which pptpd should store its process
# ID (or pid). The default is /var/run/pptpd.pid.
#
}
pidfile /var/run/pptpd.pid

View File

@@ -0,0 +1,61 @@
{
# TAG: remoteip
#
# Specifies the local and remote IP address ranges.
#
# You can specify single IP addresses seperated by commas or you can
# specify ranges, or both. For example:
#
# 192.168.0.234,192.168.0.245-249,192.168.0.254
#
# IMPORTANT RESTRICTIONS:
#
# 1. No spaces are permitted between commas or within addresses.
#
# 2. If you give more IP addresses than MAX_CONNECTIONS, it will
# start at the beginning of the list and go until it gets
# MAX_CONNECTIONS IPs. Others will be ignored.
#
# 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,
# you must type 234-238 if you mean this.
#
# 4. If you give a single localIP, that's ok - all local IPs will
# be set to the given one. You MUST still give at least one remote
# IP for each simultaneous client.
#
return "# pptpd disabled - no remoteip"
unless ($pptpd{status} eq 'enabled');
# PPTPD can't do ranges in the form 192.168.42.200-192.168.42.210
# (Grrrr!!!) so we need to use the 192.168.42.200-210 format
my $netmaskBits = esmith::util::IPquadToAddr ($LocalNetmask);
my $sessions = $pptpd{sessions} || 0;
# Calculate pptpd start and end addresses
my $endIP = $dhcpd{end};
my $end_addr = esmith::util::IPquadToAddr($endIP);
my $start_addr = $end_addr - $sessions + 1;
my $startIP = esmith::util::IPaddrToQuad($start_addr);
my @start = split(/\./, $startIP);
my @end = split(/\./, $endIP);
$OUT .= "remoteip ";
my $start = shift @start;
my $end = shift @end ;
$OUT .= ($start eq $end) ? "$start." : "$start-$end.";
$start = shift @start;
$end = shift @end ;
$OUT .= ($start eq $end) ? "$start." : "$start-$end.";
$start = shift @start;
$end = shift @end ;
$OUT .= ($start eq $end) ? "$start." : "$start-$end.";
$start = shift @start;
$end = shift @end ;
$OUT .= ($start eq $end) ? "$start" : "$start-$end";
}

View File

@@ -0,0 +1,8 @@
{
# TAG: speed
#
# Specifies the speed for the PPP daemon to talk at.
# Some PPP daemons will ignore this value.
#
}
speed 460800

View File

@@ -0,0 +1,9 @@
{
# I'm not certain that this is needed. This should be handled by
# connection tracking - we should only accept GRE packets from
# sites we've already negotiated PPTP connections with.
} /sbin/iptables --new-chain gre-in
/sbin/iptables --append INPUT -p 47 -j gre-in
/sbin/iptables --append INPUT -p 47 -j denylog
/sbin/iptables --append gre-in ! -d $OUTERNET -j denylog
/sbin/iptables --append gre-in -j denylog

View File

@@ -0,0 +1,11 @@
{
$OUT = "";
if ((%pptpd) and (exists $pptpd{Interfaces}))
{
$OUT .=<<'EOF';
OLD_PPPconn=$(get_safe_id PPPconn filter find)
NEW_PPPconn=$(get_safe_id PPPconn filter new)
/sbin/iptables --new-chain $NEW_PPPconn
EOF
}
}

View File

@@ -0,0 +1,14 @@
{
$OUT = "";
if ((%pptpd) and (exists $pptpd{Interfaces}))
{
my @interfaces = split /,/, $pptpd{Interfaces};
foreach my $interface (sort @interfaces)
{
$OUT .=<<"EOF";
/sbin/iptables --insert \$NEW_PPPconn --in-interface $interface -j ACCEPT
/sbin/iptables --insert \$NEW_PPPconn --out-interface $interface -j ACCEPT
EOF
}
}
}

View File

@@ -0,0 +1,13 @@
{
$OUT = "";
if ((%pptpd) and (exists $pptpd{Interfaces}))
{
$OUT .=<<'EOF';
# Destroy the old chain and put in the new one.
/sbin/iptables --replace PPPconn 1 \
--jump $NEW_PPPconn
/sbin/iptables --flush $OLD_PPPconn
/sbin/iptables --delete-chain $OLD_PPPconn
EOF
}
}

View File

@@ -0,0 +1,9 @@
{
my $pptpd_status = $pptpd{status} || 'disabled';
my $target = ($pptpd_status eq 'enabled') ? "ACCEPT" : "denylog";
$OUT =
" /sbin/iptables --replace gre-in 1 ! -d \$OUTERNET -j denylog\n" .
" /sbin/iptables --replace gre-in 2 -j $target";
}

View File

@@ -0,0 +1,5 @@
[Service]
ExecStartPre=/sbin/e-smith/service-status pptpd
[Install]
WantedBy=sme-server.target

0
root/var/log/pptpd/.gitignore vendored Normal file
View File