From 2ad4442acea9ccd996e25d09827aa9d556603a93 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 7 Apr 2024 21:35:32 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Env=20NSS=5FLIB=5FPATH=20can=20now?= =?UTF-8?q?=20be=20used=20to=20specify=20libnss=20location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #108 --- CHANGELOG.md | 1 + README.md | 22 ++++++++++++++++++++++ firefox_decrypt.py | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afee7ac..c3d5ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ##### 1.1.0+git - Fix unhandled exception with deleted passwords - see #99 +- Environment variable `NSS_LIB_PATH` can now be used to specify `libnss` location ##### 1.1.0 - Include `pyproject.toml` to facilitate usage via `pipx` diff --git a/README.md b/README.md index f9bb8cc..ec50d94 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,28 @@ You can also choose from one of the supported formats with `--format`: (*) `pass` can produce unintended consequences. Make sure to backup your password store before using this option. +##### Specify NSS library location + +In order to decode your passwords, Firefox Decrypt uses a series of heuristics to try to locate a compatible [NSS library](https://developer.mozilla.org/docs/Mozilla/Projects/NSS) on your system. +As this approach can sometimes fail, starting with version 1.1.1 of Firefox Decrypt you can now define the `NSS_LIB_PATH` environment variable to manually specify the location of the library. +This location will be prioritized and if no compatible library is found, the script will continue with the built-in heuristics. + +``` +# On Linux it will look for libnss3.so in /opt/nss/lib/ +# On Mac it will look for libnss3.dylib +NSS_LIB_PATH=/opt/nss/lib/ python firefox_decrypt.py + +# On Windows it will look for nss3.dll +set NSS_LIB_PATH=D:\NSS\lib\ && python firefox_decrypt.py +``` + +You can confirm if this was successful by running the script in high-verbosity mode (`-vv`) and look for the `Loaded NSS` message after `Loading NSS`: + +``` +(...) DEBUG - Loading NSS library from /opt/nss/lib/libnss3.so +(...) DEBUG - Loaded NSS library from /opt/nss/lib/libnss3.so +``` + ##### Non-interactive mode A non-interactive mode which bypasses all prompts, including profile choice and master password, can be enabled with `-n/--no-interactive`. diff --git a/firefox_decrypt.py b/firefox_decrypt.py index 76792fb..2718dd8 100755 --- a/firefox_decrypt.py +++ b/firefox_decrypt.py @@ -279,7 +279,9 @@ def find_nss(locations: list[str], nssname: str) -> ct.CDLL: def load_libnss(): """Load libnss into python using the CDLL interface""" - locations: list[str] = [] + locations: list[str] = [ + os.environ.get("NSS_LIB_PATH", ""), + ] if SYSTEM == "Windows": nssname = "nss3.dll"