finish logging
This commit is contained in:
@ -2,11 +2,12 @@
|
||||
""" This Script encrypt Wireguardfiles for Wirepy users for more Security """
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import pwd
|
||||
import shutil
|
||||
from subprocess import CompletedProcess, run
|
||||
from wp_app_config import AppConfig
|
||||
from wp_app_config import AppConfig, logging
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--user", required=True, help="Username of the target file system")
|
||||
@ -18,7 +19,7 @@ try:
|
||||
uid = user_info.pw_uid # User ID (e.g., 1000)
|
||||
gid = user_info.pw_gid # Group ID (e.g., 1000)
|
||||
except KeyError:
|
||||
print(f"User '{args.user}' not found.")
|
||||
logging.error(f"User '{args.user}' not found.", exc_info=True)
|
||||
exit(1)
|
||||
|
||||
keyfile: Path = Path(f"/home/{args.user}/.config/wire_py/pbwgk.pem")
|
||||
@ -44,17 +45,12 @@ if not keyfile.is_file():
|
||||
check=False,
|
||||
)
|
||||
|
||||
if process.stdout:
|
||||
print(process.stdout)
|
||||
|
||||
# Output from Openssl Error
|
||||
if process.stderr:
|
||||
print("(Error):", process.stderr)
|
||||
logging.error(f"{process.stderr} Code: {process.returncode}", exc_info=True)
|
||||
|
||||
if process.returncode == 0:
|
||||
print("Public key generated successfully.")
|
||||
else:
|
||||
print(f"Error generate Publickey: Code: {process.returncode}")
|
||||
logging.info("Public key generated successfully.", exc_info=True)
|
||||
|
||||
shutil.chown(keyfile, uid, gid)
|
||||
|
||||
@ -82,13 +78,6 @@ if AppConfig.TEMP_DIR.exists() and any(AppConfig.TEMP_DIR.iterdir()):
|
||||
check=False,
|
||||
)
|
||||
|
||||
print(f"Processing of the file: {config_file}")
|
||||
|
||||
# Output from Openssl Error
|
||||
if process.stderr:
|
||||
print("(Error):", process.stderr)
|
||||
|
||||
if process.returncode == 0:
|
||||
print(f"File {base_name}.dat successfully encrypted.")
|
||||
else:
|
||||
print(f"Error by {config_file}: Code: {process.returncode}")
|
||||
logging.error(process.stderr, exc_info=True)
|
||||
|
Reference in New Issue
Block a user