Updated for root user

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-09-24 23:31:07 +03:00
parent 677e9d5d2b
commit 365c6e653e

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
import sys
import logging
from pathlib import Path
@ -788,6 +789,12 @@ def main() -> None:
Raises:
SystemExit: Exit code 0.
"""
error = Errors()
if not os.geteuid() == 0:
error.raise_error_message(message='Must run as root.', exit_status=1)
raise SystemExit('')
# Configure logging
if Configs.error_log_file.is_file():
Configs.error_log_file.unlink()
@ -854,7 +861,6 @@ def main() -> None:
arguments[args[0]]()
except KeyError:
logging.error("Exception occurred", exc_info=True)
error = Errors()
error.raise_error_message(message='Something went wrong, check the log file.', exit_status=1)
except IndexError:
usage.help_short(1)