summaryrefslogtreecommitdiff
blob: 87bf6cc11d8b783fa868d736a130fb70054c7d53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-crypt/johntheripper/johntheripper-1.7.2-r3.ebuild,v 1.5 2007/12/31 12:21:42 armin76 Exp $

inherit eutils flag-o-matic toolchain-funcs pax-utils

MY_PBASE=${P/theripper/}
MY_PNBASE=${PN/theripper/}
S=${WORKDIR}/${MY_PBASE}
DESCRIPTION="fast password cracker"
HOMEPAGE="http://www.openwall.com/john/"
SRC_URI="http://www.openwall.com/john/f/${MY_PBASE}.tar.gz
		http://www.openwall.com/john/contrib/${MY_PNBASE}-1.7.2-all-7.diff.gz"

# banquise-to-bigpatch-17.patch.bz2"
# based off /var/tmp/portage/johntheripper-1.6.40

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="alpha ~amd64 ~hppa ~mips ppc ppc64 sparc x86"
IUSE="mmx altivec sse2 custom-cflags"

RDEPEND=">=dev-libs/openssl-0.9.7"

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${WORKDIR}"/${MY_PNBASE}-1.7.2-all-7.diff

	for p in sha1-memset stackdef.S stackdef-2.S mkdir-sandbox; do
		epatch "${FILESDIR}/${P}-${p}.patch"
	done
}

src_compile() {
	#
	# upstream request to strip
	# any flags, as he optimize the
	# outputs
	#
	use custom-cflags || strip-flags
	append-flags -fno-PIC -fno-PIE
	append-ldflags -nopie

	cd "${S}"/src

	# Remove default OPT_NORMAL -funroll-loops bug#198659 for unknown archs
	OPTIONS="CPP=$(tc-getCXX) CC=$(tc-getCC) AS=$(tc-getCC) LD=$(tc-getCC) \
		CFLAGS=\"-c -Wall ${CFLAGS} -DJOHN_SYSTEMWIDE \
		-DJOHN_SYSTEMWIDE_HOME=\\\"\\\\\\\"/etc/john\\\\\\\"\\\"\" \
		LDFLAGS=\"${LDFLAGS}\" \
		OPT_NORMAL=\"\""

	if use x86 ; then
		if use sse2 ; then
			eval emake ${OPTIONS} linux-x86-sse2 || die "Make failed"
		elif use mmx ; then
			eval emake ${OPTIONS} linux-x86-mmx || die "Make failed"
		else
			eval emake ${OPTIONS} linux-x86-any || die "Make failed"
		fi
	elif use alpha ; then
		eval emake ${OPTIONS} linux-alpha || die "Make failed"
	elif use sparc; then
		eval emake ${OPTIONS} linux-sparc  || die "Make failed"
	elif use amd64; then
		eval emake ${OPTIONS} linux-x86-64  || die "Make failed"
	elif use ppc-macos; then
		if use altivec; then
			eval emake ${OPTIONS} macosx-ppc32-altivec || die "Make failed"
		else
			eval emake ${OPTIONS} macosx-ppc32 || die "Make failed"
		fi
		# for Tiger this can be macosx-ppc64
	elif use ppc64; then
		if use altivec; then
			eval emake ${OPTIONS} linux-ppc32-altivec  || die "Make failed"
		else
			eval emake ${OPTIONS} linux-ppc64  || die "Make failed"
		fi
		# linux-ppc64-altivec is slightly slower than linux-ppc32-altivec for most hash types.
		# as per the Makefile comments
	elif use ppc; then
		if use altivec; then
			eval emake ${OPTIONS} linux-ppc32-altivec  || die "Make failed"
		else
			eval emake ${OPTIONS} linux-ppc32 || die "Make failed"
		fi
	else
		eval emake ${OPTIONS} generic || die "Make failed"
	fi

	# currently broken
	#eval emake bench || die "make failed"
}

src_test() {
	cd run
	if  [ -f /etc/john/john.conf -o -f /etc/john/john.ini  ]; then
		./john --test || die 'self test failed'
	else
		ewarn "selftest requires /etc/john/john.conf or /etc/john/john.ini"
	fi
}

src_install() {
	# executables
	dosbin run/john
	newsbin run/mailer john-mailer

	pax-mark -m "${D}"/usr/sbin/john

	dosym john /usr/sbin/unafs
	dosym john /usr/sbin/unique
	dosym john /usr/sbin/unshadow

	# for EGG only
	dosym john /usr/sbin/undrop

	#newsbin src/bench john-bench

	# config files
	insinto /etc/john
	doins run/john.conf
	doins run/*.chr run/password.lst

	# documentation
	dodoc doc/*
}