fix ssl_decrypt replace logging with message window and path corrected
This commit is contained in:
@ -5,7 +5,8 @@ from pathlib import Path
|
||||
import pwd
|
||||
import shutil
|
||||
from subprocess import CompletedProcess, run
|
||||
from shared_libs.wp_app_config import AppConfig, logging
|
||||
from shared_libs.wp_app_config import AppConfig
|
||||
from shared_libs.common_tools import LxTools
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--user", required=True, help="Username of the target file system")
|
||||
@ -17,41 +18,21 @@ try:
|
||||
uid = user_info.pw_uid # User ID (e.g., 1000)
|
||||
gid = user_info.pw_gid # Group ID (e.g., 1000)
|
||||
except KeyError:
|
||||
logging.error(f"User '{args.user}' not found.", exc_info=True)
|
||||
LxTools.msg_window(
|
||||
AppConfig.IMAGE_PATHS["icon_error"],
|
||||
AppConfig.IMAGE_PATHS["icon_error"],
|
||||
"Error decrypt",
|
||||
f"User '{args.user}' not found.",
|
||||
exc_info=True,
|
||||
)
|
||||
exit(1)
|
||||
|
||||
keyfile: Path = Path(f"/home/{args.user}/.config/wire_py/pbwgk.pem")
|
||||
path_of_crypted_tunnel: Path = Path(f"/home/{args.user}/.config/wire_py")
|
||||
crypted_tunnel: Path = Path(f"/home/{args.user}/.config/wire_py")
|
||||
|
||||
if not keyfile.is_file():
|
||||
process: CompletedProcess[str] = run(
|
||||
[
|
||||
"openssl",
|
||||
"rsa",
|
||||
"-in",
|
||||
AppConfig.SYSTEM_PATHS["pkey_path"],
|
||||
"-out",
|
||||
keyfile,
|
||||
"-outform",
|
||||
"PEM",
|
||||
"-pubout",
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
if process.returncode == 0:
|
||||
logging.info("Public key generated successfully.", exc_info=True)
|
||||
else:
|
||||
logging.error(
|
||||
f"Error with the following code... {process.returncode}", exc_info=True
|
||||
)
|
||||
shutil.chown(keyfile, uid, gid)
|
||||
|
||||
if AppConfig.PUBLICKEY.exists():
|
||||
|
||||
crypted__tunnel = [str(file) for file in path_of_crypted_tunnel.glob("*.dat")]
|
||||
if len([str(file) for file in crypted_tunnel.glob("*.dat")]) == 0:
|
||||
pass
|
||||
else:
|
||||
crypted__tunnel = [str(file) for file in crypted_tunnel.glob("*.dat")]
|
||||
|
||||
for tunnel_path in crypted__tunnel:
|
||||
|
||||
@ -74,11 +55,12 @@ if AppConfig.PUBLICKEY.exists():
|
||||
check=False,
|
||||
)
|
||||
shutil.chown(f"{AppConfig.TEMP_DIR}/{base_name}.conf", uid, gid)
|
||||
logging.info(f"Processing of the file: {tunnel_path}", exc_info=True)
|
||||
|
||||
# Output from Openssl Error
|
||||
if process.stderr:
|
||||
logging.error(
|
||||
LxTools.msg_window(
|
||||
AppConfig.IMAGE_PATHS["icon_error"],
|
||||
AppConfig.IMAGE_PATHS["icon_error"],
|
||||
"Error decrypt",
|
||||
f"{process.stderr} Error by [{tunnel_path}] Code: {process.returncode}",
|
||||
exc_info=True,
|
||||
)
|
||||
|
Reference in New Issue
Block a user