initial import

This commit is contained in:
2025-06-22 20:39:04 -05:00
commit f8a70886f0
3428 changed files with 302546 additions and 0 deletions

81
vde2/PKGBUILD Normal file
View File

@@ -0,0 +1,81 @@
# Maintainer: Jesus E. <heckyel@riseup.net>
pkgname=vde2
pkgver=2.3.2
_debver=$pkgver
_debrel=11
pkgrel=12
pkgdesc="Virtual Distributed Ethernet for emulators like QEMU"
url='https://sourceforge.net/projects/vde/'
license=('GPL-2')
arch=('i686' 'x86_64')
depends=('bash' 'libpcap' 'libressl')
makedepends=('python' 'quilt')
backup=(etc/conf.d/vde_switch)
source=("https://downloads.sourceforge.net/vde/${pkgname}-${pkgver}.tar.bz2"
"https://deb.debian.org/debian/pool/main/v/vde2/vde2_${_debver}+r586-${_debrel}.debian.tar.xz"
"vde_cryptcab-compile-against-openssl-1.1.0.patch"
"dhcpd.conf.sample"
"vde-config.sample"
"vde-connection.sample"
"vde_switch.confd"
"vde_switch.initd")
install=$pkgname.install
options=(!makeflags)
sha512sums=('51be75fde5a526b988060f25322a8b20289b1677db2e3aa6dbee55875c1d7af564f9d8d201a0a4a1a842471cce06f29fcd83e55a5ff7acfdc36a8349cb2f3cc6'
'1c60179f6706490e1573b0015a8ce1f27fa19f434c36d5aa6e664196f805cda2aed247b12ddf690aeb0b46309c1a12223638e5673bff32a2fd4e7804d77dbbab'
'0a45a631d765779e916067b3789e38276e2ad72f3f97621a79a45bc8745f51f458993924307cf709535a806bed9cefee494012240e5fae19ce00efcf6a16f274'
'58b0866cee781b7e6edc9cc1e991f01c01984b47df77742bd42decf4568061e7292c040b9f9aaef9c24aa779e988b82a71fa4212a59e1e7165767e29e35ef6b4'
'd7d714d27a3c5680a35e6f1f52f0d9931c98495f56ef432cd644eb7b26e4d397ff73e26163967a7b50a175ccf81584bd009a814d9bc834be35e65186223c5976'
'c064c8121ccad75d97e0d2fcdd04e8e233b30cacfe9409cd79b009ebc789e459ae07a3dbc07c71334b5ec62a2483a3ac696a6842777eac1fc16b21175a5ca963'
'a56181bce04f3e1c67357ff7b90373406709f7a3140deba4ca3da3f49116932bb0f6c6cda9950b52df1af256542a6187562eb84b0d4043c84cfac186ab275e54'
'599b3560721b6e31cbcc21e764df772bde2a8bbf131b47ebb575bf31855a53237dd1c265d33f31c91e3115d6f8cb9f94493d2dd6792c8bedb011299d1ed6d8e9')
prepare() {
cd $pkgname-$pkgver
if [[ ${pkgver%.*} = ${_debver%.*} ]]; then
# Debian patches
export QUILT_PATCHES=debian/patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
export QUILT_DIFF_ARGS='--no-timestamps'
mv "$srcdir"/debian .
# Doesn't apply
rm -v debian/patches/compile_with_hurd.patch || true
rm -v debian/patches/compile_with_kfreebsd.patch || true
rm -v debian/patches/fix_soname_version_info.patch || true
rm -v debian/patches/vde_cryptcab-compile-against-openssl-1.1.0.patch || true
quilt push -av
fi
patch -Np1 -i $srcdir/vde_cryptcab-compile-against-openssl-1.1.0.patch
}
build() {
cd $srcdir/$pkgname-$pkgver
./configure \
--prefix=/usr \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--libexecdir=/usr/libexec/vde2 \
--enable-experimental
make
}
package() {
cd $srcdir/$pkgname-$pkgver
make DESTDIR="$pkgdir" install
install -D -m 644 $srcdir/vde-config.sample $pkgdir/etc/vde/vde-config.sample
install -D -m 644 $srcdir/vde-connection.sample $pkgdir/etc/vde/vde-connection.sample
install -D -m 644 $srcdir/dhcpd.conf.sample $pkgdir/usr/share/vde2/dhcpd.conf.sample
install -D -m 644 $srcdir/vde_switch.confd $pkgdir/etc/conf.d/vde_switch
install -D -m 755 $srcdir/vde_switch.initd $pkgdir/etc/init.d/vde_switch
# install license files
for i in COPYING*; do
install -Dm644 COPYING* -t $pkgdir/usr/share/licenses/$pkgname
done
}

12
vde2/dhcpd.conf.sample Normal file
View File

@@ -0,0 +1,12 @@
ddns-update-style none;
subnet 192.168.254.0 netmask 255.255.255.0 {
range 192.168.254.1 192.168.254.253;
option routers 192.168.254.254;
option domain-name "virtual.example.com";
# find your DNS servers from /etc/resolv.conf
# otherwise only pure IP addresses will work
option domain-name-servers 192.168.254.254;
option broadcast-address 192.168.254.255;
default-lease-time 86400;
}

35
vde2/vde-config.sample Normal file
View File

@@ -0,0 +1,35 @@
# Set options vde_switch program
# To activate this vde profile add it to /etc/conf.d/vde
# Global options
VDE_NUMPORTS="32" # Number of ports (default 32)
VDE_HUB="no" # [yes|no] Make the switch act as a hub
VDE_FSTP="no" # [yes|no] Activate the fast spanning tree protocol
VDE_MAC="" # Set the Switch MAC address
VDE_PRIORITY="" # Set the priority for FST (MAC extension)
VDE_HASHSIZE="" # Hash table size
# Options from datasock module
VDE_SOCK="/var/run/vde/sample.sock" # control directory pathname
VDE_SOCK_MODE="660" # Standard access mode for comm sockets (octal)
VDE_SOCK_GROUP="root" # Group owner for comm sockets
# Options from consmgmt module
VDE_MANAGEMENT_SOCK="/var/run/vde/sample.mgmt" # path of the management UNIX socket
VDE_MANAGEMENT_SOCK_MODE="660" # management UNIX socket access mode (octal)
# Other options to parse to vde_switch
VDE_OPTIONS=""
# VDE with internet support
# You can use either tuntap method or slirpvde method.
# Options from tuntap module
VDE_TAP="" # Enable routing through TAP tap interface (comma separated array eg.:"tap0,tap1").
# slirpvde daemon support
SLIRP="no" # [yes|no] enable/disable SLIRP daemon support
SLIRP_DHCP="no" # [yes|no] turn on the DHCP server for the network autoconfiguration of all the units connected to the VDE
SLIRP_NETWORK="" # specify the network address (default 10.0.2.0)
# other options to parse to slirpvde
SLIRP_OPTIONS=""

View File

@@ -0,0 +1,6 @@
# You can add vde switch connections below
# just without the # at the beginning:
# vde_plug /var/run/vde/sample.sock = vde_plug /var/run/vde/sample2.sock
# or if hosts are different use this syntax:
# vde_plug /var/run/vde/sample.sock = ssh host2 vde_plug /var/run/vde/sample.sock

19
vde2/vde2.install Normal file
View File

@@ -0,0 +1,19 @@
post_install() {
echo "vde config files should be placed in /etc/vde, sample files are provided."
echo "iptables and dhcpd sample files have been installed to '/usr/share/vde2'."
echo "Merge those examples, if needed to the according config files."
if ! getent group vde &>/dev/null; then
groupadd -r vde >/dev/null
fi
}
post_upgrade() {
post_install $1
}
post_remove() {
if getent group vde &>/dev/null; then
groupdel vde >/dev/null
fi
}

View File

@@ -0,0 +1,94 @@
diff --git a/src/vde_cryptcab/cryptcab.c b/src/vde_cryptcab/cryptcab.c
index c1f14fd..0c7b186 100644
--- a/src/vde_cryptcab/cryptcab.c
+++ b/src/vde_cryptcab/cryptcab.c
@@ -22,7 +22,7 @@ static void Usage(char *programname)
exit(1);
}
-static EVP_CIPHER_CTX ctx;
+static EVP_CIPHER_CTX *ctx;
static int ctx_initialized = 0;
static int encryption_disabled = 0;
static int nfd;
@@ -30,6 +30,10 @@ static unsigned long long mycounter=1;
static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
static int verbose = 0;
+#if OPENSSL_VERSION_NUMBER < 0x1010000 || defined LIBRESSL_VERSION_NUMBER
+#define EVP_CIPHER_CTX_reset(x) EVP_CIPHER_CTX_cleanup(x)
+#endif
+
void vc_printlog(int priority, const char *format, ...)
{
va_list arg;
@@ -103,19 +107,21 @@ int data_encrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p
}
if (!ctx_initialized) {
- EVP_CIPHER_CTX_init (&ctx);
+ ctx = EVP_CIPHER_CTX_new ();
+ if (!ctx)
+ return -1;
ctx_initialized = 1;
}
- EVP_EncryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
- if (EVP_EncryptUpdate (&ctx, dst, &olen, src, len) != 1)
+ EVP_EncryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
+ if (EVP_EncryptUpdate (ctx, dst, &olen, src, len) != 1)
{
fprintf (stderr,"error in encrypt update\n");
olen = -1;
goto cleanup;
}
- if (EVP_EncryptFinal (&ctx, dst + olen, &tlen) != 1)
+ if (EVP_EncryptFinal (ctx, dst + olen, &tlen) != 1)
{
fprintf (stderr,"error in encrypt final\n");
olen = -1;
@@ -124,7 +130,7 @@ int data_encrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p
olen += tlen;
cleanup:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_reset(ctx);
return olen;
}
@@ -138,19 +144,21 @@ int data_decrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p
}
if (!ctx_initialized) {
- EVP_CIPHER_CTX_init (&ctx);
+ ctx = EVP_CIPHER_CTX_new ();
+ if (!ctx)
+ return -1;
ctx_initialized = 1;
}
- EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
- if (EVP_DecryptUpdate (&ctx, dst, &olen, src, len) != 1)
+ EVP_DecryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
+ if (EVP_DecryptUpdate (ctx, dst, &olen, src, len) != 1)
{
fprintf (stderr,"error in decrypt update\n");
olen = -1;
goto cleanup;
}
- if (EVP_DecryptFinal (&ctx, dst + olen, &tlen) != 1)
+ if (EVP_DecryptFinal (ctx, dst + olen, &tlen) != 1)
{
fprintf (stderr,"error in decrypt final\n");
olen = -1;
@@ -159,7 +167,7 @@ int data_decrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p
olen += tlen;
cleanup:
- EVP_CIPHER_CTX_cleanup(&ctx);
+ EVP_CIPHER_CTX_reset (ctx);
return olen;
}

15
vde2/vde_switch.confd Normal file
View File

@@ -0,0 +1,15 @@
# load the tun module
VDE_MODPROBE_TUN="yes"
# virtual tap networking device to be used for vde
VDE_TAP="tap0"
# The group that will have access to the VDE control socket.
VDE_GROUP="vde"
# VDE socket location (default: /run/${RC_SVCNAME}.ctl)
VDE_SOCKET=""
# Additional options passed to the vde_switch daemon.
#VDE_OPTS=""
VDE_OPTS=""

44
vde2/vde_switch.initd Normal file
View File

@@ -0,0 +1,44 @@
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
command="/usr/bin/vde_switch"
pidfile="/run/${RC_SVCNAME}.pid"
depend() {
after net.${VDE_TAP}
}
start_pre() {
[ "${VDE_MODPROBE_TUN}" = "yes" ] || return 0
modprobe tun
}
# We have to use start() because the shortform uses --pidfile for s-s-d --start
# which causes s-s-d to check the pid file before it exists
start() {
VDE_SOCKET="${VDE_SOCKET:-/run/${RC_SVCNAME}.ctl}"
ebegin "Starting ${SVC_NAME}"
start-stop-daemon --start --exec ${command} -- \
--pidfile=${pidfile} \
--tap=${VDE_TAP} \
--group=${VDE_GROUP} \
--mode=660 \
--dirmode=770 \
--sock=${VDE_SOCKET} \
--daemon \
${VDE_OPTS}
ewaitfile 10 "${VDE_SOCKET}"
eend $? "Failed to start ${RC_SVCNAME}"
}
stop_post() {
[ "${VDE_MODPROBE_TUN}" = "yes" ] && modprobe --quiet --remove tun
# Don't fail to stop the service if the "tun" module in use
# and the above "modprobe -r" command fails.
return 0
}