pptpd: backport from trunk

Signed-off-by: Luka Perkov <luka@openwrt.org>
This commit is contained in:
Luka Perkov 2015-11-18 21:49:25 +01:00
parent ee0bb7b9df
commit 70471762cc
9 changed files with 245 additions and 0 deletions

69
net/pptpd/Makefile Normal file
View File

@ -0,0 +1,69 @@
#
# Copyright (C) 2006-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=pptpd
PKG_VERSION:=1.4.0
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/poptop
PKG_MD5SUM:=36f9f45c6ffa92bc3b6e24ae2d053505
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_MAINTAINER:=Luka Perkov <luka@openwrt.org>
include $(INCLUDE_DIR)/package.mk
define Package/pptpd
SECTION:=net
CATEGORY:=Network
DEPENDS:=+kmod-ppp +kmod-gre +kmod-mppe +ppp
TITLE:=PopTop pptp server
URL:=http://poptop.sourceforge.net/
SUBMENU:=VPN
endef
CONFIGURE_ARGS += \
--enable-bcrelay \
CONFIGURE_VARS += \
ac_cv_header_libintl_h=no \
MAKE_FLAGS += \
COPTS="$(TARGET_CFLAGS)" \
INSTALL="install" \
define Package/pptpd/conffiles
/etc/pptpd.conf
/etc/ppp/options.pptpd
/etc/config/pptpd
endef
define Package/pptpd/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) \
$(PKG_INSTALL_DIR)/usr/sbin/bcrelay \
$(PKG_INSTALL_DIR)/usr/sbin/pptpctrl \
$(PKG_INSTALL_DIR)/usr/sbin/pptpd \
$(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib/pptpd
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pptpd/* $(1)/usr/lib/pptpd/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) ./files/pptpd.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/pptpd.init $(1)/etc/init.d/pptpd
$(INSTALL_DIR) $(1)/etc/ppp
$(INSTALL_DATA) ./files/options.pptpd $(1)/etc/ppp/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/pptpd.config $(1)/etc/config/pptpd
endef
$(eval $(call BuildPackage,pptpd))

View File

@ -0,0 +1,22 @@
#debug
#logfile /tmp/pptp-server.log
auth
name "pptp-server"
lcp-echo-failure 3
lcp-echo-interval 60
default-asyncmap
mtu 1482
mru 1482
nobsdcomp
nodeflate
#noproxyarp
#nomppc
mppe required,no40,no56,stateless
require-mschap-v2
refuse-chap
refuse-mschap
refuse-eap
refuse-pap
#ms-dns 172.16.1.1
#plugin radius.so
#radius-config-file /etc/radius.conf

View File

@ -0,0 +1,5 @@
#debug
option /etc/ppp/options.pptpd
speed 115200
stimeout 10
#localip & remoteip are not needed, ip management is done by pppd

View File

@ -0,0 +1,8 @@
config service 'pptpd'
option 'enabled' '0'
option 'localip' '192.168.0.1'
option 'remoteip' '192.168.0.20-30'
config 'login'
option 'username' 'youruser'
option 'password' 'yourpass'

View File

@ -0,0 +1,63 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=60
USE_PROCD=1
BIN=/usr/sbin/pptpd
CONFIG=/var/etc/pptpd.conf
CHAP_SECRETS=/var/etc/chap-secrets
validate_login_section() {
uci_validate_section pptpd login "${1}" \
'username:string' \
'password:string'
}
validate_pptpd_section() {
uci_validate_section pptpd service "${1}" \
'enabled:uinteger' \
'localip:string' \
'remoteip:string'
}
setup_login() {
validate_login_section "${1}" || {
echo "validation failed"
return 1
}
[ -n "${username}" ] || return 0
[ -n "${password}" ] || return 0
echo "${username} pptp-server ${password} *" >> $CHAP_SECRETS
}
setup_config() {
validate_pptpd_section "${1}" || {
echo "validation failed"
return 1
}
[ "$enabled" -eq 0 ] && return 1
mkdir -p /var/etc
cp /etc/pptpd.conf $CONFIG
[ -n "$localip" ] && echo "localip $localip" >> $CONFIG
[ -n "$remoteip" ] && echo "remoteip $remoteip" >> $CONFIG
return 0
}
start_service() {
config_load pptpd
setup_config pptpd || return
config_foreach setup_login login
ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets
procd_open_instance
procd_set_param command $BIN -c $CONFIG
procd_close_instance
}

View File

@ -0,0 +1,18 @@
--- a/pqueue.c
+++ b/pqueue.c
@@ -7,13 +7,11 @@
#include "pqueue.h"
#ifdef DEBUG_PQUEUE
-#define DEBUG_ON 1
+#define DEBUG_CMD(_a) { _a }
#else
-#define DEBUG_ON 0
+#define DEBUG_CMD(_a)
#endif
-#define DEBUG_CMD(_a) if (DEBUG_ON) { _a }
-
#define MIN_CAPACITY 128 /* min allocated buffer for a packet */
static int pqueue_alloc (int seq, unsigned char *packet, int packlen, pqueue_t **new);

View File

@ -0,0 +1,11 @@
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -18,7 +18,7 @@ all: $(PLUGINS)
%.so: %.c
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^ $(LDADD)
-LIBDIR ?= $(DESTDIR)$(prefix)/lib/pptpd
+LIBDIR = $(DESTDIR)$(prefix)/lib/pptpd
install: $(PLUGINS)
$(INSTALL) -d $(LIBDIR)

View File

@ -0,0 +1,11 @@
--- a/Makefile.in
+++ b/Makefile.in
@@ -153,7 +153,7 @@ AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
-CFLAGS = -O2 -fno-builtin -Wall -DSBINDIR='"$(sbindir)"'
+CFLAGS = $(COPTS) -fno-builtin -Wall -DSBINDIR='"$(sbindir)"'
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@

View File

@ -0,0 +1,38 @@
--- a/bcrelay.c
+++ b/bcrelay.c
@@ -667,7 +667,7 @@ static void mainloop(int argc, char **ar
* there is no need to concern about the physical/link layer header because it is
* filled in automatically (based on the contents of sa).
*/
- if ((nrsent = sendto(cur_ifsnr[j].sock_nr, ipp_p, rlen, MSG_DONTWAIT|MSG_TRYHARD, (struct sockaddr *)&sa, salen)) < 0)
+ if ((nrsent = sendto(cur_ifsnr[j].sock_nr, ipp_p, rlen, MSG_DONTWAIT|MSG_DONTROUTE, (struct sockaddr *)&sa, salen)) < 0)
{
if (errno == ENETDOWN) {
syslog(LOG_NOTICE, "ignored ENETDOWN from sendto(), a network interface was going down?");
--- a/compat.c
+++ b/compat.c
@@ -11,10 +11,10 @@
#include "compat.h"
#include "our_syslog.h"
-#ifndef HAVE_STRLCPY
#include <string.h>
#include <stdio.h>
+#ifndef HAVE_STRLCPY
void strlcpy(char *dst, const char *src, size_t size)
{
strncpy(dst, src, size - 1);
--- /dev/null
+++ b/net/ppp_defs.h
@@ -0,0 +1,10 @@
+#ifndef _NET_PPP_DEFS_H
+#define _NET_PPP_DEFS_H 1
+
+#define __need_time_t
+#include <time.h>
+
+#include <asm/types.h>
+#include <linux/ppp_defs.h>
+
+#endif /* net/ppp_defs.h */