korreckturen throughout code

This commit is contained in:
2025-04-26 00:28:34 +02:00
parent f6204c9071
commit 1a853d4ff1
6 changed files with 255 additions and 222 deletions

View File

@ -1,35 +1,35 @@
#!/usr/bin/python3
""" This Script decrypt Wireguardfiles for Wirepy users """
""" This Script decrypt Wireguard files for Wirepy users """
import os
import shutil
from pathlib import Path
from subprocess import check_call
uname = Path("/tmp/.loguser")
uname: Path = Path("/tmp/.log_user")
with open(uname, "r", encoding="utf-8") as f:
logname = f.readline()
log_name = f.readline()
# Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
dirname = Path("/tmp/tlecdcwg/")
keyfile = Path(f"/home/{logname}/.config/wire_py/pbwgk.pem")
PKEYFILE = "/usr/local/etc/ssl/pwgk.pem"
# Folder Name "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
folder_path: Path = Path("/tmp/tlecdcwg/")
keyfile: Path = Path(f"/home/{log_name}/.config/wire_py/pbwgk.pem")
PKEYFILE: Path = "/usr/local/etc/ssl/pwgk.pem"
if not keyfile.is_file():
check_call(["openssl", "rsa", "-in", PKEYFILE, "-out", keyfile, "-outform", "PEM", "-pubout"])
shutil.chown(keyfile, 1000, 1000)
dirname2 = f"/home/{logname}/.config/wire_py/"
detl = os.listdir(dirname2)
os.chdir(dirname2)
folder_path2 = f"/home/{log_name}/.config/wire_py/"
detl: list[str] = os.listdir(folder_path2)
os.chdir(folder_path2)
detl.remove("keys")
detl.remove("settings")
if os.path.exists(f"{dirname2}pbwgk.pem"):
if os.path.exists(f"{folder_path2}pbwgk.pem"):
detl.remove("pbwgk.pem")
for detunnels in detl:
tlname2 = f"{detunnels[:-4]}.conf"
extpath = f"{dirname}/{tlname2}"
extpath = f"{folder_path}/{tlname2}"
check_call(["openssl", "pkeyutl", "-decrypt", "-inkey", PKEYFILE, "-in", detunnels, "-out", extpath])
shutil.chown(extpath, 1000, 1000)