[GH-ISSUE #2681] $JOHN pathsearch broken when --prefix option is used with configure #1735

Closed
opened 2026-10-15 04:23:48 +07:00 by bsakaguchi · 33 comments
Owner

Originally created by @rofl0r on GitHub (Aug 17, 2017).
Original GitHub issue: https://github.com/openwall/john/issues/2681

using latest git, installing john's run dir into a custom location, and trying to run john from there without cd'ing there is quite broken.

scenario without john.conf in $HOME/.john

execve("john-git/run/john", ["john-git/run/john", "testkey"], [/* 29 vars */]) = 0
mkdir("/home/rofl0r/.john", 0700)       = -1 EEXIST (File exists)
open("/home/rofl0r/.john/john.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("~/.john/john.conf", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/home/rofl0r/.john/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("~/.john/john.ini", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/usr/share/john/john.conf", O_RDONLY) = -1 EACCES (Permission denied)
open("$JOHN/john.conf", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/usr/share/john/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("$JOHN/john.ini", O_RDONLY)        = -1 ENOENT (No such file or directory)

it fails with the message that fopen $JOHN/john.ini failed which is pretty misleading, since there's not even a john.ini in john's source dir. so first i wasted like 5 minutes trying to find john.ini.

since the error message suggests "$JOHN", i intuitively tried setting JOHN env variable.

setting JOHN environment variable to the right directory

didn't have any result, and solar explains in http://www.openwall.com/lists/john-users/2008/06/16/2 that john doesn't use any env vars.

then i copied john.conf to $HOME/.john

john.conf in $HOME/.john

execve("john-git/run/john", ["john-git/run/john", "testkey"], [/* 29 vars */]) = 0
mkdir("/home/rofl0r/.john", 0700)       = -1 EEXIST (File exists)
open("/home/rofl0r/.john/john.conf", O_RDONLY) = 3
read(3, "#\n# This file is part of John th"..., 4096) = 4096
open("/usr/share/john/dynamic_disabled.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("$JOHN/dynamic_disabled.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/john/best64.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("$JOHN/best64.conf", O_RDONLY)     = -1 ENOENT (No such file or directory)
write(2, "fopen: $JOHN/best64.conf", 24) = 24

so now it failed because best64.conf was not found, so i copied *.conf into $HOME/.john.
didn't help either, because the search for best64.conf doesn't even look there

so imo, there are several issues here:

  • path search is not consistent. sometime is uses $HOME/.john, sometimes not
  • environment variables are ignored which is completely unintuitive since the variable is called $JOHN
  • path search is literally done in "$JOHN" - i.e. under some circumstances the string literal is used to search, instead of/additional to what it expands to
  • dirname $(readlink -f $0) is never tried

so i would suggest john doing the following instead

  • maybe accept an environment variable such as JOHN_DIR
  • use always this order to search for files:
    1. what JOHN_DIR env var points to
    2. $HOME/.john
    3. compiled in $JOHN var
    4. dirname $(readlink -f $0) (i.e. the directory where the john binary is in)
    5. . so it works when started from inside the john run dir
Originally created by @rofl0r on GitHub (Aug 17, 2017). Original GitHub issue: https://github.com/openwall/john/issues/2681 using latest git, installing john's run dir into a custom location, and trying to run john from there without cd'ing there is quite broken. ## scenario without john.conf in $HOME/.john ``` execve("john-git/run/john", ["john-git/run/john", "testkey"], [/* 29 vars */]) = 0 mkdir("/home/rofl0r/.john", 0700) = -1 EEXIST (File exists) open("/home/rofl0r/.john/john.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("~/.john/john.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("/home/rofl0r/.john/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory) open("~/.john/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/john/john.conf", O_RDONLY) = -1 EACCES (Permission denied) open("$JOHN/john.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/john/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory) open("$JOHN/john.ini", O_RDONLY) = -1 ENOENT (No such file or directory) ``` it fails with the message that fopen $JOHN/john.ini failed which is pretty misleading, since there's not even a john.ini in john's source dir. so first i wasted like 5 minutes trying to find john.ini. since the error message suggests "$JOHN", i intuitively tried setting JOHN env variable. ## setting JOHN environment variable to the right directory didn't have any result, and solar explains in http://www.openwall.com/lists/john-users/2008/06/16/2 that john doesn't use any env vars. then i copied john.conf to $HOME/.john ## john.conf in $HOME/.john ``` execve("john-git/run/john", ["john-git/run/john", "testkey"], [/* 29 vars */]) = 0 mkdir("/home/rofl0r/.john", 0700) = -1 EEXIST (File exists) open("/home/rofl0r/.john/john.conf", O_RDONLY) = 3 read(3, "#\n# This file is part of John th"..., 4096) = 4096 open("/usr/share/john/dynamic_disabled.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("$JOHN/dynamic_disabled.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/share/john/best64.conf", O_RDONLY) = -1 ENOENT (No such file or directory) open("$JOHN/best64.conf", O_RDONLY) = -1 ENOENT (No such file or directory) write(2, "fopen: $JOHN/best64.conf", 24) = 24 ``` so now it failed because best64.conf was not found, so i copied *.conf into $HOME/.john. didn't help either, because the search for best64.conf doesn't even look there so imo, there are several issues here: - path search is not consistent. sometime is uses $HOME/.john, sometimes not - environment variables are ignored which is completely unintuitive since the variable is called $JOHN - path search is literally done in "$JOHN" - i.e. under some circumstances the string literal is used to search, instead of/additional to what it expands to - `dirname $(readlink -f $0)` is never tried so i would suggest john doing the following instead - maybe accept an environment variable such as JOHN_DIR - use **always** this order to search for files: 1. what JOHN_DIR env var points to 2. $HOME/.john 3. compiled in $JOHN var 4. `dirname $(readlink -f $0)` (i.e. the directory where the john binary is in) 5. `.` so it works when started from inside the john run dir
bsakaguchi 2026-10-15 04:23:48 +07:00
Author
Owner

@solardiz commented on GitHub (Aug 17, 2017):

I didn't look into this yet - I'd like someone else to look into the jumbo-specific breakage. My guess is it's fairly recent and might have to do with changing the order of initialization function calls in john.c, e.g. what magnum did on May 16.

Regarding "v. . so it works when started from inside the john run dir": NAK, we must not access any non-user-specified files from the current directory, for security reasons. The "so it works when started from inside the john run dir" objective should be achieved through using the basename, which becomes . or empty in a ./john invocation. This is how it used to work.

Regarding other proposed changes, we may discuss those once the jumbo-specific breakage is fixed, so that any adjustments would be relative to the behavior intended so far.

<!-- gh-comment-id:323103234 --> @solardiz commented on GitHub (Aug 17, 2017): I didn't look into this yet - I'd like someone else to look into the jumbo-specific breakage. My guess is it's fairly recent and might have to do with changing the order of initialization function calls in `john.c`, e.g. what magnum did on May 16. Regarding "v. . so it works when started from inside the john run dir": NAK, we must not access any non-user-specified files from the current directory, for security reasons. The "so it works when started from inside the john run dir" objective should be achieved through using the basename, which becomes `.` or empty in a `./john` invocation. This is how it used to work. Regarding other proposed changes, we may discuss those once the jumbo-specific breakage is fixed, so that any adjustments would be relative to the behavior intended so far.
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

@rofl0r this is a system-wide build, right? And if so, exactly how did you configure/build it?
Also, please show the output of john --list=build-info.

<!-- gh-comment-id:323120370 --> @magnumripper commented on GitHub (Aug 17, 2017): @rofl0r this is a system-wide build, right? And if so, exactly how did you configure/build it? Also, please show the output of `john --list=build-info`.
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

I'm marking this as invalid/PEBCAK until proven otherwise. So sue me 😉

<!-- gh-comment-id:323121705 --> @magnumripper commented on GitHub (Aug 17, 2017): I'm marking this as invalid/PEBCAK until proven otherwise. So sue me 😉
Author
Owner

@solardiz commented on GitHub (Aug 17, 2017):

magnum, you're right - most of this looks like PEBCAK to me. A system-wide build isn't supposed to look for the config file where the john binary is located. I missed that at first. @rofl0r, why are you even making a system-wide build if you have such expectations from it? You should probably continue with default (non-system-wide) builds if you want them to read the config file where john is.

However, some of the behavior reported here does in fact look wrong to me: we shouldn't be literally accessing paths starting with ~/ and $JOHN/. So labeling this entire issue PEBCAK feels wrong to me.

<!-- gh-comment-id:323124278 --> @solardiz commented on GitHub (Aug 17, 2017): magnum, you're right - most of this looks like PEBCAK to me. A system-wide build isn't supposed to look for the config file where the `john` binary is located. I missed that at first. @rofl0r, why are you even making a system-wide build if you have such expectations from it? You should probably continue with default (non-system-wide) builds if you want them to read the config file where `john` is. However, some of the behavior reported here does in fact look wrong to me: we shouldn't be literally accessing paths starting with `~/` and `$JOHN/`. So labeling this entire issue PEBCAK feels wrong to me.
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

solar explains in http://www.openwall.com/lists/john-users/2008/06/16/2 that john doesn't use any env vars.

Jumbo, and nine years later, use environment variables for various things but the only thing that should affect this issue at all is it allows $HOME to override users' home directory (closing #1901).

<!-- gh-comment-id:323125012 --> @magnumripper commented on GitHub (Aug 17, 2017): > solar explains in http://www.openwall.com/lists/john-users/2008/06/16/2 that john doesn't use any env vars. Jumbo, and nine years later, use environment variables for various things but the only thing that should affect this issue at all is it allows `$HOME` to override users' home directory (closing #1901).
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

It may be a bug, but I'm not calling it that until I know how it was configured and built. And what the $HOME environment was defined as, if defined at all.

<!-- gh-comment-id:323125539 --> @magnumripper commented on GitHub (Aug 17, 2017): It **may** be a bug, but I'm not calling it that until I know how it was configured and built. And what the `$HOME` environment was defined as, if defined at all.
Author
Owner

@rofl0r commented on GitHub (Aug 17, 2017):

this is not a system-wide build. i just ran ./configure and make

EDIT: actually i ran ./configure --prefix=/usr, but i doubt that should make a difference, and if it does that's a bug imo

<!-- gh-comment-id:323131865 --> @rofl0r commented on GitHub (Aug 17, 2017): this is not a system-wide build. i just ran ./configure and make EDIT: actually i ran ./configure --prefix=/usr, but i doubt that should make a difference, and if it does that's a bug imo
Author
Owner

@rofl0r commented on GitHub (Aug 17, 2017):

$ john-git/run/john --list=build-info
Version: 1.8.0-jumbo-1-5794-g648b13f
Build: linux-gnu 64-bit AVX-ac OMP
SIMD: AVX, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1
System-wide exec: /usr/bin
System-wide home: /usr/share/john
Private home: ~/.john
$JOHN is /usr/share/john/
Format interface version: 14
Max. number of reported tunable costs: 3
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
Max. Markov mode level: 400
Max. Markov mode password length: 30
gcc version: 4.4.7
GNU libc version: 2.12 (loaded: 2.12)
OpenCL headers version: 1.2
Crypto library: OpenSSL
OpenSSL library version: 01000105f
OpenSSL 1.0.1e-fips 11 Feb 2013
GMP library version: 4.3.1
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's
<!-- gh-comment-id:323132281 --> @rofl0r commented on GitHub (Aug 17, 2017): ``` $ john-git/run/john --list=build-info Version: 1.8.0-jumbo-1-5794-g648b13f Build: linux-gnu 64-bit AVX-ac OMP SIMD: AVX, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1 System-wide exec: /usr/bin System-wide home: /usr/share/john Private home: ~/.john $JOHN is /usr/share/john/ Format interface version: 14 Max. number of reported tunable costs: 3 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 Max. Markov mode level: 400 Max. Markov mode password length: 30 gcc version: 4.4.7 GNU libc version: 2.12 (loaded: 2.12) OpenCL headers version: 1.2 Crypto library: OpenSSL OpenSSL library version: 01000105f OpenSSL 1.0.1e-fips 11 Feb 2013 GMP library version: 4.3.1 File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's ```
Author
Owner

@rofl0r commented on GitHub (Aug 17, 2017):

My guess is it's fairly recent and might have to do with changing the order of initialization function calls in john.c, e.g. what magnum did on May 16.

i was using revision d1daf24a41 earlier and it exposed the same problem

<!-- gh-comment-id:323133097 --> @rofl0r commented on GitHub (Aug 17, 2017): > My guess is it's fairly recent and might have to do with changing the order of initialization function calls in john.c, e.g. what magnum did on May 16. i was using revision d1daf24a41ec8a0236dc00dfecba7d57fb99a6a9 earlier and it exposed the same problem
Author
Owner

@ghost commented on GitHub (Aug 17, 2017):

You are using a system-wide build. The --prefix=/usr is the one to blame.

System-wide exec: /usr/bin
System-wide home: /usr/share/john
Private home: ~/.john
$JOHN is /usr/share/john/
<!-- gh-comment-id:323147785 --> @ghost commented on GitHub (Aug 17, 2017): You are using a system-wide build. The `--prefix=/usr` is the one to blame. ``` System-wide exec: /usr/bin System-wide home: /usr/share/john Private home: ~/.john $JOHN is /usr/share/john/ ```
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

Oh, @claudioandre is right. IIRC there are certain properties of autoconf that we simply can't disable or turn off. The "best thing I could do" with --prefix (well it seemed like a good idea at the time) was having it imply systemwide. Sorry for the inconvenience.

Not quite sure how to handle this other than to warn about it and/or document better.

<!-- gh-comment-id:323150923 --> @magnumripper commented on GitHub (Aug 17, 2017): Oh, @claudioandre is right. IIRC there are certain properties of autoconf that we simply can't disable or turn off. The "best thing I could do" with `--prefix` (well it seemed like a good idea at the time) was having it imply systemwide. Sorry for the inconvenience. Not quite sure how to handle this other than to warn about it and/or document better.
Author
Owner

@magnumripper commented on GitHub (Aug 17, 2017):

--prefix is completely irrelevant for a normal (not systemwide) build, due to how legacy JtR is designed.

<!-- gh-comment-id:323151612 --> @magnumripper commented on GitHub (Aug 17, 2017): `--prefix` is completely irrelevant for a normal (not systemwide) build, due to how legacy JtR is designed.
Author
Owner

@rofl0r commented on GitHub (Aug 17, 2017):

well tbh i don't really see a point in having this systemwide distinction anyway.
maybe it's time to get rid of it ?
it could just as well always behave as i outlined above, so it would work for anyone.

<!-- gh-comment-id:323152444 --> @rofl0r commented on GitHub (Aug 17, 2017): well tbh i don't really see a point in having this systemwide distinction anyway. maybe it's time to get rid of it ? it could just as well always behave as i outlined above, so it would work for anyone.
Author
Owner

@magnumripper commented on GitHub (Aug 23, 2017):

I think you miss a few problems with your suggested scheme (such as how to implement it IRL in a portable way).

<!-- gh-comment-id:324313386 --> @magnumripper commented on GitHub (Aug 23, 2017): I think you miss a few problems with your suggested scheme (such as how to implement it IRL in a portable way).
Author
Owner

@rofl0r commented on GitHub (Aug 23, 2017):

how so ? i don't see anything unportable in my scheme.
i don't think you should close this issue without further discussion.
the distinction between systemwide and non-systemwide install seems completely arbitrary to me.
also there are several related issues i mentioned, that will just be forgotten when this stays closed (such as that $HOME/.john is only being seeked for john.conf, but not for best64.conf)

<!-- gh-comment-id:324342392 --> @rofl0r commented on GitHub (Aug 23, 2017): how so ? i don't see anything unportable in my scheme. i don't think you should close this issue without further discussion. the distinction between systemwide and non-systemwide install seems completely arbitrary to me. also there are several related issues i mentioned, that will just be forgotten when this stays closed (such as that $HOME/.john is only being seeked for john.conf, but not for best64.conf)
Author
Owner

@magnumripper commented on GitHub (Aug 23, 2017):

Nothing stops us from discussing further.

so i would suggest john doing the following instead

  • maybe accept an environment variable such as JOHN_DIR
  • use always this order to search for files:
    1. what JOHN_DIR env var points to
    2. $HOME/.john
    3. compiled in $JOHN var
    4. dirname $(readlink -f $0) (i.e. the directory where the john binary is in)
    5. . so it works when started from inside the john run dir
  1. What do you mean "compiled in $JOHN var"? I can't make any sense of that.

  2. You suggest using dirname $(readlink -f $0). Can you elaborate on that? JtR is written in C and must be portable. What you wrote looks more like shell code and isn't even portable at that.

Specifically, if we drop the notion of SYSTEMWIDE, place john somewhere in the path and run it from some arbitrary CWD, argv[0] is just john and the running process has no idea where that binary was actually located (so can't define $JOHN). Sure, you can find out under various OS's. But as far as I know there is no portable way to do it.

<!-- gh-comment-id:324382900 --> @magnumripper commented on GitHub (Aug 23, 2017): Nothing stops us from discussing further. > so i would suggest john doing the following instead > - maybe accept an environment variable such as JOHN_DIR > - use **always** this order to search for files: > 1. what JOHN_DIR env var points to > 2. $HOME/.john > 3. compiled in $JOHN var > 4. `dirname $(readlink -f $0)` (i.e. the directory where the john binary is in) > 5. `.` so it works when started from inside the john run dir 1. What do you mean "compiled in $JOHN var"? I can't make any sense of that. 2. You suggest using `dirname $(readlink -f $0)`. Can you elaborate on that? JtR is written in C and must be portable. What you wrote looks more like shell code and isn't even portable at that. Specifically, if we drop the notion of SYSTEMWIDE, place `john` somewhere in the path and run it from some arbitrary CWD, argv[0] is just `john` and the running process has no idea where that binary was actually located (so can't define $JOHN). Sure, you can find out under various OS's. But as far as I know there is no portable way to do it.
Author
Owner

@magnumripper commented on GitHub (Aug 24, 2017):

The reason .include <best64.conf> doesn't search $HOME/.john is intended. (...)

<!-- gh-comment-id:324547978 --> @magnumripper commented on GitHub (Aug 24, 2017): ~~The reason `.include <best64.conf>` doesn't search `$HOME/.john` is intended. (...)~~
Author
Owner

@magnumripper commented on GitHub (Aug 24, 2017):

Scrap what I just wrote. Here's the deal: .include <best64.h> will only search $JOHN while .include "best64.h" would have also tried current directory.

I agree that (given SYSTEMWIDE) ~/.john should have been searched though. I will look into that.

<!-- gh-comment-id:324551437 --> @magnumripper commented on GitHub (Aug 24, 2017): Scrap what I just wrote. Here's the deal: `.include <best64.h>` will only search `$JOHN` while `.include "best64.h"` would have also tried current directory. I agree that (given SYSTEMWIDE) `~/.john` should have been searched though. I will look into that.
Author
Owner

@rofl0r commented on GitHub (Aug 24, 2017):

hi, with "compiled-in $JOHN var" i mean the value of $JOHN, which is hardcoded into the binary at compile-time. it corresponds to JOHN_SYSTEMWIDE_HOME in params.h.

you are right, dirname $(readlink -f $0) is a shell command. i used it to illustrate the intent, not the exact code, since it's a bit more elaborate in C.

what it boils down to is that one uses the standard POSIX function readlink() (man 3p readlink) on argv[0] and then extracts the parts before the last slash to retrieve the directory name where the john binary resides. even if there are exotic systems that don't have readlink(), now that you have a configure script it's trivial to make a compile check to see if it can be used. if not, its usage can just be omitted.

<!-- gh-comment-id:324612699 --> @rofl0r commented on GitHub (Aug 24, 2017): hi, with "compiled-in $JOHN var" i mean the value of $JOHN, which is hardcoded into the binary at compile-time. it corresponds to `JOHN_SYSTEMWIDE_HOME` in params.h. you are right, `dirname $(readlink -f $0)` is a shell command. i used it to illustrate the intent, not the exact code, since it's a bit more elaborate in C. what it boils down to is that one uses the standard POSIX function `readlink()` (man 3p readlink) on argv[0] and then extracts the parts before the last slash to retrieve the directory name where the john binary resides. even if there are exotic systems that don't have readlink(), now that you have a configure script it's trivial to make a compile check to see if it can be used. if not, its usage can just be omitted.
Author
Owner

@rofl0r commented on GitHub (Aug 24, 2017):

.include <best64.h> will only search $JOHN while .include "best64.h" would have also tried current directory.

interesting, i didn't realize that there are 2 different ways to use .include. since the default john.conf assumes the files it includes to be in the same directory, would it make sense to use .include "xxx" instead of .include <xxx> directly in john.conf ?

<!-- gh-comment-id:324613727 --> @rofl0r commented on GitHub (Aug 24, 2017): > .include <best64.h> will only search $JOHN while .include "best64.h" would have also tried current directory. interesting, i didn't realize that there are 2 different ways to use `.include`. since the default john.conf assumes the files it includes to be in the same directory, would it make sense to use `.include "xxx"` instead of `.include <xxx>` directly in john.conf ?
Author
Owner

@magnumripper commented on GitHub (Aug 24, 2017):

hi, with "compiled-in $JOHN var" i mean the value of $JOHN, which is hardcoded into the binary at compile-time. it corresponds to JOHN_SYSTEMWIDE_HOME in params.h.

This is how a "systemwide" build works. You wanted us to ditch that idea.

what it boils down to is that one uses the standard POSIX function readlink() (man 3p readlink) on argv[0] and then extracts the parts before the last slash to retrieve the directory name where the john binary resides. even if there are exotic systems that don't have readlink(), now that you have a configure script it's trivial to make a compile check to see if it can be used. if not, its usage can just be omitted.

This is how a "non-systemwide" build works. This is hard to combine with the above. Again, the problem is that if you go by $PATH you just typed john with no path at all. So argv[0] will be just that, there's no information to gain from **argv at all. There's no slash to look for.

SYSTEMWIDE exists precisely because it's hard or "impossible" to combine the two approaches.

<!-- gh-comment-id:324715063 --> @magnumripper commented on GitHub (Aug 24, 2017): > hi, with "compiled-in $JOHN var" i mean the value of $JOHN, which is hardcoded into the binary at compile-time. it corresponds to `JOHN_SYSTEMWIDE_HOME` in params.h. This is how a "systemwide" build works. You wanted us to ditch that idea. > what it boils down to is that one uses the standard POSIX function `readlink()` (man 3p readlink) on argv[0] and then extracts the parts before the last slash to retrieve the directory name where the john binary resides. even if there are exotic systems that don't have readlink(), now that you have a configure script it's trivial to make a compile check to see if it can be used. if not, its usage can just be omitted. This is how a "non-systemwide" build works. This is hard to combine with the above. Again, the problem is that if you go by `$PATH` you just typed `john` with no path at all. So `argv[0]` will be just that, there's no information to gain from `**argv` at all. There's no slash to look for. SYSTEMWIDE exists precisely because it's hard or "impossible" to combine the two approaches.
Author
Owner

@magnumripper commented on GitHub (Aug 24, 2017):

.include <best64.h> will only search $JOHN while .include "best64.h" would have also tried current directory.

interesting, i didn't realize that there are 2 different ways to use .include.

It gets better, or worse. There's a third syntax .include 'xxx' that works just like .include "xxx" except the former doesn't treat a missing file as an error. I had no idea until today when I looked at the code.

since the default john.conf assumes the files it includes to be in the same directory, would it make sense to use .include "xxx" instead of .include <xxx> directly in john.conf ?

I see no reason to do that change in this repo, but nothing stops you from doing so at your end.

<!-- gh-comment-id:324716384 --> @magnumripper commented on GitHub (Aug 24, 2017): >> .include <best64.h> will only search $JOHN while .include "best64.h" would have also tried current directory. > > interesting, i didn't realize that there are 2 different ways to use `.include`. It gets better, or worse. There's a third syntax `.include 'xxx'` that works just like `.include "xxx"` except the former doesn't treat a missing file as an error. I had no idea until today when I looked at the code. > since the default john.conf assumes the files it includes to be in the same directory, would it make sense to use `.include "xxx"` instead of `.include <xxx>` directly in john.conf ? I see no reason to do that change in this repo, but nothing stops you from doing so at your end.
Author
Owner

@frank-dittrich commented on GitHub (Aug 24, 2017):

It gets better, or worse. There's a third syntax .include 'xxx' that works just like .include "xxx" except the former doesn't treat a missing file as an error. I had no idea until today when I looked at the code.

I think that code has been added when the mandatory john.local.conf has been dropped.

<!-- gh-comment-id:324729789 --> @frank-dittrich commented on GitHub (Aug 24, 2017): > It gets better, or worse. There's a third syntax .include 'xxx' that works just like .include "xxx" except the former doesn't treat a missing file as an error. I had no idea until today when I looked at the code. I think that code has been added when the mandatory john.local.conf has been dropped.
Author
Owner

@magnumripper commented on GitHub (Aug 24, 2017):

I agree that (given SYSTEMWIDE) ~/.john should have been searched though. I will look into that.

As far as I can see, everything works as intended: After john.conf was found, the others (sourced with .include <...>) are assumed to be located in the same place. We can discuss changing intentions but that'd be an aother issue.

<!-- gh-comment-id:324753397 --> @magnumripper commented on GitHub (Aug 24, 2017): > I agree that (given SYSTEMWIDE) `~/.john` should have been searched though. I will look into that. As far as I can see, everything works as intended: After john.conf was found, the others (sourced with `.include <...>`) are assumed to be located in the same place. We can discuss changing intentions but that'd be an aother issue.
Author
Owner

@rofl0r commented on GitHub (Aug 24, 2017):

This is how a "systemwide" build works. You wanted us to ditch that idea.

not exactly. i wanted to ditch the gratuitous distinction between system-wide and non-system-wide.
it makes sense to always fall back to a system-wide dir (the current default for it is good), if the files cannot be found in either the users homedir or the current dir derived with my readlink -f emulation:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>


int readlink_f(char* in, char* out) {
        if(realpath(in, out)) return 0;

        char path[PATH_MAX], buf[PATH_MAX], *pth, *p;
        if(!(pth = getenv("PATH"))) return -1;
        snprintf(path, sizeof path, "%s", pth);
        p = strtok(path, ":");
        do {
                if(!p) break;
                snprintf(buf, sizeof buf, "%s/%s", p, in);
                if(realpath(buf, out)) return 0;
        } while((p = strtok((char*)0, ":")));
        return -1;
}

int main(int argc, char**argv) {
        char buf[PATH_MAX];
        int ret = readlink_f(argv[0], buf);
        if(ret == -1) return 1;
        printf("%s\n", buf);
        return 0;

}

SYSTEMWIDE exists precisely because it's hard or "impossible" to combine the two approaches.

it's neither impossible nor hard, it's just a matter of defining the search directory order.

<!-- gh-comment-id:324773330 --> @rofl0r commented on GitHub (Aug 24, 2017): > This is how a "systemwide" build works. You wanted us to ditch that idea. not exactly. i wanted to ditch the gratuitous distinction between system-wide and non-system-wide. it makes sense to always fall back to a system-wide dir (the current default for it is good), if the files cannot be found in either the users homedir or the current dir derived with my `readlink -f` emulation: ```c #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <limits.h> int readlink_f(char* in, char* out) { if(realpath(in, out)) return 0; char path[PATH_MAX], buf[PATH_MAX], *pth, *p; if(!(pth = getenv("PATH"))) return -1; snprintf(path, sizeof path, "%s", pth); p = strtok(path, ":"); do { if(!p) break; snprintf(buf, sizeof buf, "%s/%s", p, in); if(realpath(buf, out)) return 0; } while((p = strtok((char*)0, ":"))); return -1; } int main(int argc, char**argv) { char buf[PATH_MAX]; int ret = readlink_f(argv[0], buf); if(ret == -1) return 1; printf("%s\n", buf); return 0; } ``` > SYSTEMWIDE exists precisely because it's hard or "impossible" to combine the two approaches. it's neither impossible nor hard, it's just a matter of defining the search directory order.
Author
Owner

@secf00tprint commented on GitHub (Jul 20, 2020):

Just some little help for those who have downloaded John the Ripper Jumbo (https://www.openwall.com/john/k/john-1.9.0-jumbo-1.tar.gz, 20.07.2020) from the homepage) as tar.gz.
There I had the same effect that it can't find john even if you build it with: ./configure; make -s clean && make -sj4.

So my solution was (running Ubuntu 20.04):

  1. Clone this repo here:
    git clone https://github.com/magnumripper/JohnTheRipper.git

  2. Build it:
    cd JohnTheRipper/src; ./configure; make -s clean && make -sj4

  3. Set a Path Variable (put this in your ~/.bashrc or ~/.zshrc file to make it permanent) with:
    absolute_path_to_john_the_ripper_jumbo_github_repo

 # John the Ripper
 export PATH="$PATH:/absolute_path_to_john_the_ripper_jumbo_github_repo/run/"

eg.

 export PATH="$PATH:/home/me/JohnTheRipper/run/"
  1. Set an alias (likewise in your ~/.bashrc or ~/.zshrc file) with:
alias john=absolute_path_to_john_the_ripper_jumbo_github_repo/run/john

eg.

alias john=/home/me/JohnTheRipper/run/john

After that it should work in other directories too.

Further information to my environment:

➜  src git:(bleeding-jumbo) ✗ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04 LTS
Release:	20.04
Codename:	focal
➜  src git:(bleeding-jumbo) ✗ git config --get remote.origin.url                                 
https://github.com/magnumripper/JohnTheRipper.git
➜  src git:(bleeding-jumbo) ✗ john --list=build-info                                     
Version: 1.9.0-jumbo-1+bleeding-2778d2e9d 2020-06-17 16:09:24 +0200
Build: linux-gnu 64-bit x86_64 AVX2 AC OMP
SIMD: AVX2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1
CPU tests: AVX2
$JOHN is /home/phoot1if/code/security/credentials/JohnTheRipper/run/
Format interface version: 14
Max. number of reported tunable costs: 4
Rec file version: REC4
Charset file version: CHR3
CHARSET_MIN: 1 (0x01)
CHARSET_MAX: 255 (0xff)
CHARSET_LENGTH: 24
SALT_HASH_SIZE: 1048576
SINGLE_IDX_MAX: 32768
SINGLE_BUF_MAX: 4294967295
Effective limit: Max. KPC 32768
Max. Markov mode level: 400
Max. Markov mode password length: 30
gcc version: 9.3.0
GNU libc version: 2.31 (loaded: 2.31)
Crypto library: OpenSSL
OpenSSL library version: 01010106f
OpenSSL 1.1.1f  31 Mar 2020
GMP library version: 6.2.0
File locking: fcntl()
fseek(): fseek
ftell(): ftell
fopen(): fopen
memmem(): System's
times(2) sysconf(_SC_CLK_TCK) is 100
Using times(2) for timers, resolution 10 ms
HR timer claimed resolution 1 ns, observed 39 ns
Total physical host memory: 31741 MB
Available physical host memory: 21807 MB
<!-- gh-comment-id:660902685 --> @secf00tprint commented on GitHub (Jul 20, 2020): Just some little help for those who have downloaded John the Ripper Jumbo ([https://www.openwall.com/john/k/john-1.9.0-jumbo-1.tar.gz](https://www.openwall.com/john/k/john-1.9.0-jumbo-1.tar.gz), 20.07.2020) from the [homepage](https://www.openwall.com/john/)) as tar.gz. There I had the same effect that it can't find john even if you build it with: `./configure; make -s clean && make -sj4`. So my solution was (running Ubuntu 20.04): 1. Clone this repo here: `git clone https://github.com/magnumripper/JohnTheRipper.git` 2. Build it: `cd JohnTheRipper/src; ./configure; make -s clean && make -sj4` 3. Set a Path Variable (put this in your `~/.bashrc` or `~/.zshrc` file to make it permanent) with: `absolute_path_to_john_the_ripper_jumbo_github_repo` ``` # John the Ripper export PATH="$PATH:/absolute_path_to_john_the_ripper_jumbo_github_repo/run/" ``` eg. ``` export PATH="$PATH:/home/me/JohnTheRipper/run/" ``` 4. Set an alias (likewise in your `~/.bashrc` or `~/.zshrc` file) with: ``` alias john=absolute_path_to_john_the_ripper_jumbo_github_repo/run/john ``` eg. ``` alias john=/home/me/JohnTheRipper/run/john ``` After that it should work in other directories too. Further information to my environment: ``` ➜ src git:(bleeding-jumbo) ✗ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal ➜ src git:(bleeding-jumbo) ✗ git config --get remote.origin.url https://github.com/magnumripper/JohnTheRipper.git ➜ src git:(bleeding-jumbo) ✗ john --list=build-info Version: 1.9.0-jumbo-1+bleeding-2778d2e9d 2020-06-17 16:09:24 +0200 Build: linux-gnu 64-bit x86_64 AVX2 AC OMP SIMD: AVX2, interleaving: MD4:3 MD5:3 SHA1:1 SHA256:1 SHA512:1 CPU tests: AVX2 $JOHN is /home/phoot1if/code/security/credentials/JohnTheRipper/run/ Format interface version: 14 Max. number of reported tunable costs: 4 Rec file version: REC4 Charset file version: CHR3 CHARSET_MIN: 1 (0x01) CHARSET_MAX: 255 (0xff) CHARSET_LENGTH: 24 SALT_HASH_SIZE: 1048576 SINGLE_IDX_MAX: 32768 SINGLE_BUF_MAX: 4294967295 Effective limit: Max. KPC 32768 Max. Markov mode level: 400 Max. Markov mode password length: 30 gcc version: 9.3.0 GNU libc version: 2.31 (loaded: 2.31) Crypto library: OpenSSL OpenSSL library version: 01010106f OpenSSL 1.1.1f 31 Mar 2020 GMP library version: 6.2.0 File locking: fcntl() fseek(): fseek ftell(): ftell fopen(): fopen memmem(): System's times(2) sysconf(_SC_CLK_TCK) is 100 Using times(2) for timers, resolution 10 ms HR timer claimed resolution 1 ns, observed 39 ns Total physical host memory: 31741 MB Available physical host memory: 21807 MB ```
Author
Owner

@solardiz commented on GitHub (Jul 20, 2020):

Hi @secf00tprint. I appreciate you trying to help others, but your advice is partially wrong. We explicitly do not support invocation of non-systemwide builds via the PATH environment variable, and we strongly recommend that it not be set. So step 3 in your instructions should be skipped.

Step 4 is what helps (if the user insists on running john when not in the run directory and not specifying a path to it), but it misses the final john program name in the example, should be:

alias john=/home/me/JohnTheRipper/run/john

Normally, people simply cd to the run directory and run ./john or alternatively they type a full or a relative path to there (e.g. ~/john/run/john). I understand that it may be handy to also be able to use just john from anywhere, for which alias helps, but PATH does not.

<!-- gh-comment-id:660963147 --> @solardiz commented on GitHub (Jul 20, 2020): Hi @secf00tprint. I appreciate you trying to help others, but your advice is partially wrong. We explicitly do _not_ support invocation of non-systemwide builds via the `PATH` environment variable, and we strongly recommend that it not be set. So step 3 in your instructions should be skipped. Step 4 is what helps (_if_ the user insists on running `john` when not in the `run` directory and not specifying a path to it), but it misses the final `john` program name in the example, should be: ``` alias john=/home/me/JohnTheRipper/run/john ``` Normally, people simply `cd` to the `run` directory and run `./john` or alternatively they type a full or a relative path to there (e.g. `~/john/run/john`). I understand that it may be handy to also be able to use just `john` from anywhere, for which `alias` helps, but `PATH` does not.
Author
Owner

@secf00tprint commented on GitHub (Jul 21, 2020):

Yes, you're right I missed john at the end and corrected it.

I understand that it may be handy to also be able to use just john from anywhere, for which alias helps, but PATH does not.

Then you cannot use all the other binaries in the run folder (e.g. zip2john).

For me to be enforced to go to the run folder was really confusing.

<!-- gh-comment-id:661806955 --> @secf00tprint commented on GitHub (Jul 21, 2020): Yes, you're right I missed john at the end and corrected it. > I understand that it may be handy to also be able to use just john from anywhere, for which alias helps, but PATH does not. Then you cannot use all the other binaries in the `run` folder (e.g. `zip2john`). For me to be enforced to go to the run folder was really confusing.
Author
Owner

@solardiz commented on GitHub (Jul 21, 2020):

The problem is john and some of its other programs need to somehow find the rest of the files that they use, such as john.conf. Currently, for non-systemwide builds they extract the right directory pathname (maybe relative) from the invocation program name. When you use an alias, that directory pathname is right in there. When you use PATH, it is not. So some programs fail when invoked via PATH.

For systemwide builds, the installation location gets hard-coded into the binaries, so they may be invoked via PATH fine. However, this is currently only meant for use by distros' packages, not by end-users doing their own builds.

<!-- gh-comment-id:661819410 --> @solardiz commented on GitHub (Jul 21, 2020): The problem is `john` and some of its other programs need to somehow find the rest of the files that they use, such as `john.conf`. Currently, for non-systemwide builds they extract the right directory pathname (maybe relative) from the invocation program name. When you use an `alias`, that directory pathname is right in there. When you use `PATH`, it is not. So some programs fail when invoked via `PATH`. For systemwide builds, the installation location gets hard-coded into the binaries, so they may be invoked via `PATH` fine. However, this is currently only meant for use by distros' packages, not by end-users doing their own builds.
Author
Owner

@secf00tprint commented on GitHub (Jul 21, 2020):

Interesting. Thanks for the information. Is there a possibility to add free distro packages to https://www.openwall.com/john/ so it works out of the box?

<!-- gh-comment-id:661839285 --> @secf00tprint commented on GitHub (Jul 21, 2020): Interesting. Thanks for the information. Is there a possibility to add free distro packages to [https://www.openwall.com/john/](https://www.openwall.com/john/) so it works out of the box?
Author
Owner

@ghost commented on GitHub (Jul 21, 2020):

I also found the information interesting. I don't like using systemwyde builds, but (since) they are required, I can live with that.

<!-- gh-comment-id:661862584 --> @ghost commented on GitHub (Jul 21, 2020): I also found the information interesting. I don't like using systemwyde builds, but (since) they are required, I can live with that.
Author
Owner

@solardiz commented on GitHub (Jul 21, 2020):

Many distros include packages of john, e.g. some are listed in https://linuxconfig.org/password-cracking-with-john-the-ripper-on-linux (maybe need to add this URL to the tutorials list on the wiki).

I think we need to look into what exactly our --prefix option to configure does in jumbo. Ideally, it'd work the same it works with other typical software, where it can be used to install into e.g. /home/user/app and set PATH to inside there, and things will work. That will also mean we'd finally need to add make install.

<!-- gh-comment-id:661877629 --> @solardiz commented on GitHub (Jul 21, 2020): Many distros include packages of `john`, e.g. some are listed in https://linuxconfig.org/password-cracking-with-john-the-ripper-on-linux (maybe need to add this URL to the tutorials list on the wiki). I think we need to look into what exactly our `--prefix` option to `configure` does in jumbo. Ideally, it'd work the same it works with other typical software, where it can be used to install into e.g. `/home/user/app` and set `PATH` to inside there, and things will work. That will also mean we'd finally need to add `make install`.
Author
Owner

@solardiz commented on GitHub (Jul 21, 2020):

Claudio, I don't understand what you mean by systemwide builds being "required". Personally, I am comfortable using non-systemwide builds - I just don't expect them to work along with PATH.

Edit: created #4281 for adding proper "make install".

<!-- gh-comment-id:661951475 --> @solardiz commented on GitHub (Jul 21, 2020): Claudio, I don't understand what you mean by systemwide builds being "required". Personally, I am comfortable using non-systemwide builds - I just don't expect them to work along with `PATH`. Edit: created #4281 for adding proper "make install".
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1735
No description provided.