summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-vpn/vtun/files')
-rw-r--r--net-vpn/vtun/files/vtun-3.0.4-autoconf-fork-not-working.patch11
-rw-r--r--net-vpn/vtun/files/vtun-3.0.4-includes.patch50
-rw-r--r--net-vpn/vtun/files/vtun-3.0.4-libssl-ctx.patch253
-rw-r--r--net-vpn/vtun/files/vtun-3.0.4-naughty-inlines.patch21
4 files changed, 335 insertions, 0 deletions
diff --git a/net-vpn/vtun/files/vtun-3.0.4-autoconf-fork-not-working.patch b/net-vpn/vtun/files/vtun-3.0.4-autoconf-fork-not-working.patch
new file mode 100644
index 000000000000..258e4d736ccd
--- /dev/null
+++ b/net-vpn/vtun/files/vtun-3.0.4-autoconf-fork-not-working.patch
@@ -0,0 +1,11 @@
+--- a/config.h.in 2022-11-28 07:10:54.564387362 +0100
++++ b/config.h.in 2022-11-28 07:12:15.435007668 +0100
+@@ -156,3 +156,8 @@
+
+ /* Define as `fork' if `vfork' does not work. */
+ #undef vfork
++
++#if !defined(HAVE_WORKING_FORK) && !defined(HAVE_WORKING_VFORK)
++#define HAVE_WORKING_FORK 1
++#endif
++
diff --git a/net-vpn/vtun/files/vtun-3.0.4-includes.patch b/net-vpn/vtun/files/vtun-3.0.4-includes.patch
new file mode 100644
index 000000000000..d17e4acbc5c4
--- /dev/null
+++ b/net-vpn/vtun/files/vtun-3.0.4-includes.patch
@@ -0,0 +1,50 @@
+--- a/lfd_encrypt.c
++++ b/lfd_encrypt.c
+@@ -44,6 +44,7 @@
+ #include <strings.h>
+ #include <string.h>
+ #include <time.h>
++#include <arpa/inet.h> /* htonl() */
+
+ #include "vtun.h"
+ #include "linkfd.h"
+--- a/lib.c
++++ b/lib.c
+@@ -34,6 +34,7 @@
+ #include <sys/wait.h>
+ #include <syslog.h>
+ #include <errno.h>
++#include <time.h> /* nanosleep() */
+
+ #include "vtun.h"
+ #include "linkfd.h"
+--- a/lib.h
++++ b/lib.h
+@@ -26,6 +26,7 @@
+ #include <sys/types.h>
+ #include <signal.h>
+ #include <errno.h>
++#include <unistd.h> /* read(), write() */
+
+ #ifdef HAVE_LIBUTIL_H
+ #include <libutil.h>
+--- a/lock.c
++++ b/lock.c
+@@ -32,6 +32,7 @@
+ #include <sys/types.h>
+ #include <signal.h>
+ #include <errno.h>
++#include <time.h> /* nanosleep() */
+
+ #include "vtun.h"
+ #include "linkfd.h"
+--- a/lfd_shaper.c
++++ b/lfd_shaper.c
+@@ -27,6 +27,7 @@
+ #include <stdlib.h>
+ #include <sys/time.h>
+ #include <syslog.h>
++#include <time.h> /* nanosleep() */
+
+ #include "vtun.h"
+ #include "linkfd.h"
diff --git a/net-vpn/vtun/files/vtun-3.0.4-libssl-ctx.patch b/net-vpn/vtun/files/vtun-3.0.4-libssl-ctx.patch
new file mode 100644
index 000000000000..6df2ca344e1f
--- /dev/null
+++ b/net-vpn/vtun/files/vtun-3.0.4-libssl-ctx.patch
@@ -0,0 +1,253 @@
+--- a/lfd_encrypt.c 2016-10-01 23:27:51.000000000 +0200
++++ b/lfd_encrypt.c 2022-11-27 19:30:55.119047677 +0100
+@@ -95,11 +95,11 @@
+ static char * pkey;
+ static char * iv_buf;
+
+-static EVP_CIPHER_CTX ctx_enc; /* encrypt */
+-static EVP_CIPHER_CTX ctx_dec; /* decrypt */
++static EVP_CIPHER_CTX *ctx_enc = NULL; /* encrypt */
++static EVP_CIPHER_CTX *ctx_dec = NULL; /* decrypt */
+
+-static EVP_CIPHER_CTX ctx_enc_ecb; /* sideband ecb encrypt */
+-static EVP_CIPHER_CTX ctx_dec_ecb; /* sideband ecb decrypt */
++static EVP_CIPHER_CTX *ctx_enc_ecb = NULL; /* sideband ecb encrypt */
++static EVP_CIPHER_CTX *ctx_dec_ecb = NULL; /* sideband ecb decrypt */
+
+ static int send_msg(int len, char *in, char **out);
+ static int recv_msg(int len, char *in, char **out);
+@@ -146,6 +146,22 @@
+ free(key);
+ }
+
++static void setup_ctx_ptrs()
++{
++ if (ctx_enc_ecb == NULL) {
++ ctx_enc_ecb = EVP_CIPHER_CTX_new();
++ }
++ if (ctx_dec_ecb == NULL) {
++ ctx_dec_ecb = EVP_CIPHER_CTX_new();
++ }
++ if (ctx_enc == NULL) {
++ ctx_enc = EVP_CIPHER_CTX_new();
++ }
++ if (ctx_dec == NULL) {
++ ctx_dec = EVP_CIPHER_CTX_new();
++ }
++}
++
+ static int alloc_encrypt(struct vtun_host *host)
+ {
+ int sb_init = 0;
+@@ -168,6 +184,8 @@
+ return -1;
+ }
+
++ setup_ctx_ptrs();
++
+ RAND_bytes((char *)&sequence_num, 4);
+ gibberish = 0;
+ gib_time_start = 0;
+@@ -182,15 +200,15 @@
+ keysize = 32;
+ sb_init = 1;
+ cipher_type = EVP_aes_256_ecb();
+- pctx_enc = &ctx_enc_ecb;
+- pctx_dec = &ctx_dec_ecb;
++ pctx_enc = ctx_enc_ecb;
++ pctx_dec = ctx_dec_ecb;
+ break;
+
+ case VTUN_ENC_AES256ECB:
+ blocksize = 16;
+ keysize = 32;
+- pctx_enc = &ctx_enc;
+- pctx_dec = &ctx_dec;
++ pctx_enc = ctx_enc;
++ pctx_dec = ctx_dec;
+ cipher_type = EVP_aes_256_ecb();
+ strcpy(cipher_name,"AES-256-ECB");
+ break;
+@@ -201,14 +219,14 @@
+ keysize = 16;
+ sb_init=1;
+ cipher_type = EVP_aes_128_ecb();
+- pctx_enc = &ctx_enc_ecb;
+- pctx_dec = &ctx_dec_ecb;
++ pctx_enc = ctx_enc_ecb;
++ pctx_dec = ctx_dec_ecb;
+ break;
+ case VTUN_ENC_AES128ECB:
+ blocksize = 16;
+ keysize = 16;
+- pctx_enc = &ctx_enc;
+- pctx_dec = &ctx_dec;
++ pctx_enc = ctx_enc;
++ pctx_dec = ctx_dec;
+ cipher_type = EVP_aes_128_ecb();
+ strcpy(cipher_name,"AES-128-ECB");
+ break;
+@@ -221,16 +239,16 @@
+ var_key = 1;
+ sb_init = 1;
+ cipher_type = EVP_bf_ecb();
+- pctx_enc = &ctx_enc_ecb;
+- pctx_dec = &ctx_dec_ecb;
++ pctx_enc = ctx_enc_ecb;
++ pctx_dec = ctx_dec_ecb;
+ break;
+
+ case VTUN_ENC_BF256ECB:
+ blocksize = 8;
+ keysize = 32;
+ var_key = 1;
+- pctx_enc = &ctx_enc;
+- pctx_dec = &ctx_dec;
++ pctx_enc = ctx_enc;
++ pctx_dec = ctx_dec;
+ cipher_type = EVP_bf_ecb();
+ strcpy(cipher_name,"Blowfish-256-ECB");
+ break;
+@@ -243,16 +261,16 @@
+ var_key = 1;
+ sb_init = 1;
+ cipher_type = EVP_bf_ecb();
+- pctx_enc = &ctx_enc_ecb;
+- pctx_dec = &ctx_dec_ecb;
++ pctx_enc = ctx_enc_ecb;
++ pctx_dec = ctx_dec_ecb;
+ break;
+ case VTUN_ENC_BF128ECB: /* blowfish 128 ecb is the default */
+ default:
+ blocksize = 8;
+ keysize = 16;
+ var_key = 1;
+- pctx_enc = &ctx_enc;
+- pctx_dec = &ctx_dec;
++ pctx_enc = ctx_enc;
++ pctx_dec = ctx_dec;
+ cipher_type = EVP_bf_ecb();
+ strcpy(cipher_name,"Blowfish-128-ECB");
+ break;
+@@ -294,10 +312,10 @@
+ lfd_free(enc_buf); enc_buf = NULL;
+ lfd_free(dec_buf); dec_buf = NULL;
+
+- EVP_CIPHER_CTX_cleanup(&ctx_enc);
+- EVP_CIPHER_CTX_cleanup(&ctx_dec);
+- EVP_CIPHER_CTX_cleanup(&ctx_enc_ecb);
+- EVP_CIPHER_CTX_cleanup(&ctx_dec_ecb);
++ EVP_CIPHER_CTX_cleanup(ctx_enc);
++ EVP_CIPHER_CTX_cleanup(ctx_dec);
++ EVP_CIPHER_CTX_cleanup(ctx_enc_ecb);
++ EVP_CIPHER_CTX_cleanup(ctx_dec_ecb);
+
+ return 0;
+ }
+@@ -323,7 +341,7 @@
+ outlen=len+pad;
+ if (pad == blocksize)
+ RAND_bytes(in_ptr+len, blocksize-1);
+- EVP_EncryptUpdate(&ctx_enc, out_ptr, &outlen, in_ptr, len+pad);
++ EVP_EncryptUpdate(ctx_enc, out_ptr, &outlen, in_ptr, len+pad);
+ *out = enc_buf;
+
+ sequence_num++;
+@@ -343,7 +361,7 @@
+
+ outlen=len;
+ if (!len) return 0;
+- EVP_DecryptUpdate(&ctx_dec, out_ptr, &outlen, in_ptr, len);
++ EVP_DecryptUpdate(ctx_dec, out_ptr, &outlen, in_ptr, len);
+ recv_ib_mesg(&outlen, &out_ptr);
+ if (!outlen) return 0;
+ tmp_ptr = out_ptr + outlen; tmp_ptr--;
+@@ -431,13 +449,15 @@
+ break;
+ } /* switch(cipher) */
+
+- EVP_CIPHER_CTX_init(&ctx_enc);
+- EVP_EncryptInit_ex(&ctx_enc, cipher_type, NULL, NULL, NULL);
++ setup_ctx_ptrs();
++
++ EVP_CIPHER_CTX_init(ctx_enc);
++ EVP_EncryptInit_ex(ctx_enc, cipher_type, NULL, NULL, NULL);
+ if (var_key)
+- EVP_CIPHER_CTX_set_key_length(&ctx_enc, keysize);
+- EVP_EncryptInit_ex(&ctx_enc, NULL, NULL, pkey, NULL);
+- EVP_EncryptInit_ex(&ctx_enc, NULL, NULL, NULL, iv);
+- EVP_CIPHER_CTX_set_padding(&ctx_enc, 0);
++ EVP_CIPHER_CTX_set_key_length(ctx_enc, keysize);
++ EVP_EncryptInit_ex(ctx_enc, NULL, NULL, pkey, NULL);
++ EVP_EncryptInit_ex(ctx_enc, NULL, NULL, NULL, iv);
++ EVP_CIPHER_CTX_set_padding(ctx_enc, 0);
+ if (enc_init_first_time)
+ {
+ sprintf(tmpstr,"%s encryption initialized", cipher_name);
+@@ -521,13 +541,15 @@
+ break;
+ } /* switch(cipher) */
+
+- EVP_CIPHER_CTX_init(&ctx_dec);
+- EVP_DecryptInit_ex(&ctx_dec, cipher_type, NULL, NULL, NULL);
++ setup_ctx_ptrs();
++
++ EVP_CIPHER_CTX_init(ctx_dec);
++ EVP_DecryptInit_ex(ctx_dec, cipher_type, NULL, NULL, NULL);
+ if (var_key)
+- EVP_CIPHER_CTX_set_key_length(&ctx_dec, keysize);
+- EVP_DecryptInit_ex(&ctx_dec, NULL, NULL, pkey, NULL);
+- EVP_DecryptInit_ex(&ctx_dec, NULL, NULL, NULL, iv);
+- EVP_CIPHER_CTX_set_padding(&ctx_dec, 0);
++ EVP_CIPHER_CTX_set_key_length(ctx_dec, keysize);
++ EVP_DecryptInit_ex(ctx_dec, NULL, NULL, pkey, NULL);
++ EVP_DecryptInit_ex(ctx_dec, NULL, NULL, NULL, iv);
++ EVP_CIPHER_CTX_set_padding(ctx_dec, 0);
+ if (dec_init_first_time)
+ {
+ sprintf(tmpstr,"%s decryption initialized", cipher_name);
+@@ -559,7 +581,7 @@
+
+ in_ptr = in - blocksize*2;
+ outlen = blocksize*2;
+- EVP_EncryptUpdate(&ctx_enc_ecb, in_ptr,
++ EVP_EncryptUpdate(ctx_enc_ecb, in_ptr,
+ &outlen, in_ptr, blocksize*2);
+ *out = in_ptr;
+ len = outlen;
+@@ -586,7 +608,7 @@
+ in_ptr = in;
+ iv = malloc(blocksize);
+ outlen = blocksize*2;
+- EVP_DecryptUpdate(&ctx_dec_ecb, in_ptr, &outlen, in_ptr, blocksize*2);
++ EVP_DecryptUpdate(ctx_dec_ecb, in_ptr, &outlen, in_ptr, blocksize*2);
+
+ if ( !strncmp(in_ptr, "ivec", 4) )
+ {
+@@ -629,7 +651,7 @@
+ if (cipher_enc_state != CIPHER_INIT)
+ {
+ cipher_enc_state = CIPHER_INIT;
+- EVP_CIPHER_CTX_cleanup(&ctx_enc);
++ EVP_CIPHER_CTX_cleanup(ctx_enc);
+ #ifdef LFD_ENCRYPT_DEBUG
+ vtun_syslog(LOG_INFO,
+ "Forcing local encryptor re-init");
+@@ -710,7 +732,7 @@
+ if (cipher_enc_state != CIPHER_INIT)
+ {
+ cipher_enc_state = CIPHER_INIT;
+- EVP_CIPHER_CTX_cleanup(&ctx_enc);
++ EVP_CIPHER_CTX_cleanup(ctx_enc);
+ }
+ #ifdef LFD_ENCRYPT_DEBUG
+ vtun_syslog(LOG_INFO, "Remote requests encryptor re-init");
+@@ -724,7 +746,7 @@
+ cipher_enc_state != CIPHER_REQ_INIT &&
+ cipher_enc_state != CIPHER_INIT)
+ {
+- EVP_CIPHER_CTX_cleanup (&ctx_dec);
++ EVP_CIPHER_CTX_cleanup (ctx_dec);
+ cipher_dec_state = CIPHER_INIT;
+ cipher_enc_state = CIPHER_REQ_INIT;
+ }
diff --git a/net-vpn/vtun/files/vtun-3.0.4-naughty-inlines.patch b/net-vpn/vtun/files/vtun-3.0.4-naughty-inlines.patch
new file mode 100644
index 000000000000..d36d95d7c6e2
--- /dev/null
+++ b/net-vpn/vtun/files/vtun-3.0.4-naughty-inlines.patch
@@ -0,0 +1,21 @@
+--- a/vtun.h 2016-10-01 23:27:51.000000000 +0200
++++ b/vtun.h 2022-11-27 19:08:02.609754913 +0100
+@@ -232,6 +232,6 @@
+ int tunnel(struct vtun_host *host);
+ int read_config(char *file);
+ struct vtun_host * find_host(char *host);
+-inline void clear_nat_hack_flags(int svr);
++void clear_nat_hack_flags(int svr);
+
+ #endif
+--- a/cfg_file.y 2022-11-27 19:09:33.380433928 +0100
++++ b/cfg_file.y 2022-11-27 19:09:57.340613164 +0100
+@@ -610,7 +610,7 @@
+ }
+
+ /* Clear the VTUN_NAT_HACK flag which are not relevant to the current operation mode */
+-inline void clear_nat_hack_flags(int svr)
++void clear_nat_hack_flags(int svr)
+ {
+ if (svr)
+ llist_trav(&host_list,clear_nat_hack_server,NULL);