about summary refs log tree commit diff
path: root/pkgs/tools/security/john
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-10-13 04:33:14 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-10-13 04:42:40 +0200
commit902bcf1422ecabb6efa771505ba5b6b3c76254c8 (patch)
tree831ee60c8b9db4e7a9afaab1b28f0409517481c4 /pkgs/tools/security/john
parentcf4e2c426ef7b93926303dc2e878a7368fe62d17 (diff)
downloadnixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar.gz
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar.bz2
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar.lz
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar.xz
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.tar.zst
nixlib-902bcf1422ecabb6efa771505ba5b6b3c76254c8.zip
john: Make package work out of the box.
So far it was only possible to run john if you've either copied over the
default configuration over to ~/.john and substitute $JOHN with the
right path or set $JOHN to the store path directly.

Both methods are not really a very good user experience, so we're now
patching in the resulting paths into the default rules/configurations.

This also splits off configuration files into $out/etc/john instead of
putting everything into $out/share/john and now also properly installs
the auxiliary programs into $out/bin.

Closes #8792.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Reported-by: devhell <"^"@regexmail.net>
Cc: @offlinehacker
Diffstat (limited to 'pkgs/tools/security/john')
-rw-r--r--pkgs/tools/security/john/default.nix34
1 files changed, 26 insertions, 8 deletions
diff --git a/pkgs/tools/security/john/default.nix b/pkgs/tools/security/john/default.nix
index 993a3a3bb85b..90ef375b79b6 100644
--- a/pkgs/tools/security/john/default.nix
+++ b/pkgs/tools/security/john/default.nix
@@ -1,4 +1,6 @@
-{ stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 }:
+{ stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2
+, writeText
+}:
 
 with stdenv.lib;
 
@@ -11,18 +13,34 @@ stdenv.mkDerivation rec {
     sha256 = "08q92sfdvkz47rx6qjn7qv57cmlpy7i7rgddapq5384mb413vjds";
   };
 
-  buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];
-
-  NIX_CFLAGS_COMPILE = "-DJOHN_SYSTEMWIDE=1";
+  postPatch = ''
+    sed -ri -e '
+      s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/!
+      /^#define\s+JOHN_SYSTEMWIDE/s!/usr!'"$out"'!
+    ' src/params.h
+    sed -ri -e '/^\.include/ {
+      s!\$JOHN!'"$out"'/etc/john!
+      s!^(\.include\s*)<([^./]+\.conf)>!\1"'"$out"'/etc/john/\2"!
+    }' run/*.conf
+  '';
 
   preConfigure = "cd src";
   configureFlags = [ "--disable-native-macro" ];
 
+  buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ];
+
+  NIX_CFLAGS_COMPILE = [ "-DJOHN_SYSTEMWIDE=1" ];
+
   installPhase = ''
-    mkdir -p "$out/share/john"
-    mkdir -p "$out/bin"
-    cp -R ../run/* "$out/share/john"
-    ln -s "$out/share/john/john" "$out/bin/john"
+    mkdir -p "$out/etc/john" "$out/share/john" "$out/share/doc/john"
+    find ../run -mindepth 1 -maxdepth 1 -type f -executable \
+      -exec "${stdenv.shell}" "${writeText "john-binary-install.sh" ''
+        filename="$(basename "$1")"
+        install -vD "$1" "$out/bin/''${filename%.*}"
+      ''}" {} \;
+    cp -vt "$out/etc/john" ../run/*.conf
+    cp -vt "$out/share/john" ../run/*.chr ../run/password.lst
+    cp -vrt "$out/share/doc/john" ../doc/*
   '';
 
   meta = {