aboutsummaryrefslogtreecommitdiff
path: root/net/xl2tpd/patches
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2015-05-13 13:20:06 +0200
committerDaniel Golle <daniel@makrotopia.org>2015-05-13 13:23:21 +0200
commit964edd830b12884df476f9abb001478754506660 (patch)
tree58a2c5b82a0e68deec0c4de27351a105b40d80e4 /net/xl2tpd/patches
parent764c55e0139d38627bfd10c95a80c70537b5391c (diff)
xl2tpd: update source, import some useful patches
Yousong Zhou <yszhou4tech@gmail.com> made a couple of useful fixes mostly for the xl2tpd-control tool which was broken. imported them (patches/2*) here. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'net/xl2tpd/patches')
-rw-r--r--net/xl2tpd/patches/100-makefile_opt_flags.patch2
-rw-r--r--net/xl2tpd/patches/110-makefile_dont_build_pfc.patch6
-rw-r--r--net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch6
-rw-r--r--net/xl2tpd/patches/201-xl2tpd-control-check-end-of-file-when-reading-pipe-t.patch37
-rw-r--r--net/xl2tpd/patches/202-xl2tpd-control-define-_GNU_SOURCE-to-use-fmemopen-an.patch21
-rw-r--r--net/xl2tpd/patches/203-xl2tpd-control-open-control-file-with-O_NONBLOCK.patch37
-rw-r--r--net/xl2tpd/patches/204-start_pppd-place-opts-after-plugin-pppol2tp.so.patch62
-rw-r--r--net/xl2tpd/patches/205-xl2tpd-control-cleaup-result-file-atexit.patch62
-rw-r--r--net/xl2tpd/patches/206-xl2tpd-fix-possible-buffer-overflow-when-filling-str.patch22
-rw-r--r--net/xl2tpd/patches/207-l2tp_log-remove-log-prefix-that-will-duplicate-with-.patch21
10 files changed, 268 insertions, 8 deletions
diff --git a/net/xl2tpd/patches/100-makefile_opt_flags.patch b/net/xl2tpd/patches/100-makefile_opt_flags.patch
index 82e875d70..1af416f96 100644
--- a/net/xl2tpd/patches/100-makefile_opt_flags.patch
+++ b/net/xl2tpd/patches/100-makefile_opt_flags.patch
@@ -1,6 +1,6 @@
--- a/Makefile
+++ b/Makefile
-@@ -91,7 +91,8 @@ OSFLAGS+= -DUSE_KERNEL
+@@ -97,7 +97,8 @@ OSFLAGS+= -DUSE_KERNEL
IPFLAGS?= -DIP_ALLOCATION
diff --git a/net/xl2tpd/patches/110-makefile_dont_build_pfc.patch b/net/xl2tpd/patches/110-makefile_dont_build_pfc.patch
index 460a0f15d..f76364fa8 100644
--- a/net/xl2tpd/patches/110-makefile_dont_build_pfc.patch
+++ b/net/xl2tpd/patches/110-makefile_dont_build_pfc.patch
@@ -1,6 +1,6 @@
--- a/Makefile
+++ b/Makefile
-@@ -107,10 +107,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
+@@ -113,10 +113,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
MANDIR?=$(DESTDIR)${PREFIX}/share/man
@@ -13,7 +13,7 @@
$(EXEC): $(OBJS) $(HDRS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
-@@ -118,14 +118,10 @@ $(EXEC): $(OBJS) $(HDRS)
+@@ -124,14 +124,10 @@ $(EXEC): $(OBJS) $(HDRS)
$(CONTROL_EXEC): $(CONTROL_SRCS)
$(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@
@@ -29,7 +29,7 @@
install -d -m 0755 ${SBINDIR}
install -m 0755 $(EXEC) ${SBINDIR}/$(EXEC)
install -d -m 0755 ${MANDIR}/man5
-@@ -133,11 +129,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
+@@ -139,11 +135,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
install -m 0644 doc/xl2tpd.8 ${MANDIR}/man8/
install -m 0644 doc/xl2tpd.conf.5 doc/l2tp-secrets.5 \
${MANDIR}/man5/
diff --git a/net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch b/net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch
index dba544c0e..c8c4a7dd6 100644
--- a/net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch
+++ b/net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch
@@ -1,7 +1,5 @@
-Index: xl2tpd-1.3.6/xl2tpd.c
-===================================================================
---- xl2tpd-1.3.6.orig/xl2tpd.c
-+++ xl2tpd-1.3.6/xl2tpd.c
+--- a/xl2tpd.c
++++ b/xl2tpd.c
@@ -30,7 +30,7 @@
#include <errno.h>
#include <unistd.h>
diff --git a/net/xl2tpd/patches/201-xl2tpd-control-check-end-of-file-when-reading-pipe-t.patch b/net/xl2tpd/patches/201-xl2tpd-control-check-end-of-file-when-reading-pipe-t.patch
new file mode 100644
index 000000000..52f8332cd
--- /dev/null
+++ b/net/xl2tpd/patches/201-xl2tpd-control-check-end-of-file-when-reading-pipe-t.patch
@@ -0,0 +1,37 @@
+From 8c5853b8e22f34bc1c1acba278f7850ab7946894 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Tue, 28 Apr 2015 21:26:15 +0800
+Subject: [PATCH 1/7] xl2tpd-control: check end-of-file when reading pipe to
+ avoid dead loop.
+
+---
+ xl2tpd-control.c | 11 +++++++----
+ 1 file changed, 7 insertions(+), 4 deletions(-)
+
+--- a/xl2tpd-control.c
++++ b/xl2tpd-control.c
+@@ -306,17 +306,20 @@ int read_result(int result_fd, char* buf
+ /*FIXME: there is a chance to hang up reading.
+ Should I create watching thread with timeout?
+ */
+- ssize_t readed;
++ ssize_t readed = 0;
++ ssize_t len;
++
+ do
+ {
+- readed = read (result_fd, buf, size);
+- if (readed < 0)
++ len = read (result_fd, buf + readed, size - readed);
++ if (len < 0)
+ {
+ print_error (ERROR_LEVEL,
+ "error: can't read command result: %s\n", strerror (errno));
+ break;
+ }
+- } while (readed == 0);
++ readed += len;
++ } while (len > 0 && (size - readed) > 0);
+ buf[readed] = '\0';
+
+ /* scan result code */
diff --git a/net/xl2tpd/patches/202-xl2tpd-control-define-_GNU_SOURCE-to-use-fmemopen-an.patch b/net/xl2tpd/patches/202-xl2tpd-control-define-_GNU_SOURCE-to-use-fmemopen-an.patch
new file mode 100644
index 000000000..d75010f9a
--- /dev/null
+++ b/net/xl2tpd/patches/202-xl2tpd-control-define-_GNU_SOURCE-to-use-fmemopen-an.patch
@@ -0,0 +1,21 @@
+From 76f444d284c0b0a351a488954e0d39b72a0ce211 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Wed, 29 Apr 2015 10:32:37 +0800
+Subject: [PATCH 2/7] xl2tpd-control: define _GNU_SOURCE to use fmemopen() and
+ friends.
+
+---
+ xl2tpd-control.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/xl2tpd-control.c
++++ b/xl2tpd-control.c
+@@ -10,6 +10,8 @@
+ *
+ */
+
++#define _GNU_SOURCE
++
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdarg.h>
diff --git a/net/xl2tpd/patches/203-xl2tpd-control-open-control-file-with-O_NONBLOCK.patch b/net/xl2tpd/patches/203-xl2tpd-control-open-control-file-with-O_NONBLOCK.patch
new file mode 100644
index 000000000..aef1f7c15
--- /dev/null
+++ b/net/xl2tpd/patches/203-xl2tpd-control-open-control-file-with-O_NONBLOCK.patch
@@ -0,0 +1,37 @@
+From f7cfd36b8a93afd326c0d9378e99576c616bd3fc Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Wed, 29 Apr 2015 14:21:12 +0800
+Subject: [PATCH 3/7] xl2tpd-control: open control file with O_NONBLOCK.
+
+Otherwise xl2tpd-control would block indefinitely in case xl2tpd is
+not running.
+---
+ xl2tpd-control.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/xl2tpd-control.c
++++ b/xl2tpd-control.c
+@@ -246,7 +246,7 @@ int main (int argc, char *argv[])
+ print_error (DEBUG_LEVEL, "command to be passed:\n%s\n", buf);
+
+ /* try to open control file for writing */
+- int control_fd = open (control_filename, O_WRONLY, 0600);
++ int control_fd = open (control_filename, O_WRONLY | O_NONBLOCK, 0600);
+ if (control_fd < 0)
+ {
+ int errorno = errno;
+@@ -265,6 +265,14 @@ int main (int argc, char *argv[])
+ }
+ return -1;
+ }
++
++ /* turn off O_NONBLOCK */
++ if (fcntl (control_fd, F_SETFL, O_WRONLY) == -1) {
++ print_error (ERROR_LEVEL,
++ "Can not turn off nonblocking mode for control_fd: %s\n",
++ strerror(errno));
++ return -2;
++ }
+
+ /* pass command to control pipe */
+ if (write (control_fd, buf, ftell (mesf)) < 0)
diff --git a/net/xl2tpd/patches/204-start_pppd-place-opts-after-plugin-pppol2tp.so.patch b/net/xl2tpd/patches/204-start_pppd-place-opts-after-plugin-pppol2tp.so.patch
new file mode 100644
index 000000000..1d50eaa25
--- /dev/null
+++ b/net/xl2tpd/patches/204-start_pppd-place-opts-after-plugin-pppol2tp.so.patch
@@ -0,0 +1,62 @@
+From 7a343f7b79b70a8e7e04b2bd465d344ad0ef4c49 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Wed, 29 Apr 2015 16:30:17 +0800
+Subject: [PATCH 4/7] start_pppd: place opts after "plugin pppol2tp.so".
+
+so that plugin options like pppol2tp_debug_mark can be recognized by pppd.
+---
+ xl2tpd.c | 21 ++++++++++-----------
+ 1 file changed, 10 insertions(+), 11 deletions(-)
+
+--- a/xl2tpd.c
++++ b/xl2tpd.c
+@@ -382,7 +382,6 @@ int start_pppd (struct call *c, struct p
+ /* char a, b; */
+ char tty[512];
+ char *stropt[80];
+- struct ppp_opts *p;
+ #ifdef USE_KERNEL
+ struct sockaddr_pppol2tp sax;
+ int flags;
+@@ -396,16 +395,7 @@ int start_pppd (struct call *c, struct p
+ struct call *sc;
+ struct tunnel *st;
+
+- p = opts;
+ stropt[0] = strdup (PPPD);
+- while (p)
+- {
+- stropt[pos] = (char *) malloc (strlen (p->option) + 1);
+- strncpy (stropt[pos], p->option, strlen (p->option) + 1);
+- pos++;
+- p = p->next;
+- }
+- stropt[pos] = NULL;
+ if (c->pppd > 0)
+ {
+ l2tp_log(LOG_WARNING, "%s: PPP already started on call!\n", __FUNCTION__);
+@@ -467,7 +457,6 @@ int start_pppd (struct call *c, struct p
+ snprintf (stropt[pos], 10, "%d", c->ourcid);
+ pos++;
+ }
+- stropt[pos] = NULL;
+ }
+ else
+ #endif
+@@ -497,6 +486,16 @@ int start_pppd (struct call *c, struct p
+ return -EINVAL;
+ }
+ stropt[pos++] = strdup(tty);
++ }
++
++ {
++ struct ppp_opts *p = opts;
++ while (p)
++ {
++ stropt[pos] = strdup (p->option);
++ pos++;
++ p = p->next;
++ }
+ stropt[pos] = NULL;
+ }
+
diff --git a/net/xl2tpd/patches/205-xl2tpd-control-cleaup-result-file-atexit.patch b/net/xl2tpd/patches/205-xl2tpd-control-cleaup-result-file-atexit.patch
new file mode 100644
index 000000000..bfd01a2b6
--- /dev/null
+++ b/net/xl2tpd/patches/205-xl2tpd-control-cleaup-result-file-atexit.patch
@@ -0,0 +1,62 @@
+From d4a484db1684cce15966bb722644416f90253ea7 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Thu, 30 Apr 2015 13:53:11 +0800
+Subject: [PATCH 5/7] xl2tpd-control: cleaup result file atexit().
+
+---
+ xl2tpd-control.c | 20 +++++++++++++-------
+ 1 file changed, 13 insertions(+), 7 deletions(-)
+
+--- a/xl2tpd-control.c
++++ b/xl2tpd-control.c
+@@ -35,6 +35,9 @@
+ #define TUNNEL_REQUIRED 1
+ #define TUNNEL_NOT_REQUIRED 0
+
++char result_filename[128];
++int result_fd = -1;
++
+ int log_level = ERROR_LEVEL;
+
+ void print_error (int level, const char *fmt, ...);
+@@ -117,6 +120,14 @@ void help()
+ );
+ }
+
++void cleanup(void)
++{
++ /* cleaning up */
++ if (result_fd >= 0)
++ close (result_fd);
++ unlink (result_filename);
++}
++
+ int main (int argc, char *argv[])
+ {
+ char* control_filename = NULL;
+@@ -195,11 +206,11 @@ int main (int argc, char *argv[])
+ FILE* mesf = fmemopen (buf, CONTROL_PIPE_MESSAGE_SIZE, "w");
+
+ /* create result pipe for reading */
+- char result_filename[128];
+ snprintf (result_filename, 128, RESULT_FILENAME_FORMAT, getpid());
+ unlink (result_filename);
+ mkfifo (result_filename, 0600);
+- int result_fd = open (result_filename, O_RDONLY | O_NONBLOCK, 0600);
++ atexit(cleanup);
++ result_fd = open (result_filename, O_RDONLY | O_NONBLOCK, 0600);
+ if (result_fd < 0)
+ {
+ print_error (ERROR_LEVEL,
+@@ -293,11 +304,6 @@ int main (int argc, char *argv[])
+ );
+ printf ("%s", rbuf);
+
+- /* cleaning up */
+-
+- close (result_fd);
+- unlink (result_filename);
+-
+ return command_result_code;
+ }
+
diff --git a/net/xl2tpd/patches/206-xl2tpd-fix-possible-buffer-overflow-when-filling-str.patch b/net/xl2tpd/patches/206-xl2tpd-fix-possible-buffer-overflow-when-filling-str.patch
new file mode 100644
index 000000000..6110b0c5b
--- /dev/null
+++ b/net/xl2tpd/patches/206-xl2tpd-fix-possible-buffer-overflow-when-filling-str.patch
@@ -0,0 +1,22 @@
+From 1e8b82388578a622c5caf8fa04c238fdd7808ecc Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Thu, 30 Apr 2015 13:53:40 +0800
+Subject: [PATCH 6/7] xl2tpd: fix possible buffer overflow when filling
+ stropt[].
+
+---
+ xl2tpd.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/xl2tpd.c
++++ b/xl2tpd.c
+@@ -490,7 +490,8 @@ int start_pppd (struct call *c, struct p
+
+ {
+ struct ppp_opts *p = opts;
+- while (p)
++ int maxn_opts = sizeof(stropt) / sizeof(stropt[0]) - 1;
++ while (p && pos < maxn_opts)
+ {
+ stropt[pos] = strdup (p->option);
+ pos++;
diff --git a/net/xl2tpd/patches/207-l2tp_log-remove-log-prefix-that-will-duplicate-with-.patch b/net/xl2tpd/patches/207-l2tp_log-remove-log-prefix-that-will-duplicate-with-.patch
new file mode 100644
index 000000000..d513a5820
--- /dev/null
+++ b/net/xl2tpd/patches/207-l2tp_log-remove-log-prefix-that-will-duplicate-with-.patch
@@ -0,0 +1,21 @@
+From 44ced2bbf1d6b39bb36c3cb8be6e40c8764e2e8a Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Thu, 30 Apr 2015 13:57:36 +0800
+Subject: [PATCH 7/7] l2tp_log: remove log prefix that will duplicate with
+ procd.
+
+---
+ misc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/misc.c
++++ b/misc.c
+@@ -61,7 +61,7 @@ void l2tp_log (int level, const char *fm
+ init_log();
+ SYSLOG_CALL( syslog (level, "%s", buf) );
+ } else {
+- fprintf(stderr, "xl2tpd[%d]: %s", getpid(), buf);
++ fprintf(stderr, "%s", buf);
+ }
+ }
+