Skip to content

Add environment variable to control John’s home directory (XDG Base Directory support) #5841

@misterhackerman

Description

@misterhackerman

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/john
  • JOHN_HOME=$HOME/.local/state/john
  • JOHN_HOME=$HOME/.john (legacy)

In other words, users control the layout without recompiling or symlink hacks.

Additionally:

  • Preserve the current behavior if JOHN_HOME is 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_HOME with a getenv() check, e.g.:

    const char *john_home = getenv("JOHN_HOME");
    if (!john_home)
        john_home = "~/.john";

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions