From 07ca0044d02311c8124189d4c11e5a60428597de Mon Sep 17 00:00:00 2001 From: Mithun Gowda B Date: Mon, 21 Jul 2025 11:42:02 +0530 Subject: [PATCH] Update uninstall.py Signed-off-by: Mithun Gowda B --- setup/operations/uninstall.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup/operations/uninstall.py b/setup/operations/uninstall.py index 1417c91..3d3355e 100644 --- a/setup/operations/uninstall.py +++ b/setup/operations/uninstall.py @@ -417,6 +417,15 @@ def run(args: argparse.Namespace) -> int: operation = UninstallOperation() operation.setup_operation_logging(args) logger = get_logger() + # ✅ Inserted validation code + expected_home = Path.home().resolve() + actual_dir = args.install_dir.resolve() + + if not str(actual_dir).startswith(str(expected_home)): + print(f"\n[✗] Installation must be inside your user profile directory.") + print(f" Expected prefix: {expected_home}") + print(f" Provided path: {actual_dir}") + sys.exit(1) try: # Validate global arguments @@ -495,4 +504,4 @@ def run(args: argparse.Namespace) -> int: print(f"\n{Colors.YELLOW}Uninstall cancelled by user{Colors.RESET}") return 130 except Exception as e: - return operation.handle_operation_error("uninstall", e) \ No newline at end of file + return operation.handle_operation_error("uninstall", e)