From 875138142d39059ab6669a5c4eba3403947181c9 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Fri, 9 Feb 2024 19:57:33 +0100 Subject: [PATCH] move vpn tool --- Makefile | 12 +++++------- scripts/connect.py | 3 ++- scripts/connect_basic.py | 7 ++----- src/{enter_vpn.c => vpn.c} | 0 4 files changed, 9 insertions(+), 13 deletions(-) rename src/{enter_vpn.c => vpn.c} (100%) diff --git a/Makefile b/Makefile index 4443193..1a12481 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CFLAGS = -std=gnu99 -pie -fPIC -pedantic -Wno-imports -Wunused -Wno-missing-field-initializers -Wextra -Wunreachable-code -O3 -all: wireguard_mount wireguard_resolve enter_vpn +all: wireguard_mount wireguard_resolve vpn wireguard_mount: src/wireguard-mount.c mkdir -p bin @@ -10,9 +10,9 @@ wireguard_resolve: src/resolve.c src/resolve.s mkdir -p bin gcc -shared -o bin/wireguard-resolve.so -nostdlib -fPIC src/resolve.c src/resolve.s -enter_vpn: src/enter_vpn.c +vpn: src/vpn.c mkdir -p bin - gcc $(CFLAGS) -o bin/enter_vpn src/enter_vpn.c + gcc $(CFLAGS) -o bin/vpn src/vpn.c format: src scripts clang-format -i src/*.c @@ -31,12 +31,10 @@ install_mount: systemd bin install_basic: systemd scripts bin mkdir -p /snacks/wireguard/bin mkdir -p /snacks/wireguard/scripts - cp bin/wireguard-resolve.so /snacks/wireguard/bin/wireguard-resolve.so cp systemd/vpnclient-wg-basic.service /etc/systemd/system/vpnclient-wg-basic.service cp scripts/connect_basic.py /snacks/wireguard/scripts/connect_basic.py cp scripts/inner_basic.sh /snacks/wireguard/scripts/inner_basic.sh + cp bin/vpn /usr/local/bin/vpn + setcap cap_sys_admin,cap_sys_ptrace=ep /usr/local/bin/vpn chmod -R 755 /snacks/wireguard systemctl daemon-reload - - - diff --git a/scripts/connect.py b/scripts/connect.py index 4aade0c..61c8c49 100644 --- a/scripts/connect.py +++ b/scripts/connect.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -import subprocess, os +import subprocess +import os newenv = os.environ.copy() newenv["LD_PRELOAD"] = "/snacks/wireguard/bin/wireguard-resolve.so" diff --git a/scripts/connect_basic.py b/scripts/connect_basic.py index fcdf2b5..5b91169 100644 --- a/scripts/connect_basic.py +++ b/scripts/connect_basic.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 -import subprocess, os - -newenv = os.environ.copy() -newenv["LD_PRELOAD"] = "/snacks/wireguard/bin/wireguard-resolve.so" +import subprocess +import os def default_devices(): @@ -70,7 +68,6 @@ def wireguard(): ) subprocess.run( ["nsenter", "--net=/run/vpn/net", "/snacks/wireguard/scripts/inner_basic.sh"], - env=newenv, ) diff --git a/src/enter_vpn.c b/src/vpn.c similarity index 100% rename from src/enter_vpn.c rename to src/vpn.c