Thu Feb 29 20:57:37 2024 UTC (89d)
mail/opensmtpd-extras: initial import of opensmtpd-extras-6.7.1

This package provides extras for OpenSMTPD, including several filters, queues,
shcedulers and tables.


(vins)
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/DESCR
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/Makefile
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/PLIST
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/distinfo
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/options.mk
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/patches/patch-api_filter__api.c
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/patches/patch-api_queue__api.c
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/patches/patch-api_scheduler__api.c
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/patches/patch-api_table__api.c
diff -r0 -r1.1 pkgsrc/mail/opensmtpd-extras/patches/patch-configure.ac

File Added: pkgsrc/mail/opensmtpd-extras/DESCR
Extras for OpenSMTPD, including several filters, queues, schedulers and
tables.

File Added: pkgsrc/mail/opensmtpd-extras/Makefile
# $NetBSD: Makefile,v 1.1 2024/02/29 20:57:37 vins Exp $

DISTNAME=	opensmtpd-extras-6.7.1
CATEGORIES=	mail
MASTER_SITES=	${MASTER_SITE_GITHUB:=OpenSMTPD/}
GITHUB_PROJECT=	OpenSMTPD-extras
GITHUB_RELEASE=	${PKGVERSION_NOREV}

MAINTAINER=	vins@NetBSD.org
HOMEPAGE=	https://github.com/OpenSMTPD/OpenSMTPD-extras/
COMMENT=	Addons for OpenSMTPD
LICENSE=	isc

BUILD_DEFS+=		VARBASE
PTHREAD_AUTO_VARS=	yes

CFLAGS.NetBSD+=	-D_OPENBSD_SOURCE   # strtonum()

GNU_CONFIGURE=	yes
USE_LIBTOOL=	yes
USE_TOOLS+=	awk mandoc pkg-config sh
USE_TOOLS+=	automake aclocal autoheader autoconf

DEPENDS+=	opensmtpd-[0-9]*:../../mail/opensmtpd

SUBST_CLASSES+=		paths
SUBST_STAGE.paths=	pre-configure
SUBST_MESSAGE.paths=	Replacing hard-coded paths.
SUBST_FILES.paths=	configure.ac
SUBST_SED.paths+=	-e "s:/usr/local/bin:${PREFIX}/bin:g"
SUBST_SED.paths+=	-e "s:/usr/local/lib:${PREFIX}/lib:g"
SUBST_SED.paths+=	-e "s:/usr/local/include:${PREFIX}/include:g"
SUBST_SED.paths+=	-e "s:/usr/local/ssl:${SSLDIR}:g"

CONFIGURE_ENV+=		TEST_MINUS_S_SH=${SH:Q}
CONFIGURE_ARGS+=	--with-pie
CONFIGURE_ARGS+=	--with-mantype=man
CONFIGURE_ARGS+=	--libexecdir=${PREFIX}/libexec
CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR}/smtpd
CONFIGURE_ARGS+=	--with-user-smtpd=_smtpd
CONFIGURE_ARGS+=	--with-path-empty=${VARBASE}/empty
CONFIGURE_ARGS+=	--with-libssl=${SSLBASE:Q}
CONFIGURE_ARGS+=	--with-libevent=${BUILDLINK_PREFIX.libevent}

CONFIGURE_ARGS+=	--with-cflags=${CFLAGS:Q}	\
			--with-cppflags=${CPPFLAGS:Q}	\
			--with-ldflags=${LDFLAGS:Q}

CONFIGURE_ARGS+=	--with-filter-stub	\
			--with-filter-trace	\
			--with-filter-void	\
			--with-queue-null	\
			--with-queue-ram	\
			--with-queue-stub	\
			--with-scheduler-ram	\
			--with-scheduler-stub	\
			--with-table-passwd	\
			--with-table-socketmap	\
			--with-table-stub	\
			--with-tool-stats

.include "options.mk"

INSTALL_TARGET=		install-strip
INSTALLATION_DIRS+=	libexec/opensmtpd

pre-configure:
	cd ${WRKSRC} && ${PREFIX}/bin/libtoolize --copy --force
	cd ${WRKSRC} && ${TOOLS_CMD.aclocal}
	cd ${WRKSRC} && ${TOOLS_CMD.autoconf}
	cd ${WRKSRC} && ${TOOLS_CMD.autoheader}
	cd ${WRKSRC} && ${TOOLS_CMD.automake} --foreign --add-missing --copy

.include "../../security/openssl/buildlink3.mk"
.include "../../devel/libevent/buildlink3.mk"
.include "../../devel/zlib/buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/pam.buildlink3.mk"

.include "../../mk/bsd.pkg.mk"

File Added: pkgsrc/mail/opensmtpd-extras/PLIST
@comment $NetBSD: PLIST,v 1.1 2024/02/29 20:57:37 vins Exp $
libexec/opensmtpd/queue-null
${PLIST.python}libexec/opensmtpd/queue-python
libexec/opensmtpd/queue-ram
libexec/opensmtpd/queue-stub
${PLIST.python}libexec/opensmtpd/scheduler-python
libexec/opensmtpd/scheduler-ram
libexec/opensmtpd/scheduler-stub
${PLIST.ldap}libexec/opensmtpd/table-ldap
${PLIST.mysql}libexec/opensmtpd/table-mysql
libexec/opensmtpd/table-passwd
${PLIST.pgsql}libexec/opensmtpd/table-postgres
${PLIST.python}libexec/opensmtpd/table-python
${PLIST.redis}libexec/opensmtpd/table-redis
libexec/opensmtpd/table-socketmap
${PLIST.sqlite}libexec/opensmtpd/table-sqlite
libexec/opensmtpd/table-stub
man/man5/table-passwd.5
${PLIST.redis}man/man5/table-redis.5
man/man5/table-socketmap.5
${PLIST.sqlite}man/man5/table-sqlite.5

File Added: pkgsrc/mail/opensmtpd-extras/distinfo
$NetBSD: distinfo,v 1.1 2024/02/29 20:57:37 vins Exp $

BLAKE2s (opensmtpd-extras-6.7.1.tar.gz) = 8f083e788e92af2374701f283e46b010f62d21d16cce0399fd5382a008425c1a
SHA512 (opensmtpd-extras-6.7.1.tar.gz) = 0969c53a5d13816862f13b3572c0d84d34e2d36d85f83a528d70ee3f4ad5e6b2cdda256529e95a43a177e64368e4e93540d5bb2f81039808d79049234b249d91
Size (opensmtpd-extras-6.7.1.tar.gz) = 548792 bytes
SHA1 (patch-api_filter__api.c) = 10386e0910025a5fb7e39e516ba89d37a9f4f2df
SHA1 (patch-api_queue__api.c) = 95cb46aaaec8f61767abd66a6ae7122aa524d20e
SHA1 (patch-api_scheduler__api.c) = 926efe385a7cfe5844af80041e01b1886a27fea6
SHA1 (patch-api_table__api.c) = a0a96fb0e8f26d4595dc92ad8c3844270530c4d1
SHA1 (patch-configure.ac) = f772a1659f12fc421203d911d6b710020c29f5b2

File Added: pkgsrc/mail/opensmtpd-extras/options.mk
# $NetBSD: options.mk,v 1.1 2024/02/29 20:57:37 vins Exp $

PKG_OPTIONS_VAR=	PKG_OPTIONS.opensmtpd-extras

PKG_SUPPORTED_OPTIONS+=	ldap mysql perl pgsql python redis sqlite
PKG_SUGGESTED_OPTIONS=	ldap sqlite

PLIST_VARS+=	ldap mysql pgsql python redis sqlite

.include "../../mk/bsd.options.mk"

###
### SQLite based OpenSMTPD table
###
.if !empty(PKG_OPTIONS:Msqlite)
.  include "../../databases/sqlite3/buildlink3.mk"
CONFIGURE_ARGS+=	--with-table-sqlite
PLIST.sqlite=       yes
.endif

###
### LDAP based OpenSMTPD table
###
.if !empty(PKG_OPTIONS:Mldap)
.  include "../../databases/openldap-client/buildlink3.mk"
CONFIGURE_ARGS+=	--with-table-ldap
PLIST.ldap=       yes
.endif

###
### MySQL based OpenSMTPD table
###
.if !empty(PKG_OPTIONS:Mmysql)
.  include "../../mk/mysql.buildlink3.mk"
CONFIGURE_ARGS+=	--with-table-mysql
PLIST.mysql=		yes
.endif

###
### PostgreSQL based OpenSMTPD table
###
.if !empty(PKG_OPTIONS:Mpgsql)
.  include "../../mk/pgsql.buildlink3.mk"
CONFIGURE_ARGS+=	--with-table-postgres
PLIST.pgsql=		yes
.endif

###
### Redis based OpenSMTPD table
###
.if !empty(PKG_OPTIONS:Mredis)
.  include "../../databases/hiredis/buildlink3.mk"
CONFIGURE_ARGS+=	--with-table-redis
PLIST.redis=		yes
.endif

###
### Perl bindings for OpenSMTPD
###
.if !empty(PKG_OPTIONS:Mperl)
.  include "../../lang/perl5/buildlink3.mk"
USE_TOOLS+=		perl:run
CONFIGURE_ENV+=		need_perl=yes
CONFIGURE_ENV+=		PERL_CONFIG=${PERL5:Q}
CONFIGURE_ARGS+=	--with-perl=${BUILDLINK_PREFIX.perl:Q}
.endif

###
### Python bindings for OpenSMTPD
###
.if !empty(PKG_OPTIONS:Mpython)
# current implementation is incompatible and does not build with python3
PYTHON_VERSIONS_ACCEPTED=	27
LDFLAGS+=		${COMPILER_RPATH_FLAG}${PREFIX}/lib
.  include "../../converters/libiconv/buildlink3.mk"
.  include "../../devel/gettext-lib/buildlink3.mk"
.  include "../../lang/python/application.mk"
CONFIGURE_ARGS+=	--with-python=${PREFIX:Q}
CONFIGURE_ARGS+=	--with-python-type=python${PYVERSSUFFIX}
CONFIGURE_ARGS+=	--with-queue-python
CONFIGURE_ARGS+=	--with-table-python
CONFIGURE_ARGS+=	--with-scheduler-python
PLIST.python=		yes
.endif

File Added: pkgsrc/mail/opensmtpd-extras/patches/patch-api_filter__api.c
$NetBSD: patch-api_filter__api.c,v 1.1 2024/02/29 20:57:37 vins Exp $

Use seteuid(2) on systems where setresuid() is unsupported 

--- api/filter_api.c.orig	2024-02-29 15:13:00.034082660 +0000
+++ api/filter_api.c
@@ -1062,8 +1062,18 @@ filter_api_loop(void)
 	}
 
 	if (setgroups(1, &fi.gid) ||
-	    setresgid(fi.gid, fi.gid, fi.gid) ||
-	    setresuid(fi.uid, fi.uid, fi.uid)) {
+#if HAVE_SETRESGID 
+           setresgid(fi.gid, fi.gid, fi.gid)    
+#else 
+           setegid(fi.gid) 
+#endif 
+           || 
+#if HAVE_SETRESUID 
+           setresuid(fi.uid, fi.uid, fi.uid)) 
+#else 
+           seteuid(fi.uid)) 
+#endif
+	{
 		log_warn("warn: filter-api:%s cannot drop privileges", filter_name);
 		fatalx("filter-api: exiting");
 	}

File Added: pkgsrc/mail/opensmtpd-extras/patches/patch-api_queue__api.c
$NetBSD: patch-api_queue__api.c,v 1.1 2024/02/29 20:57:37 vins Exp $

Use seteuid(2) on systems where setresuid() is unsupported

--- api/queue_api.c.orig	2020-04-06 18:36:29.000000000 +0000
+++ api/queue_api.c
@@ -421,8 +421,18 @@ queue_api_dispatch(void)
 
 	if (pw &&
 	   (setgroups(1, &pw->pw_gid) ||
-	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
-	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))) {
+#if HAVE_SETRESGID
+	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid)
+#else
+	    setegid(pw->pw_gid)
+#endif
+	    ||
+#if HAVE_SETRESUID
+	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)))
+#else
+	    seteuid(pw->pw_gid)))
+#endif
+	{
 		log_warn("queue-api: cannot drop privileges");
 		fatalx("queue-api: exiting");
 	}

File Added: pkgsrc/mail/opensmtpd-extras/patches/patch-api_scheduler__api.c
$NetBSD: patch-api_scheduler__api.c,v 1.1 2024/02/29 20:57:37 vins Exp $

Use seteuid(2) on systems where setresuid() is unsupported

--- api/scheduler_api.c.orig	2020-04-06 18:36:29.000000000 +0000
+++ api/scheduler_api.c
@@ -440,8 +440,18 @@ scheduler_api_dispatch(void)
 
 	if (pw &&
 	   (setgroups(1, &pw->pw_gid) ||
-	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
-	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))) {
+#if HAVE_SETRESGID 
+           setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid)    
+#else 
+           setegid(pw->pw_gid) 
+#endif 
+           || 
+#if HAVE_SETRESUID 
+           setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))) 
+#else 
+           seteuid(pw->pw_gid))) 
+#endif
+	{
 		log_warn("queue-api: cannot drop privileges");
 		fatalx("queue-api: exiting");
 	}

File Added: pkgsrc/mail/opensmtpd-extras/patches/patch-api_table__api.c
$NetBSD: patch-api_table__api.c,v 1.1 2024/02/29 20:57:37 vins Exp $

Use seteuid(2) on systems where setresuid() is unsupported

--- api/table_api.c.orig	2020-04-06 18:36:29.000000000 +0000
+++ api/table_api.c
@@ -300,8 +300,18 @@ table_api_dispatch(void)
 	}
 
 	if (setgroups(1, &pw->pw_gid) ||
-	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
-	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) {
+#if HAVE_SETRESGID
+           setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid)
+#else
+           setegid(pw->pw_gid)
+#endif
+           ||
+#if HAVE_SETRESUID
+           setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
+#else
+           seteuid(pw->pw_gid)))
+#endif
+	{
 		log_warn("table-api: cannot drop privileges");
 		fatalx("table-api: exiting");
 	}

File Added: pkgsrc/mail/opensmtpd-extras/patches/patch-configure.ac
$NetBSD: patch-configure.ac,v 1.1 2024/02/29 20:57:37 vins Exp $

Avoid conflicting types for snprintf()

--- configure.ac.orig	2024-02-29 18:09:13.292053324 +0000
+++ configure.ac
@@ -501,9 +501,9 @@ fi
 AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <stdio.h>
-int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
+int x_snprintf(char *a, size_t b, const char *c, ...) { return 0; }
 		]], [[
-	snprintf(0, 0, 0);
+	x_snprintf(0, 0, 0);
 		]])],
    [AC_MSG_RESULT([yes])
     AC_DEFINE([SNPRINTF_CONST], [const],