Add environment variable to control John’s home directory (XDG Base Directory support)
Summary
John the Ripper currently hardcodes ~/.john as the per-user “home” (JOHN_PRIVATE_HOME in params.h), with $JOHN as a partial override. This setup does not comply with the XDG Base Directory Specification and gives users little flexibility in where files are stored.
The problem is not whether to default to ~/.john or to XDG — it’s that the path is compiled in and not fully user-configurable.
Proposal
Introduce a new environment variable (e.g. JOHN_HOME) that defines the base directory for all user-specific files (config, pot, session, recovery, etc).
This would allow:
JOHN_HOME=$XDG_DATA_HOME/johnJOHN_HOME=$HOME/.local/state/johnJOHN_HOME=$HOME/.john(legacy)
In other words, users control the layout without recompiling or symlink hacks.
Additionally:
- Preserve the current behavior if
JOHN_HOMEis unset (fall back to~/.john).
Benefits
-
User Choice: Users who want strict XDG compliance can set it in their shell profile. Those who prefer the legacy layout don’t need to change anything.
-
Distribution-friendly: Packagers (Arch, Debian, etc.) can enable XDG layouts without patching
params.h. -
No breakage: Existing scripts and installs continue to work unchanged.
-
Simple to implement: Replace the constant
JOHN_PRIVATE_HOMEwith a getenv() check, e.g.:const char *john_home = getenv("JOHN_HOME"); if (!john_home) john_home = "~/.john";
Related issue: #4552
Thank you for linking that issue. But let me clarify:
This isn't about implementing XDG - it's about adding one environment variable (JOHN_HOME) that lets users decide for themselves. Default behavior stays exactly the same (~/.john), but now packagers and advanced users can configure their own paths without needing patches. Zero breaking changes, minimal code.