pptpd: backport from trunk
authorLuka Perkov <[email protected]>
Wed, 18 Nov 2015 20:49:25 +0000 (21:49 +0100)
committerLuka Perkov <[email protected]>
Wed, 18 Nov 2015 20:49:25 +0000 (21:49 +0100)
Signed-off-by: Luka Perkov <[email protected]>
net/pptpd/Makefile [new file with mode: 0644]
net/pptpd/files/options.pptpd [new file with mode: 0644]
net/pptpd/files/pptpd.conf [new file with mode: 0644]
net/pptpd/files/pptpd.config [new file with mode: 0644]
net/pptpd/files/pptpd.init [new file with mode: 0644]
net/pptpd/patches/001-bad_pqueue_debug.patch [new file with mode: 0644]
net/pptpd/patches/002-makefile_fix.patch [new file with mode: 0644]
net/pptpd/patches/003-opt_flags.patch [new file with mode: 0644]
net/pptpd/patches/100-musl-compat.patch [new file with mode: 0644]

diff --git a/net/pptpd/Makefile b/net/pptpd/Makefile
new file mode 100644 (file)
index 0000000..d17d196
--- /dev/null
@@ -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 <[email protected]>
+
+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))
diff --git a/net/pptpd/files/options.pptpd b/net/pptpd/files/options.pptpd
new file mode 100644 (file)
index 0000000..f73eeea
--- /dev/null
@@ -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
diff --git a/net/pptpd/files/pptpd.conf b/net/pptpd/files/pptpd.conf
new file mode 100644 (file)
index 0000000..354745f
--- /dev/null
@@ -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
diff --git a/net/pptpd/files/pptpd.config b/net/pptpd/files/pptpd.config
new file mode 100644 (file)
index 0000000..b2d5df5
--- /dev/null
@@ -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'
diff --git a/net/pptpd/files/pptpd.init b/net/pptpd/files/pptpd.init
new file mode 100644 (file)
index 0000000..d1c50fd
--- /dev/null
@@ -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
+}
diff --git a/net/pptpd/patches/001-bad_pqueue_debug.patch b/net/pptpd/patches/001-bad_pqueue_debug.patch
new file mode 100644 (file)
index 0000000..50d5252
--- /dev/null
@@ -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);
diff --git a/net/pptpd/patches/002-makefile_fix.patch b/net/pptpd/patches/002-makefile_fix.patch
new file mode 100644 (file)
index 0000000..74e3335
--- /dev/null
@@ -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)
diff --git a/net/pptpd/patches/003-opt_flags.patch b/net/pptpd/patches/003-opt_flags.patch
new file mode 100644 (file)
index 0000000..cc136c5
--- /dev/null
@@ -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@
diff --git a/net/pptpd/patches/100-musl-compat.patch b/net/pptpd/patches/100-musl-compat.patch
new file mode 100644 (file)
index 0000000..6ce625a
--- /dev/null
@@ -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 */