diff --git a/mail-filter/postgrey/files/postgrey-1.37.confd-r1 b/mail-filter/postgrey/files/postgrey-1.37.confd-r1 new file mode 100644 index 0000000000000..a1ada9f28f1ac --- /dev/null +++ b/mail-filter/postgrey/files/postgrey-1.37.confd-r1 @@ -0,0 +1,58 @@ +# Config file for /etc/init.d/postgrey + +# LISTEN TYPE +# Set to 'inet' if you want to use a TCP socket. +# Set to 'unix' if you want to use a UNIX socket. +POSTGREY_TYPE="inet" + +# HOST +# What IP should postgrey bind to? +# Leave unchanged unless you know what you are doing. +# (ignored if POSTGREY_TYPE is set to 'unix') +# +# If using 'inet' with a non-loopback interface, please add rc_need="net" +# to this file. +POSTGREY_HOST="127.0.0.1" + +# PORT +# What TCP port should postgrey listen on? +# (ignored if POSTGREY_TYPE is set to 'unix') +POSTGREY_PORT="10030" + +# SOCKET +# Unix socket to listen on, if POSTGREY_TYPE is set to 'unix'. +# Leave unchanged unless you know what you are doing. +# (ignored if POSTGREY_TYPE is set to 'inet') +POSTGREY_SOCKET="/var/spool/postfix/private/postgrey" + +# DELAY +# How long to delay mail that is greylisted in seconds. +POSTGREY_DELAY=300 + +# TEXT +# The response we'll send back with delayed mail. +POSTGREY_TEXT="Greylisted for %s seconds" + +# Additional Postgrey options +# +# -v, --verbose increase verbosity level +# --max-age=N delete entries older than N days since the last time +# that they have been seen (default: 30) +# --retry-window=N allow only N days for the first retrial (default: 2) +# append 'h' if you want to specify it in hours +# --greylist-action=A if greylisted, return A to Postfix +# (default: DEFER_IF_PERMIT) +# --lookup-by-subnet strip the last 8 bits from IP addresses (default) +# --ipv4cidr=N What cidr to use for the subnet on IPv4 addresses +# when using lookup-by-subnet (default: 24) +# --ipv6cidr=N What cidr to use for the subnet on IPv6 addresses +# when using lookup-by-subnet (default: 64) +# --lookup-by-host do not strip the last 8 bits from IP addresses +# --whitelist-clients=FILE default: /etc/postfix/postgrey_whitelist_clients +# --whitelist-recipients=FILE default: /etc/postfix/postgrey_whitelist_recipients +# +# Note that the --whitelist-x options can be specified multiple times, and that +# per default /etc/postfix/postgrey_whitelist_clients.local is also read, so +# that you can put there local entries. +# +POSTGREY_OPTS="" diff --git a/mail-filter/postgrey/files/postgrey-1.37.initd-r1 b/mail-filter/postgrey/files/postgrey-1.37.initd-r1 new file mode 100644 index 0000000000000..15aade5013c8f --- /dev/null +++ b/mail-filter/postgrey/files/postgrey-1.37.initd-r1 @@ -0,0 +1,72 @@ +#!/sbin/openrc-run +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +if [ "${POSTGREY_TYPE}" = "inet" ] ; then + POSTGREY_ADDR="${POSTGREY_TYPE}=${POSTGREY_HOST}:${POSTGREY_PORT}" +else + POSTGREY_ADDR="${POSTGREY_TYPE}=${POSTGREY_SOCKET}" +fi + +conf="/etc/conf.d/postgrey" +extra_started_commands="reload" +pidfile="/run/${RC_SVCNAME}.pid" +command="/usr/sbin/postgrey" +command_args="--${POSTGREY_ADDR} --daemonize --pidfile=${pidfile}" +command_args="${command_args} --user=postgrey --group=postgrey" +command_args="${command_args} ${POSTGREY_DELAY:+--delay=${POSTGREY_DELAY}}" +command_args="${command_args} ${POSTGREY_OPTS}" +command_args="${command_args} ${POSTGREY_TEXT:+--greylist-text=\"${POSTGREY_TEXT}\"}" + +depend() { + before postfix + provide postfix_greylist +} + +conf_error() { + eerror "You need to setup ${conf} first" + return 1 +} + +checkconfig() { + if [ -z "${POSTGREY_TYPE}" ] ; then + einfo "You need to choose the server type you want" + einfo "by setting the POSTGREY_TYPE variable in ${conf}." + elif [ "${POSTGREY_TYPE}" = "inet" ] ; then + if [ -z "${POSTGREY_PORT}" ] || [ -z "${POSTGREY_HOST}" ] ; then + einfo "The following entries are missing in ${conf}:" + [ -z "${POSTGREY_HOST}" ] && einfo " - POSTGREY_HOST" + [ -z "${POSTGREY_PORT}" ] && einfo " - POSTGREY_PORT" + conf_error + fi + elif [ "${POSTGREY_TYPE}" = "unix" ] ; then + if [ -z "${POSTGREY_SOCKET}" ] ; then + einfo "The following entries are missing in ${conf}:" + [ -z "${POSTGREY_SOCKET}" ] && einfo " - POSTGREY_SOCKET" + conf_error + fi + else + einfo "Unknown POSTGREY_TYPE in ${conf}. Please choose 'inet' or 'unix'." + conf_error + fi +} + +start_pre() { + if [ "${RC_CMD}" != "restart" ] ; then + checkconfig || return $? + fi +} + +stop_pre() { + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return $? + fi +} + +reload() { + checkconfig || return $? + + ebegin "Reloading Postgrey" + start-stop-daemon --signal HUP --pidfile ${pidfile} + eend $? +} diff --git a/mail-filter/postgrey/postgrey-1.37_p20230714-r2.ebuild b/mail-filter/postgrey/postgrey-1.37_p20230714-r2.ebuild new file mode 100644 index 0000000000000..4fc286ecd7c60 --- /dev/null +++ b/mail-filter/postgrey/postgrey-1.37_p20230714-r2.ebuild @@ -0,0 +1,78 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit systemd + +COMMIT="5f60afc8e77cc2b12682636de4ad983992d6a1d2" +DESCRIPTION="Postgrey is a Postfix policy server implementing greylisting" +HOMEPAGE="https://postgrey.schweikert.ch/" +SRC_URI="https://github.com/schweikert/postgrey/archive/${COMMIT}.tar.gz -> ${P}.tar.gz" +S="${WORKDIR}/${PN}-${COMMIT}" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~x86" +IUSE="selinux" + +DEPEND=" + acct-group/postgrey + acct-user/postgrey +" +# TODO: Use db.eclass? +RDEPEND=" + ${DEPEND} + >=dev-lang/perl-5.6.0 + dev-perl/Net-Server + dev-perl/IO-Multiplex + dev-perl/BerkeleyDB + dev-perl/Net-DNS + dev-perl/NetAddr-IP + dev-perl/Net-RBLClient + dev-perl/Parse-Syslog + virtual/perl-Digest-SHA + >=sys-libs/db-4.1 + selinux? ( sec-policy/selinux-postgrey ) +" + +src_prepare() { + default + + # bug #479400 + sed -i 's@#!/usr/bin/perl -T -w@#!/usr/bin/perl -w@' postgrey || die "sed failed" + sed -i -e '/git/d' Makefile || die +} + +src_install() { + # postgrey data/DB in /var + diropts -m0770 -o ${PN} -g ${PN} + dodir /var/spool/postfix/${PN} + keepdir /var/spool/postfix/${PN} + fowners postgrey:postgrey /var/spool/postfix/${PN} + fperms 0770 /var/spool/postfix/${PN} + + # postgrey binary + dosbin ${PN} + dosbin contrib/postgreyreport + + # policy-test script + dosbin policy-test + + # postgrey data in /etc/postfix + insinto /etc/postfix + insopts -o root -g ${PN} -m 0640 + doins postgrey_whitelist_clients postgrey_whitelist_recipients + + # documentation + dodoc Changes README README.exim + + # init.d + conf.d files + insopts -o root -g root -m 755 + newinitd "${FILESDIR}"/${PN}-1.37.initd-r1 ${PN} + + insopts -o root -g root -m 640 + newconfd "${FILESDIR}"/${PN}-1.37.confd-r1 ${PN} + + systemd_dounit "${FILESDIR}"/postgrey.service +}