[GH-ISSUE #982] params.h systemwide #580

Closed
opened 2026-10-14 03:14:09 +07:00 by bsakaguchi · 17 comments
Owner

Originally created by @DomT4 on GitHub (Dec 31, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/982

Originally assigned to: @magnumripper on GitHub.

Hey guys,

Apologies in advance, this is technically a very old issue. I'm not sure if anyone has previously flagged this up to you. A scan of the Github issues search didn't reveal anything, but I may well have missed something there, and given the age of the issue it could well have been flagged on a mailing list somewhere.

For the last several years both MacPorts and Homebrew have been patching the params.h file to match our respective desired JOHN_SYSTEMWIDE_EXEC and JOHN_SYSTEMWIDE_HOME locations.

The file itself explicitly says "do not patch me", but everyone has been doing so regardless. Trying to pass directories to the configuration with flags, which the document recommends, seems to run into fatal build errors:

make -s CFLAGS='-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=#{foo}'
In file included from ./formats.h:./params.h:86:5:15 :
error: token is not a valid binary operator in a preprocessor subexpression
./params.h:86:5: error: token is not a valid binary operator in a preprocessor subexpression
#if JOHN_SYSTEMWIDE
    ^~~~~~~~~~~~~~~
#if JOHN_SYSTEMWIDE
    ^~~~~~~~~~~~~~~
<command line>:1:49: <command line>note:: 1expanded from here:
49: note: expanded from here
#define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share
                           ~~~~~~~~~~~~~~~~~~~~~^
#define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share
                           ~~~~~~~~~~~~~~~~~~~~~^
In file included from DES_fmt.c:16:
In file included from ./formats.h:15:
./params.h:In file included from jumbo.c:25:
./params.h:145:5: error: 145token is not a valid binary operator in a preprocessor subexpression:
5: error: token is not a valid binary operator in a preprocessor subexpression
#if JOHN_SYSTEMWIDE
    ^~~~~~~~~~~~~~~
#if JOHN_SYSTEMWIDE
    ^~~~~~~~~~~~~~~<command line>
:1:49<command line>:: 1note: expanded from here
:49: note: expanded from here
#define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share
                           ~~~~~~~~~~~~~~~~~~~~~^
#define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share
                           ~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.
make[1]: *** [jumbo.o] Error 1
make[1]: *** Waiting for unfinished jobs....
2 errors generated.
make[1]: *** [DES_fmt.o] Error 1
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [john-mpi.o] Error 1
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [DES_std.o] Error 1
make: *** [default] Error 2

Are we all missing something obvious, or is this a bug upstream here can fix on the accepting flags? Thanks!

Originally created by @DomT4 on GitHub (Dec 31, 2014). Original GitHub issue: https://github.com/openwall/john/issues/982 Originally assigned to: @magnumripper on GitHub. Hey guys, Apologies in advance, this is technically a very old issue. I'm not sure if anyone has previously flagged this up to you. A scan of the Github issues search didn't reveal anything, but I may well have missed something there, and given the age of the issue it could well have been flagged on a mailing list somewhere. For the last several _years_ both MacPorts and Homebrew have been patching the `params.h` file to match our respective desired `JOHN_SYSTEMWIDE_EXEC` and `JOHN_SYSTEMWIDE_HOME` locations. The file itself explicitly says _"do not patch me"_, but everyone has been doing so regardless. Trying to pass directories to the configuration with flags, which the document recommends, seems to run into fatal build errors: ``` make -s CFLAGS='-DJOHN_SYSTEMWIDE=1 -DJOHN_SYSTEMWIDE_EXEC=#{foo}' ``` ``` In file included from ./formats.h:./params.h:86:5:15 : error: token is not a valid binary operator in a preprocessor subexpression ./params.h:86:5: error: token is not a valid binary operator in a preprocessor subexpression #if JOHN_SYSTEMWIDE ^~~~~~~~~~~~~~~ #if JOHN_SYSTEMWIDE ^~~~~~~~~~~~~~~ <command line>:1:49: <command line>note:: 1expanded from here: 49: note: expanded from here #define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share ~~~~~~~~~~~~~~~~~~~~~^ #define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share ~~~~~~~~~~~~~~~~~~~~~^ In file included from DES_fmt.c:16: In file included from ./formats.h:15: ./params.h:In file included from jumbo.c:25: ./params.h:145:5: error: 145token is not a valid binary operator in a preprocessor subexpression: 5: error: token is not a valid binary operator in a preprocessor subexpression #if JOHN_SYSTEMWIDE ^~~~~~~~~~~~~~~ #if JOHN_SYSTEMWIDE ^~~~~~~~~~~~~~~<command line> :1:49<command line>:: 1note: expanded from here :49: note: expanded from here #define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share ~~~~~~~~~~~~~~~~~~~~~^ #define JOHN_SYSTEMWIDE 1 -DJOHN_SYSTEMWIDE_EXEC=/usr/local/Cellar/john-jumbo/1.8.0_j1/share ~~~~~~~~~~~~~~~~~~~~~^ 2 errors generated. make[1]: *** [jumbo.o] Error 1 make[1]: *** Waiting for unfinished jobs.... 2 errors generated. make[1]: *** [DES_fmt.o] Error 1 Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [john-mpi.o] Error 1 Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [DES_std.o] Error 1 make: *** [default] Error 2 ``` Are we all missing something obvious, or is this a bug upstream here can fix on the accepting flags? Thanks!
bsakaguchi 2026-10-14 03:14:09 +07:00
Author
Owner

@magnumripper commented on GitHub (Jan 1, 2015):

I will look into this. The first question is whether "core John" has the same problem.

<!-- gh-comment-id:68485026 --> @magnumripper commented on GitHub (Jan 1, 2015): I will look into this. The first question is whether "core John" has the same problem.
Author
Owner

@frank-dittrich commented on GitHub (Jan 1, 2015):

In jumbo, we could add an autoconf option for this.

<!-- gh-comment-id:68485047 --> @frank-dittrich commented on GitHub (Jan 1, 2015): In jumbo, we could add an autoconf option for this.
Author
Owner

@magnumripper commented on GitHub (Jan 1, 2015):

We should support the standard stuff eg. --prefix=/usr/local/bin and have them set the needed macros. But some tweaks are very likely needed for AC vs systemwide.

<!-- gh-comment-id:68485169 --> @magnumripper commented on GitHub (Jan 1, 2015): We should support the standard stuff eg. `--prefix=/usr/local/bin` and have them set the needed macros. But some tweaks are very likely needed for AC vs systemwide.
Author
Owner

@jfoug commented on GitHub (Jan 1, 2015):

This brings up the bigger issue of getting the autoconf actually INSTALL john properly.

This would avoid most of the half assed work arounds that OS packagers are using to get john properly installed on their flavor. All they should need to do is set --prefix and then make install should do it. BUT I do not think we are at that level yet.

<!-- gh-comment-id:68490370 --> @jfoug commented on GitHub (Jan 1, 2015): This brings up the bigger issue of getting the autoconf actually INSTALL john properly. This would avoid most of the half assed work arounds that OS packagers are using to get john properly installed on their flavor. All they should need to do is set --prefix and then make install should do it. BUT I do not think we are at that level yet.
Author
Owner

@DomT4 commented on GitHub (Jan 1, 2015):

The first question is whether "core John" has the same problem.

Yeah, it does. The exact same patch has been applied to John without the Jumbo for years as well.

This brings up the bigger issue of getting the autoconf actually INSTALL john properly.

The autoconf process is already a lot less cumbersome for package managers to deal with than the regular John make process FWIW. Makes life a lot easier. Certainly, being able to actively specify a prefix would be great though.

<!-- gh-comment-id:68494974 --> @DomT4 commented on GitHub (Jan 1, 2015): > The first question is whether "core John" has the same problem. Yeah, it does. The exact same patch has been applied to `John` without the Jumbo for years as well. > This brings up the bigger issue of getting the autoconf actually INSTALL john properly. The autoconf process is already a lot less cumbersome for package managers to deal with than the regular John make process FWIW. Makes life a lot easier. Certainly, being able to actively specify a `prefix` would be great though.
Author
Owner

@jfoug commented on GitHub (Jan 1, 2015):

You 'can' specific prefix. HOWEVER, there has to be code in place (within our Makefile.in I think), that actually USES that properly to do the install.

Problem is, that almost NONE of the developers of jtr-jumbo-autoconf (in reality, that it mostly @magnumripper and myself), do not instal john. We run it run out of the build directory since we build, build, build, build all the time. Thus, the actual proper install plumbing has not been placed into JtR.

I really think we should get this working 'properly' before J2 is released. I believe this would solve (most of) the problems seen by packagers.

That does not address core, but that is Solar's call, in keeping with the shitty fat makefile mechanics, and choosing not to progress to a proper probing tool like autoconf (or cmake or any of the other package tools).

<!-- gh-comment-id:68502178 --> @jfoug commented on GitHub (Jan 1, 2015): You 'can' specific prefix. HOWEVER, there has to be code in place (within our Makefile.in I think), that actually USES that properly to do the install. Problem is, that almost NONE of the developers of jtr-jumbo-autoconf (in reality, that it mostly @magnumripper and myself), do not instal john. We run it run out of the build directory since we build, build, build, build all the time. Thus, the actual proper install plumbing has not been placed into JtR. I really think we should get this working 'properly' before J2 is released. I believe this would solve (most of) the problems seen by packagers. That does not address core, but that is Solar's call, in keeping with the shitty fat makefile mechanics, and choosing not to progress to a proper probing tool like autoconf (or cmake or any of the other package tools).
Author
Owner

@magnumripper commented on GitHub (Jan 3, 2015):

I took a stab at properly supporting --prefix a while ago. It's not that hard. But I'm not done with it. Anyway, @DomT4 please also report this problem (in core John context for more attention) to john-users so Solar fixes the upstream issue. If he does, I promise I will have a new look at supporting --prefix

<!-- gh-comment-id:68574886 --> @magnumripper commented on GitHub (Jan 3, 2015): I took a stab at properly supporting --prefix a while ago. It's not that hard. But I'm not done with it. Anyway, @DomT4 please also report this problem (in core John context for more attention) to john-users so Solar fixes the upstream issue. If he does, I promise I will have a new look at supporting --prefix
Author
Owner

@DomT4 commented on GitHub (Jan 13, 2015):

Thanks. I just dropped an email to Solar and the Dev-list upstream, so hopefully we'll see some movement.

<!-- gh-comment-id:69682530 --> @DomT4 commented on GitHub (Jan 13, 2015): Thanks. I just dropped an email to Solar and the Dev-list upstream, so hopefully we'll see some movement.
Author
Owner

@DomT4 commented on GitHub (Jan 13, 2015):

I'm pretty sure I just got told off for reporting this upstream, I sent it to the wrong list accidentally, and I wasn't specific enough in my subject. Being told off for attempting a bug report is certainly a first, heh, but this is the reply:

Hi Dominyk,

I think your posting would have been more appropriate on the john-users
list, and a better Subject would have been e.g. "system-wide install".
You could want to do something like that for further problem reports, if
any (unrelated to this one).  Since you've already brought this up on
john-dev, let's keep this one thread in here.

On Tue, Jan 13, 2015 at 01:49:56AM +0000, Dominyk Tiller wrote:
> I've been trying to chase up this bug for a fair while now. It's not a
> new bug report by any means, It's been around for years now. You can see
> a bit of a summary on the Jumbo Github issue I created here:
> https://github.com/magnumripper/JohnTheRipper/issues/982

Basically, a lot of people who package JtR are not that experienced with
shell escaping and with C.  Maybe we need some documentation to explain
these things (even though they're not specific to JtR) or an example.

When you override a pathname with a C preprocessor macro, you need to
put the new pathname in double-quotes (to make it a valid C string), and
further you need to escape those double-quotes to pass them via the
shell.  Here's how it's been working fine for me for years:

http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/john/john.spec?rev=HEAD

I am not overriding the default JOHN_SYSTEMWIDE_EXEC here, but I am
providing CPU_FALLBACK_BINARY, which demonstrates the same issue and the
same solution that you would use for JOHN_SYSTEMWIDE_EXEC.  Here are
some of the relevant lines:

FALLBACK='\"john-avx\"'
%__make linux-x86-xop CFLAGS="%cflags -DCPU_FALLBACK=1 -DCPU_FALLBACK_BINARY='$FALLBACK'"

Alternatively, we could use the C preprocessor's stringification feature
to eliminate the need for external string quoting (but then we depend on
an extra feature for "no good reason", which might break builds on some
older/exotic systems):

https://gcc.gnu.org/onlinedocs/cpp/Stringification.html#Stringification

> Essentially, params.h has a note in it to not patch the file but use
> cflags to set JOHN_SYSTEMWIDE_EXEC, but doing so causes a fairly massive
> compile breakage:

... because you do it wrongly, which is in turn because this stuff is
non-trivial for someone who is not into shell scripting and C
programming.

> So despite the file saying not to patch it, it seems patching it is the
> only way to set the directories.

Not true.

Thank you for trying to help, and I hope this explanation helps.

Alexander
<!-- gh-comment-id:69698504 --> @DomT4 commented on GitHub (Jan 13, 2015): I'm pretty sure I just got told off for reporting this upstream, I sent it to the wrong list accidentally, and I wasn't specific enough in my subject. Being told off for attempting a bug report is certainly a first, heh, but this is the reply: ``` Hi Dominyk, I think your posting would have been more appropriate on the john-users list, and a better Subject would have been e.g. "system-wide install". You could want to do something like that for further problem reports, if any (unrelated to this one). Since you've already brought this up on john-dev, let's keep this one thread in here. On Tue, Jan 13, 2015 at 01:49:56AM +0000, Dominyk Tiller wrote: > I've been trying to chase up this bug for a fair while now. It's not a > new bug report by any means, It's been around for years now. You can see > a bit of a summary on the Jumbo Github issue I created here: > https://github.com/magnumripper/JohnTheRipper/issues/982 Basically, a lot of people who package JtR are not that experienced with shell escaping and with C. Maybe we need some documentation to explain these things (even though they're not specific to JtR) or an example. When you override a pathname with a C preprocessor macro, you need to put the new pathname in double-quotes (to make it a valid C string), and further you need to escape those double-quotes to pass them via the shell. Here's how it's been working fine for me for years: http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/john/john.spec?rev=HEAD I am not overriding the default JOHN_SYSTEMWIDE_EXEC here, but I am providing CPU_FALLBACK_BINARY, which demonstrates the same issue and the same solution that you would use for JOHN_SYSTEMWIDE_EXEC. Here are some of the relevant lines: FALLBACK='\"john-avx\"' %__make linux-x86-xop CFLAGS="%cflags -DCPU_FALLBACK=1 -DCPU_FALLBACK_BINARY='$FALLBACK'" Alternatively, we could use the C preprocessor's stringification feature to eliminate the need for external string quoting (but then we depend on an extra feature for "no good reason", which might break builds on some older/exotic systems): https://gcc.gnu.org/onlinedocs/cpp/Stringification.html#Stringification > Essentially, params.h has a note in it to not patch the file but use > cflags to set JOHN_SYSTEMWIDE_EXEC, but doing so causes a fairly massive > compile breakage: ... because you do it wrongly, which is in turn because this stuff is non-trivial for someone who is not into shell scripting and C programming. > So despite the file saying not to patch it, it seems patching it is the > only way to set the directories. Not true. Thank you for trying to help, and I hope this explanation helps. Alexander ```
Author
Owner

@magnumripper commented on GitHub (Jan 13, 2015):

I had no idea about this escaping problem (though it is obvious in hindsight) so it's a good thing we got that spelled out. I will try supporting --prefix ASAP.

<!-- gh-comment-id:69787007 --> @magnumripper commented on GitHub (Jan 13, 2015): I had no idea about this escaping problem (though it is obvious in hindsight) so it's a good thing we got that spelled out. I will try supporting --prefix ASAP.
Author
Owner

@magnumripper commented on GitHub (Feb 2, 2015):

3031260 adds basic support for "systemwide".

./configure --with-systemwide will just set -DJOHN_SYSTEMWIDE and use default paths from params.h (/usr/libexec/john and /usr/share/john).

./configure --prefix=PATH will set JOHN_SYSTEMWIDE_EXEC to PATH and implies --with-systemwide.

I'd like to add copying to final destinations to "make install" but it's not totally obvious how to do this since things are coded into params.h. And I guess some/many of the binaries should actually go to /usr/bin or /usr/local/bin so we should have another option for that. Hard to do this right unless I let go of most of Solar's logic.

<!-- gh-comment-id:72395620 --> @magnumripper commented on GitHub (Feb 2, 2015): 3031260 adds basic support for "systemwide". `./configure --with-systemwide` will just set -DJOHN_SYSTEMWIDE and use default paths from params.h (/usr/libexec/john and /usr/share/john). `./configure --prefix=PATH` will set JOHN_SYSTEMWIDE_EXEC to PATH and implies --with-systemwide. I'd like to add copying to final destinations to "make install" but it's not totally obvious how to do this since things are coded into params.h. And I guess some/many of the binaries should actually go to /usr/bin or /usr/local/bin so we should have another option for that. Hard to do this right unless I let go of most of Solar's logic.
Author
Owner

@magnumripper commented on GitHub (Feb 2, 2015):

@DomT4 how was this handled so far? You applied that patch, built it, and then manually moved/copied data files from ../run to /usr/share/john and some/all executables to /usr/bin, or what?

I guess we could do something like

./configure --prefix=/usr/share/john --bindir=/usr/bin
make install
<!-- gh-comment-id:72396037 --> @magnumripper commented on GitHub (Feb 2, 2015): @DomT4 how was this handled so far? You applied that patch, built it, and then manually moved/copied data files from ../run to /usr/share/john and some/all executables to /usr/bin, or what? I guess we could do something like ``` ./configure --prefix=/usr/share/john --bindir=/usr/bin make install ```
Author
Owner

@magnumripper commented on GitHub (Feb 2, 2015):

OTOH this would be more natural for many

./configure --prefix=/usr
make install

That would imply /usr/share/john for charsets etc. and /usr/bin for executables.

<!-- gh-comment-id:72396117 --> @magnumripper commented on GitHub (Feb 2, 2015): OTOH this would be more natural for many ``` ./configure --prefix=/usr make install ``` That would imply /usr/share/john for charsets etc. and /usr/bin for executables.
Author
Owner

@magnumripper commented on GitHub (Feb 3, 2015):

Note to self: http://www.openwall.com/lists/john-users/2008/06/16/2

<!-- gh-comment-id:72567213 --> @magnumripper commented on GitHub (Feb 3, 2015): Note to self: http://www.openwall.com/lists/john-users/2008/06/16/2
Author
Owner

@DomT4 commented on GitHub (Feb 3, 2015):

@magnumripper Right now Homebrew is setting JOHN_SYSTEMWIDE_EXEC and JOHN_SYSTEMWIDE_HOME to HOMEBREWPREFIX/share/john which is usually /usr/local/share/john, installing everything in share/john and then symlinking the main John executable into the bin directory.

<!-- gh-comment-id:72568056 --> @DomT4 commented on GitHub (Feb 3, 2015): @magnumripper Right now Homebrew is setting `JOHN_SYSTEMWIDE_EXEC` and `JOHN_SYSTEMWIDE_HOME` to `HOMEBREWPREFIX/share/john` which is usually `/usr/local/share/john`, installing everything in share/john and then symlinking the main `John` executable into the bin directory.
Author
Owner

@magnumripper commented on GitHub (Oct 26, 2015):

FWIW here's how to support binary fallback chain without JOHN_SYSTEMWIDE (it can be modified for JOHN_SYSTEMWIDE of course).

<!-- gh-comment-id:151313815 --> @magnumripper commented on GitHub (Oct 26, 2015): FWIW [here's how to support binary fallback chain without JOHN_SYSTEMWIDE](https://github.com/magnumripper/JohnTheRipper/wiki/Fallback-binary-chains) (it can be modified for JOHN_SYSTEMWIDE of course).
Author
Owner

@magnumripper commented on GitHub (Nov 12, 2015):

I will document this for Jumbo-2. It works fine with AC as long as you do it right.

<!-- gh-comment-id:156065182 --> @magnumripper commented on GitHub (Nov 12, 2015): I will document this for Jumbo-2. It works fine with AC as long as you do it right.
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#580
No description provided.