From 139b7542cd9567eaff32bd713df971b6ac5b81de Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Sat, 25 Nov 2023 01:50:04 +0100 Subject: [PATCH] fix: allow site installation without enforcing a venv Currently the only way to circumvent the venv checks is setting an environment variable. However, this is not sufficient for distro site packaging: - if the variable is not set, its a rather bad and unexpected user experience to somehow magically set PWNDBG_PLEASE_SKIP_VENV - if the variable is set globally as login shell profile, this means skipping venv is always enforced which means if gdb is loaded with a pwndbg gdbinit.py from a git clone, its rather unexpected to skip the venv This patch checks for a `.skip-venv` file alongside the `gdbinit.py` which means for site installations that use de-vendored dependencies like during distro packaging, this file can simply be touched. It would skip the venv when pwndbg is loaded from the site installation but at the same time would not skip loading the venv when pwndbg is started from a git clone. --- gdbinit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbinit.py b/gdbinit.py index 520e6e4ca..710df489d 100644 --- a/gdbinit.py +++ b/gdbinit.py @@ -20,7 +20,7 @@ if environ.get("PWNDBG_PROFILE") == "1": # Get virtualenv's site-packages path venv_path = os.environ.get("PWNDBG_VENV_PATH") -if venv_path == "PWNDBG_PLEASE_SKIP_VENV": +if venv_path == "PWNDBG_PLEASE_SKIP_VENV" or path.exists(path.dirname(__file__) + "/.skip-venv"): pass else: directory, file = path.split(__file__)