Skip to content

Commit

Permalink
✨ Env NSS_LIB_PATH can now be used to specify libnss location
Browse files Browse the repository at this point in the history
Closes #108
  • Loading branch information
unode committed Apr 7, 2024
1 parent 0c7cc26 commit 9a3abd2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 3 additions & 1 deletion firefox_decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9a3abd2

Please sign in to comment.