From 365c6e653e1b2822c5f280d843d3a0579c640847 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 24 Sep 2024 23:31:07 +0300 Subject: [PATCH] Updated for root user Signed-off-by: Dimitris Zlatanidis --- slpkg/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/slpkg/main.py b/slpkg/main.py index a8856fa3..6a1b054c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -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)