Kaynağa Gözat

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>
Daniel Golle 10 yıl önce
ebeveyn
işleme
964edd830b

+ 2
- 2
net/xl2tpd/Makefile Dosyayı Görüntüle

@@ -8,7 +8,7 @@
8 8
 include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=xl2tpd
11
-PKG_VERSION:=1.3.6
11
+PKG_VERSION:=1.3.7pre20141126
12 12
 PKG_RELEASE:=1
13 13
 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
14 14
 PKG_LICENSE:=GPL-2.0
@@ -19,7 +19,7 @@ PKG_RELEASE=$(PKG_SOURCE_VERSION)
19 19
 PKG_SOURCE_PROTO:=git
20 20
 PKG_SOURCE_URL:=https://github.com/xelerance/xl2tpd.git
21 21
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
22
-PKG_SOURCE_VERSION:=5619e1771048e74b729804e8602f409af0f3faea
22
+PKG_SOURCE_VERSION:=1cda2a266e2e957b81019d63a8902b28304a0ac4
23 23
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
24 24
 
25 25
 PKG_INSTALL:=1

+ 1
- 1
net/xl2tpd/patches/100-makefile_opt_flags.patch Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 --- a/Makefile
2 2
 +++ b/Makefile
3
-@@ -91,7 +91,8 @@ OSFLAGS+= -DUSE_KERNEL
3
+@@ -97,7 +97,8 @@ OSFLAGS+= -DUSE_KERNEL
4 4
  
5 5
  IPFLAGS?= -DIP_ALLOCATION
6 6
  

+ 3
- 3
net/xl2tpd/patches/110-makefile_dont_build_pfc.patch Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 --- a/Makefile
2 2
 +++ b/Makefile
3
-@@ -107,10 +107,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
3
+@@ -113,10 +113,10 @@ BINDIR?=$(DESTDIR)${PREFIX}/bin
4 4
  MANDIR?=$(DESTDIR)${PREFIX}/share/man
5 5
  
6 6
  
@@ -13,7 +13,7 @@
13 13
  
14 14
  $(EXEC): $(OBJS) $(HDRS)
15 15
  	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
16
-@@ -118,14 +118,10 @@ $(EXEC): $(OBJS) $(HDRS)
16
+@@ -124,14 +124,10 @@ $(EXEC): $(OBJS) $(HDRS)
17 17
  $(CONTROL_EXEC): $(CONTROL_SRCS)
18 18
  	$(CC) $(CFLAGS) $(LDFLAGS) $(CONTROL_SRCS) -o $@
19 19
  
@@ -29,7 +29,7 @@
29 29
  	install -d -m 0755 ${SBINDIR}
30 30
  	install -m 0755 $(EXEC) ${SBINDIR}/$(EXEC)
31 31
  	install -d -m 0755 ${MANDIR}/man5
32
-@@ -133,11 +129,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
32
+@@ -139,11 +135,6 @@ install: ${EXEC} pfc ${CONTROL_EXEC}
33 33
  	install -m 0644 doc/xl2tpd.8 ${MANDIR}/man8/
34 34
  	install -m 0644 doc/xl2tpd.conf.5 doc/l2tp-secrets.5 \
35 35
  		 ${MANDIR}/man5/

+ 2
- 4
net/xl2tpd/patches/120-no-bsd-signal-in-musl.patch Dosyayı Görüntüle

@@ -1,7 +1,5 @@
1
-Index: xl2tpd-1.3.6/xl2tpd.c
2
-===================================================================
3
---- xl2tpd-1.3.6.orig/xl2tpd.c
4
-+++ xl2tpd-1.3.6/xl2tpd.c
1
+--- a/xl2tpd.c
2
++++ b/xl2tpd.c
5 3
 @@ -30,7 +30,7 @@
6 4
  #include <errno.h>
7 5
  #include <unistd.h>

+ 37
- 0
net/xl2tpd/patches/201-xl2tpd-control-check-end-of-file-when-reading-pipe-t.patch Dosyayı Görüntüle

@@ -0,0 +1,37 @@
1
+From 8c5853b8e22f34bc1c1acba278f7850ab7946894 Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Tue, 28 Apr 2015 21:26:15 +0800
4
+Subject: [PATCH 1/7] xl2tpd-control: check end-of-file when reading pipe to
5
+ avoid dead loop.
6
+
7
+---
8
+ xl2tpd-control.c | 11 +++++++----
9
+ 1 file changed, 7 insertions(+), 4 deletions(-)
10
+
11
+--- a/xl2tpd-control.c
12
++++ b/xl2tpd-control.c
13
+@@ -306,17 +306,20 @@ int read_result(int result_fd, char* buf
14
+     /*FIXME: there is a chance to hang up reading.
15
+              Should I create watching thread with timeout?
16
+      */
17
+-    ssize_t readed;
18
++    ssize_t readed = 0;
19
++    ssize_t len;
20
++
21
+     do
22
+     {
23
+-        readed = read (result_fd, buf, size);
24
+-        if (readed < 0)
25
++        len = read (result_fd, buf + readed, size - readed);
26
++        if (len < 0)
27
+         {
28
+             print_error (ERROR_LEVEL,
29
+                 "error: can't read command result: %s\n", strerror (errno));
30
+             break;
31
+         }
32
+-    } while (readed == 0);
33
++        readed += len;
34
++    } while (len > 0 && (size - readed) > 0);
35
+     buf[readed] = '\0';
36
+     
37
+     /* scan result code */

+ 21
- 0
net/xl2tpd/patches/202-xl2tpd-control-define-_GNU_SOURCE-to-use-fmemopen-an.patch Dosyayı Görüntüle

@@ -0,0 +1,21 @@
1
+From 76f444d284c0b0a351a488954e0d39b72a0ce211 Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Wed, 29 Apr 2015 10:32:37 +0800
4
+Subject: [PATCH 2/7] xl2tpd-control: define _GNU_SOURCE to use fmemopen() and
5
+ friends.
6
+
7
+---
8
+ xl2tpd-control.c | 2 ++
9
+ 1 file changed, 2 insertions(+)
10
+
11
+--- a/xl2tpd-control.c
12
++++ b/xl2tpd-control.c
13
+@@ -10,6 +10,8 @@
14
+  *
15
+  */
16
+  
17
++#define _GNU_SOURCE
18
++
19
+ #include <stdio.h>
20
+ #include <string.h>
21
+ #include <stdarg.h>

+ 37
- 0
net/xl2tpd/patches/203-xl2tpd-control-open-control-file-with-O_NONBLOCK.patch Dosyayı Görüntüle

@@ -0,0 +1,37 @@
1
+From f7cfd36b8a93afd326c0d9378e99576c616bd3fc Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Wed, 29 Apr 2015 14:21:12 +0800
4
+Subject: [PATCH 3/7] xl2tpd-control: open control file with O_NONBLOCK.
5
+
6
+Otherwise xl2tpd-control would block indefinitely in case xl2tpd is
7
+not running.
8
+---
9
+ xl2tpd-control.c | 10 +++++++++-
10
+ 1 file changed, 9 insertions(+), 1 deletion(-)
11
+
12
+--- a/xl2tpd-control.c
13
++++ b/xl2tpd-control.c
14
+@@ -246,7 +246,7 @@ int main (int argc, char *argv[])
15
+     print_error (DEBUG_LEVEL, "command to be passed:\n%s\n", buf);
16
+ 
17
+     /* try to open control file for writing */
18
+-    int control_fd = open (control_filename, O_WRONLY, 0600);
19
++    int control_fd = open (control_filename, O_WRONLY | O_NONBLOCK, 0600);
20
+     if (control_fd < 0)
21
+     {
22
+         int errorno = errno;
23
+@@ -265,6 +265,14 @@ int main (int argc, char *argv[])
24
+         }
25
+         return -1;
26
+     }
27
++
28
++    /* turn off O_NONBLOCK */
29
++    if (fcntl (control_fd, F_SETFL, O_WRONLY) == -1) {
30
++        print_error (ERROR_LEVEL,
31
++            "Can not turn off nonblocking mode for control_fd: %s\n",
32
++            strerror(errno));
33
++        return -2;
34
++    }
35
+     
36
+     /* pass command to control pipe */
37
+     if (write (control_fd, buf, ftell (mesf)) < 0)

+ 62
- 0
net/xl2tpd/patches/204-start_pppd-place-opts-after-plugin-pppol2tp.so.patch Dosyayı Görüntüle

@@ -0,0 +1,62 @@
1
+From 7a343f7b79b70a8e7e04b2bd465d344ad0ef4c49 Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Wed, 29 Apr 2015 16:30:17 +0800
4
+Subject: [PATCH 4/7] start_pppd: place opts after "plugin pppol2tp.so".
5
+
6
+so that plugin options like pppol2tp_debug_mark can be recognized by pppd.
7
+---
8
+ xl2tpd.c | 21 ++++++++++-----------
9
+ 1 file changed, 10 insertions(+), 11 deletions(-)
10
+
11
+--- a/xl2tpd.c
12
++++ b/xl2tpd.c
13
+@@ -382,7 +382,6 @@ int start_pppd (struct call *c, struct p
14
+     /* char a, b; */
15
+     char tty[512];
16
+     char *stropt[80];
17
+-    struct ppp_opts *p;
18
+ #ifdef USE_KERNEL
19
+     struct sockaddr_pppol2tp sax;
20
+     int flags;
21
+@@ -396,16 +395,7 @@ int start_pppd (struct call *c, struct p
22
+     struct call *sc;
23
+     struct tunnel *st;
24
+ 
25
+-    p = opts;
26
+     stropt[0] = strdup (PPPD);
27
+-    while (p)
28
+-    {
29
+-        stropt[pos] = (char *) malloc (strlen (p->option) + 1);
30
+-        strncpy (stropt[pos], p->option, strlen (p->option) + 1);
31
+-        pos++;
32
+-        p = p->next;
33
+-    }
34
+-    stropt[pos] = NULL;
35
+     if (c->pppd > 0)
36
+     {
37
+         l2tp_log(LOG_WARNING, "%s: PPP already started on call!\n", __FUNCTION__);
38
+@@ -467,7 +457,6 @@ int start_pppd (struct call *c, struct p
39
+         snprintf (stropt[pos], 10, "%d", c->ourcid);
40
+             pos++;
41
+        }
42
+-        stropt[pos] = NULL;
43
+     }
44
+     else
45
+ #endif
46
+@@ -497,6 +486,16 @@ int start_pppd (struct call *c, struct p
47
+             return -EINVAL;
48
+         }
49
+         stropt[pos++] = strdup(tty);
50
++    }
51
++
52
++    {
53
++        struct ppp_opts *p = opts;
54
++        while (p)
55
++        {
56
++            stropt[pos] = strdup (p->option);
57
++            pos++;
58
++            p = p->next;
59
++        }
60
+         stropt[pos] = NULL;
61
+     }
62
+ 

+ 62
- 0
net/xl2tpd/patches/205-xl2tpd-control-cleaup-result-file-atexit.patch Dosyayı Görüntüle

@@ -0,0 +1,62 @@
1
+From d4a484db1684cce15966bb722644416f90253ea7 Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Thu, 30 Apr 2015 13:53:11 +0800
4
+Subject: [PATCH 5/7] xl2tpd-control: cleaup result file atexit().
5
+
6
+---
7
+ xl2tpd-control.c | 20 +++++++++++++-------
8
+ 1 file changed, 13 insertions(+), 7 deletions(-)
9
+
10
+--- a/xl2tpd-control.c
11
++++ b/xl2tpd-control.c
12
+@@ -35,6 +35,9 @@
13
+ #define TUNNEL_REQUIRED 1
14
+ #define TUNNEL_NOT_REQUIRED 0
15
+ 
16
++char result_filename[128];
17
++int result_fd = -1;
18
++
19
+ int log_level = ERROR_LEVEL;
20
+ 
21
+ void print_error (int level, const char *fmt, ...);
22
+@@ -117,6 +120,14 @@ void help()
23
+     );
24
+ }
25
+ 
26
++void cleanup(void)
27
++{
28
++    /* cleaning up */
29
++    if (result_fd >= 0)
30
++	    close (result_fd);
31
++    unlink (result_filename);
32
++}
33
++
34
+ int main (int argc, char *argv[])
35
+ {
36
+     char* control_filename = NULL;
37
+@@ -195,11 +206,11 @@ int main (int argc, char *argv[])
38
+     FILE* mesf = fmemopen (buf, CONTROL_PIPE_MESSAGE_SIZE, "w");
39
+ 
40
+     /* create result pipe for reading */
41
+-    char result_filename[128];
42
+     snprintf (result_filename, 128, RESULT_FILENAME_FORMAT, getpid());
43
+     unlink (result_filename);
44
+     mkfifo (result_filename, 0600);
45
+-    int result_fd = open (result_filename, O_RDONLY | O_NONBLOCK, 0600);
46
++    atexit(cleanup);
47
++    result_fd = open (result_filename, O_RDONLY | O_NONBLOCK, 0600);
48
+     if (result_fd < 0)
49
+     {
50
+         print_error (ERROR_LEVEL,
51
+@@ -293,11 +304,6 @@ int main (int argc, char *argv[])
52
+     );
53
+     printf ("%s", rbuf);
54
+     
55
+-    /* cleaning up */
56
+-    
57
+-    close (result_fd);
58
+-    unlink (result_filename);
59
+-    
60
+     return command_result_code;
61
+ }
62
+ 

+ 22
- 0
net/xl2tpd/patches/206-xl2tpd-fix-possible-buffer-overflow-when-filling-str.patch Dosyayı Görüntüle

@@ -0,0 +1,22 @@
1
+From 1e8b82388578a622c5caf8fa04c238fdd7808ecc Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Thu, 30 Apr 2015 13:53:40 +0800
4
+Subject: [PATCH 6/7] xl2tpd: fix possible buffer overflow when filling
5
+ stropt[].
6
+
7
+---
8
+ xl2tpd.c | 3 ++-
9
+ 1 file changed, 2 insertions(+), 1 deletion(-)
10
+
11
+--- a/xl2tpd.c
12
++++ b/xl2tpd.c
13
+@@ -490,7 +490,8 @@ int start_pppd (struct call *c, struct p
14
+ 
15
+     {
16
+         struct ppp_opts *p = opts;
17
+-        while (p)
18
++        int maxn_opts = sizeof(stropt) / sizeof(stropt[0]) - 1;
19
++        while (p && pos < maxn_opts)
20
+         {
21
+             stropt[pos] = strdup (p->option);
22
+             pos++;

+ 21
- 0
net/xl2tpd/patches/207-l2tp_log-remove-log-prefix-that-will-duplicate-with-.patch Dosyayı Görüntüle

@@ -0,0 +1,21 @@
1
+From 44ced2bbf1d6b39bb36c3cb8be6e40c8764e2e8a Mon Sep 17 00:00:00 2001
2
+From: Yousong Zhou <yszhou4tech@gmail.com>
3
+Date: Thu, 30 Apr 2015 13:57:36 +0800
4
+Subject: [PATCH 7/7] l2tp_log: remove log prefix that will duplicate with
5
+ procd.
6
+
7
+---
8
+ misc.c | 2 +-
9
+ 1 file changed, 1 insertion(+), 1 deletion(-)
10
+
11
+--- a/misc.c
12
++++ b/misc.c
13
+@@ -61,7 +61,7 @@ void l2tp_log (int level, const char *fm
14
+ 	init_log();
15
+ 	SYSLOG_CALL( syslog (level, "%s", buf) );
16
+     } else {
17
+-	fprintf(stderr, "xl2tpd[%d]: %s", getpid(), buf);
18
++	fprintf(stderr, "%s", buf);
19
+     }
20
+ }
21
+