summaryrefslogtreecommitdiff
blob: 1ac47ff4a3a48515f13cd764cb489375706e37e1 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-mail/popa3d/popa3d-0.6.3.ebuild,v 1.1 2003/09/11 17:36:44 port001 Exp $

#
# Mailbox format is determined by the 'mbox' and 'maildir'
# system USE flags.
#
# Mailbox path configuration denoted by the system USE
# flags.
#
# USE flag 'maildir' denotes ~/.maildir
# USE flag 'mbox' denotes /var/mail/username
#
# You can overwrite this by setting the POPA3D_HOME_MAILBOX
# environmental variable (see below) before emerge.
#
# Environmental variables.
#
# POPA3D_HOME_MAILBOX
#
# Overwrite the local user mailbox path. For example
# if you want qmail-styled ~/Mailbox you can set it
# to "Mailbox". For the traditional (although not in
# gentoo Maildir) set it to "Maildir".
# 
# POPA3D_VIRTUAL_ONLY
#
# Set this field to "YES" if you dont want local users
# to have POP access. Setting this makes the POPA3D_HOME_MAILBOX
# variable effectively useless.
#
# POPA3D_VIRTUAL_HOME_PATH
#
# Set this field to the base virtual home path. For more information
# read the virtual guide here: http://forums.gentoo.org/viewtopic.php?t=82386
# 

IUSE="pam mbox maildir"

DESCRIPTION="A security oriented POP3 server."
HOMEPAGE="http://www.openwall.com/popa3d/"

SRC_URI="http://www.openwall.com/popa3d/${P}.tar.gz
		 http://www.data.is/~hhg/popa3d/${P}-vname-2.diff
		 maildir? ( http://www.data.is/~hhg/popa3d/popa3d-0.5.9-maildir-2.diff )"

LICENSE="as-is"
SLOT="0"
KEYWORDS="x86"

DEPEND=">=sys-apps/sed-4
		pam? ( >=sys-libs/pam-0.72 )"

pkg_setup() {
	if use mbox && use maildir ; then
		echo
		eerror
		eerror "You must choose between mbox or maildir,"
		eerror "both cannot be used together."
		eerror
		die "Both mbox and maildir specified."
	fi

	echo
	ewarn
	ewarn "You can customize this ebuild with environmental variables."
	ewarn "If you don't I'll assume sensible defaults."
	ewarn
	ewarn "See inside for details."
	ewarn
	echo
	sleep 5

	if ! grep -q ^popa3d: /etc/group ; then
		groupadd popa3d || die "Failed to add group: popa3d"
	fi

	if ! grep -q ^popa3d: /etc/passwd ; then
		useradd -g popa3d -d /dev/null -s /dev/null popa3d || die "Failed to add user: popa3d"
	fi
}

src_unpack() {
	unpack ${P}.tar.gz
}

src_compile() {
	cd ${S}

	epatch ${DISTDIR}/popa3d-0.6.3-vname-2.diff

	if use mbox ; then
		einfo "Mailbox format is: MAILBOX."
	else
		epatch ${DISTDIR}/popa3d-0.5.9-maildir-2.diff
		einfo "Mailbox format is: MAILDIR."
		if [ "${POPA3D_HOME_MAILBOX}" = "" ] ; then
			POPA3D_HOME_MAILBOX=".maildir"
		fi
	fi

	if [ "${POPA3D_HOME_MAILBOX}" != "" ] ; then
		einfo "Mailbox path: ~/$POPA3D_HOME_MAILBOX"
		sleep 2
		sed -i -e "s:^\(#define MAIL_SPOOL_PATH.*\)$://\1:" params.h
		sed -i -e "s:^#define HOME_MAILBOX_NAME.*$:#define HOME_MAILBOX_NAME \"${POPA3D_HOME_MAILBOX}\":" params.h
	else
		einfo "Mailbox path: /var/mail/username"
	fi

	if [ "${POPA3D_VIRTUAL_ONLY}" = "YES" ] ; then
		einfo "Virtual only, no local system users"
		sed -i -e "s:^#define VIRTUAL_ONLY.*$:#define VIRTUAL_ONLY 1:" params.h
	fi

	if [ "${POPA3D_VIRTUAL_HOME_PATH}" != "" ] ; then
		einfo "Virtual home path set to: $POPA3D_VIRTUAL_HOME_PATH"
		sed -i -e "s:^#define VIRTUAL_HOME_PATH.*$:#define VIRTUAL_HOME_PATH \"$POPA3D_VIRTUAL_HOME_PATH\":" params.h
	fi

	if [ "$POPA3D_VIRTUAL_ONLY" = "YES" ] ; then
		einfo "Authentication method: Virtual."
	elif use pam ; then
		einfo "Authentication method: PAM."
		LIBS="${LIBS} -lpam"
		sed -i -e "s:^#define AUTH_SHADOW .*$:#define AUTH_SHADOW 0:" params.h
		sed -i -e "s:^#define AUTH_PAM .*$:#define AUTH_PAM 1:" params.h
	else
		einfo "Authentication method: Shadow."
	fi

	sed -i -e "s:^#define POP_STANDALONE.*$:#define POP_STANDALONE 1:" params.h
	sed -i -e "s:^#define POP_VIRTUAL.*$:#define POP_VIRTUAL 1:" params.h
	sed -i -e "s:^#define VIRTUAL_VNAME.*$:#define VIRTUAL_VNAME 1:" params.h

	emake LIBS="${LIBS} -lcrypt" || die "emake failed"
}

src_install() {
	into /usr

	dosbin popa3d
	doman popa3d.8
	dodoc DESIGN INSTALL CHANGES VIRTUAL CONTACT

	diropts -m 755
	dodir /var/empty

	exeinto /etc/init.d
	newexe ${FILESDIR}/popa3d-initrc popa3d

	if use pam ; then
		insinto /etc/pam.d
		newins ${FILESDIR}/pam popa3d
	fi
}

pkg_postinst() {
	einfo "Running depscan.sh..."
	/sbin/depscan.sh
}