ports/66927: [PATCH] mail/dcc-dccd has several problems
Oleg Sharoiko
os at rsu.ru
Wed May 26 09:21:11 UTC 2004
The following reply was made to PR ports/66927; it has been noted by GNATS.
From: Oleg Sharoiko <os at rsu.ru>
To: Volker Stolz <vs at FreeBSD.org>
Cc: freebsd-gnats-submit at FreeBSD.org, dean at odyssey.apana.org.au,
Andrey Beresovsky <and at rsu.ru>
Subject: Re: ports/66927: [PATCH] mail/dcc-dccd has several problems
Date: Wed, 26 May 2004 13:19:27 +0400 (MSD)
Hello!
Here is the patch against the recent version of mail/dcc-dccd (1.2.48)
It includes:
1. Correct detection of sendmail from ports
2. Ability to specify wether to user base sendmail or ports sendmail (work
with base sendmail needs to be tested - I only have boxes with sendmail from
ports here)
3. Config file is not deleted with pkg_delete and not overwritten with make
install. Instead dcc_conf.dist is always installed and dcc_conf is installed
only when it doesn't exist.
4. Ability to specify user for setuid programs. I think this should be changed
from root to some special user, but maybe this needs some deeper testing. My
patch defaults to dcc:dcc, but please change this if you think I'm wrong. The
user is created with pw if it doesn't exist.
5. Separate options to enable/disable building of dccm and dccifd
diff -uNr --exclude=CVS dcc-dccd/Makefile dcc-dccd.new/Makefile
--- dcc-dccd/Makefile Wed May 26 12:51:38 2004
+++ dcc-dccd.new/Makefile Wed May 26 12:46:24 2004
@@ -18,19 +18,84 @@
USE_REINPLACE= yes
HAS_CONFIGURE= yes
-CONFIGURE_ARGS= --homedir=${PREFIX}/dcc
MANCOMPRESSED= yes
MAN8= cdcc.8 dbclean.8 dblist.8 dcc.8 dccd.8 dccifd.8 dccm.8 \
dccproc.8 dccsight.8
-.if exists(/usr/lib/libmilter.a) || exists(${LOCALBASE}/lib/libmilter.a)
+PKGINSTALL= ${WRKDIR}/pkg-install
+PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
+
+#
+# User for dcc files and SUID binaries
+#
+DCCUSER?= dcc
+DCCGROUP?= dcc
+
+#
+# You can choose the sendmail to be used by specifying
+#
+# WITH_SENDMAIL_BASE=yes
+# or
+# WITH_SENDMAIL_PORT=yes
+#
+
+# if no preference was set, check for an up to date base version
+# but give an installed port preference over it.
+
+HOMEDIR= ${PREFIX}/dcc
+CONFIGURE_ARGS= --homedir=${HOMEDIR}
+
+.include <bsd.port.pre.mk>
+
+.if !defined(WITH_SENDMAIL_BASE) && \
+ !defined(WITH_SENDMAIL_PORT) && \
+ !exists(${LOCALBASE}/lib/libmilter.a)
+WITH_SENDMAIL_BASE=yes
+.endif
+
+.if defined(WITH_SENDMAIL_BASE)
+.if exists(/usr/lib/libmilter.a)
+MILTERBASE= /usr
+WITH_SENDMAIL=yes
+.else
+BROKEN= "Base system sendmail not found or too old, rebuild with WITH_SENDMAIL_P
+ORT=yes"
+.endif
+.else
+BUILD_DEPENDS+= ${LOCALBASE}/lib/libmilter.a:${PORTSDIR}/mail/sendmail
+MILTERBASE?= ${LOCALBASE}
+WITH_SENDMAIL=yes
+.endif
+
+.if !defined(WITHOUT_SENDMAIL) && defined(WITH_SENDMAIL)
+MILTERINC= ${MILTERBASE}/include
+MILTERLIB= ${MILTERBASE}/lib
+
+CPPFLAGS+= -I${MILTERINC}
+LDFLAGS+= -L${MILTERLIB}
+
+CONFIGURE_ENV+= CPPFLAGS="${CPPFLAGS}" LDFLAGS="${LDFLAGS}"
+CONFIGURE_ARGS+= --with-sendmail=${MILTERBASE}
PLIST_SUB+= WITH_SENDMAIL=""
.else
-CONFIGURE_ARGS+= --disable-dccm --disable-dccifd
+CONFIGURE_ARGS+= --disable-dccm
PLIST_SUB+= WITH_SENDMAIL="@comment "
.endif
-.include <bsd.port.pre.mk>
+.if defined(WITHOUT_DCCIFD)
+CONFIGURE_ARGS+= --disable-dccifd
+PLIST_SUB+= WITH_DCCIFD="@comment "
+.else
+PLIST_SUB+= WITH_DCCIFD=""
+.endif
+
+CONFIGURE_ARGS+= --with-uid=${DCCUSER}
+PLIST_SUB+= DCCUSER=${DCCUSER} \
+ DCCGROUP=${DCCGROUP}
+
+SED_SCRIPT= -e 's|%%PREFIX%%|${PREFIX}|g' \
+ -e 's|%%DCCUSER%%|${DCCUSER}|g' \
+ -e 's|%%DCCGROUP%%|${DCCGROUP}|g'
post-patch:
${FIND} ${WRKSRC} -type f -exec \
@@ -38,5 +103,17 @@
${REINPLACE_CMD} -e 's,PTHREAD_LDFLAGS="$$PTHREAD_LDFLAGS -pthread,PTHREAD_LDFLAGS="$$PTHREAD_LDFLAGS,g' ${WRKSRC}/configure
${REINPLACE_CMD} -e 's,FreeBSD)\n\tPTHREAD_LDFLAGS,FreeBSD)\n\tDCC_CFLAGS="${PTHREAD_CFLAGS} $$DCC_CFLAGS"\n\tPTHREAD_LDFLAGS,g' ${WRKSRC}/configure
${REINPLACE_CMD} -e 's,PTHREAD_LIBS="$$PTHREAD_LIBS -lc_r,PTHREAD_LIBS=" ${PTHREAD_LIBS},g' ${WRKSRC}/configure
+
+post-build:
+ @${SED} ${SED_SCRIPT} ${PKGDIR}/pkg-install >${PKGINSTALL}
+ @${SED} ${SED_SCRIPT} ${PKGDIR}/pkg-deinstall >${PKGDEINSTALL}
+
+pre-install:
+ @${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PREFIX} PRE-INSTALL
+
+post-install:
+ @[ -s ${HOMEDIR}/dcc_conf ] || \
+ ${CP} ${HOMEDIR}/dcc_conf.dist ${HOMEDIR}/dcc_conf
.include <bsd.port.post.mk>
diff -uNr --exclude=CVS dcc-dccd/Makefile.orig dcc-dccd.new/Makefile.orig
--- dcc-dccd/Makefile.orig Wed May 26 12:46:54 2004
+++ dcc-dccd.new/Makefile.orig Thu Jan 1 03:00:00 1970
@@ -1,42 +0,0 @@
-# New ports collection makefile for: mail/dcc-dccd
-# Date created: Wed Oct 9 19:30:00 WST 2002
-# Whom: Dean Hollister <dean at odyssey.apana.org.au>
-#
-# $FreeBSD: ports/mail/dcc-dccd/Makefile,v 1.11 2004/05/23 21:39:44 sergei Exp $
-#
-
-PORTNAME= dcc-dccd
-PORTVERSION= 1.2.48
-CATEGORIES= mail
-MASTER_SITES= http://www.rhyolite.com/anti-spam/dcc/source/old/ \
- http://www.wa.apana.org.au/~dean/sources/ \
- ftp://ftp.wa.apana.org.au/pub/unix/packages/
-EXTRACT_SUFX= .tar.Z
-
-MAINTAINER= dean at odyssey.apana.org.au
-COMMENT= Distributed Checksum Clearinghouse procmail, sendmail support
-
-USE_REINPLACE= yes
-HAS_CONFIGURE= yes
-CONFIGURE_ARGS= --homedir=${PREFIX}/dcc
-MANCOMPRESSED= yes
-MAN8= cdcc.8 dbclean.8 dblist.8 dcc.8 dccd.8 dccifd.8 dccm.8 \
- dccproc.8 dccsight.8
-
-.if exists(/usr/lib/libmilter.a) || exists(${LOCALBASE}/lib/libmilter.a)
-PLIST_SUB+= WITH_SENDMAIL=""
-.else
-CONFIGURE_ARGS+= --disable-dccm --disable-dccifd
-PLIST_SUB+= WITH_SENDMAIL="@comment "
-.endif
-
-.include <bsd.port.pre.mk>
-
-post-patch:
- ${FIND} ${WRKSRC} -type f -exec \
- ${REINPLACE_CMD} -e 's,/usr/local,${PREFIX},g' {} \;
- ${REINPLACE_CMD} -e 's,PTHREAD_LDFLAGS="$$PTHREAD_LDFLAGS -pthread,PTHREAD_LDFLAGS="$$PTHREAD_LDFLAGS,g' ${WRKSRC}/configure
- ${REINPLACE_CMD} -e 's,FreeBSD)\n\tPTHREAD_LDFLAGS,FreeBSD)\n\tDCC_CFLAGS="${PTHREAD_CFLAGS} $$DCC_CFLAGS"\n\tPTHREAD_LDFLAGS,g' ${WRKSRC}/configure
- ${REINPLACE_CMD} -e 's,PTHREAD_LIBS="$$PTHREAD_LIBS -lc_r,PTHREAD_LIBS=" ${PTHREAD_LIBS},g' ${WRKSRC}/configure
-
-.include <bsd.port.post.mk>
diff -uNr --exclude=CVS dcc-dccd/files/patch-configure dcc-dccd.new/files/patch-configure
--- dcc-dccd/files/patch-configure Thu Jan 1 03:00:00 1970
+++ dcc-dccd.new/files/patch-configure Wed May 26 12:46:24 2004
@@ -0,0 +1,18 @@
+--- configure.orig Mon May 17 21:32:49 2004
++++ configure Tue May 25 18:19:48 2004
+@@ -2244,6 +2244,15 @@
+ SENDMAIL_EVAL="$SENDMAIL"
+ with_sendmail=yes
+ fi
++#
++if test -n "$SENDMAIL" -a "$SENDMAIL" != "no"; then
++ if test -f $SENDMAIL/include/libmilter/mfapi.h -a -f $SENDMAIL/lib/libmilter.a; then
++ SENDMAIL_OBJ=$SENDMAIL/lib
++ SENDMAIL_OBJ_EVAL=$SENDMAIL_OBJ
++ SENDMAIL_LIB=$SENDMAIL_OBJ/libmilter.a
++ fi
++fi
++#
+ if test -z "$SENDMAIL"; then
+ # prefer a parallel ../sendmail directory
+ DEPTH=.
diff -uNr --exclude=CVS dcc-dccd/files/patch-homedir::Makefile.in dcc-dccd.new/files/patch-homedir::Makefile.in
--- dcc-dccd/files/patch-homedir::Makefile.in Thu Jan 1 03:00:00 1970
+++ dcc-dccd.new/files/patch-homedir::Makefile.in Wed May 26 12:46:24 2004
@@ -0,0 +1,15 @@
+--- homedir/Makefile.in Tue May 25 20:37:04 2004
++++ homedir/Makefile.in Tue May 25 20:38:04 2004
+@@ -28,11 +28,7 @@
+ install:
+ for nm in $(INST_HOMEDIR) $(INST_HOMEDIR)/log; do \
+ $(HINSTALL) -m 755 -d $$nm; done
+- if test -s $(INST_HOMEDIR)/dcc_conf; then \
+- sh make-dcc_conf -h $(INST_HOMEDIR); \
+- else \
+- $(HINSTALL) -m 644 dcc_conf $(INST_HOMEDIR)/dcc_conf; \
+- fi
++ $(HINSTALL) -m 644 dcc_conf $(INST_HOMEDIR)/dcc_conf.dist
+ for nm in flod grey_flod whitelist grey_whitelist \
+ whiteclnt whitecommon; do \
+ if test ! -f $(INST_HOMEDIR)/$$nm; then \
diff -uNr --exclude=CVS dcc-dccd/pkg-deinstall dcc-dccd.new/pkg-deinstall
--- dcc-dccd/pkg-deinstall Thu Jan 1 03:00:00 1970
+++ dcc-dccd.new/pkg-deinstall Wed May 26 12:46:24 2004
@@ -0,0 +1,13 @@
+#!/bin/sh
+# $FreeBSD$
+
+if [ "$2" != "POST-DEINSTALL" ]; then
+ exit 0
+fi
+
+DCCUSER=%%DCCUSER%%
+
+if pw usershow "${DCCUSER}" 2>/dev/null 1>&2; then
+ echo "To delete ${DCCUSER} user permanently, use 'pw userdel \"${DCCUSER}\"'"
+fi
+exit 0
diff -uNr --exclude=CVS dcc-dccd/pkg-install dcc-dccd.new/pkg-install
--- dcc-dccd/pkg-install Thu Jan 1 03:00:00 1970
+++ dcc-dccd.new/pkg-install Wed May 26 12:46:24 2004
@@ -0,0 +1,34 @@
+#!/bin/sh
+# $FreeBSD$
+
+PREFIX=${PKG_PREFIX:-%%PREFIX%%}
+
+DCCUSER=%%DCCUSER%%
+DCCGROUP=%%DCCGROUP%%
+
+if [ "$2" = "PRE-INSTALL" ]; then
+
+ if ! pw groupshow "$DCCGROUP" 2>/dev/null 1>&2; then
+ if pw groupadd $DCCGROUP; then
+ echo "=> Added group \"$DCCGROUP\"."
+ else
+ echo "=> Adding group \"$DCCGROUP\" failed..."
+ exit 1
+ fi
+ fi
+
+ if ! pw usershow "$DCCUSER" 2>/dev/null 1>&2; then
+ if pw useradd $DCCUSER -g $DCCGROUP -h - \
+ -s "/sbin/nologin" -d "/nonexistent" \
+ -c "Distributed Checksum Clearinghouse"; \
+ then
+ echo "=> Added user \"$DCCUSER\"."
+ else
+ echo "=> Adding user \"$DCCUSER\" failed..."
+ exit 1
+ fi
+ fi
+
+fi
+
+exit 0
diff -uNr --exclude=CVS dcc-dccd/pkg-plist dcc-dccd.new/pkg-plist
--- dcc-dccd/pkg-plist Wed May 26 12:51:38 2004
+++ dcc-dccd.new/pkg-plist Wed May 26 12:46:24 2004
@@ -8,13 +8,14 @@
dcc/cgi-bin/list-log
dcc/cgi-bin/list-msg
dcc/cgi-bin/webuser-notify
-dcc/dcc_conf
+ at unexec if cmp -s %D/dcc/dcc_conf %D/dcc/dcc_conf.dist; then rm -f %D/dcc/dcc_conf; fi
+dcc/dcc_conf.dist
dcc/flod
dcc/grey_flod
dcc/grey_whitelist
dcc/ids
dcc/libexec/cron-dccd
-%%WITH_SENDMAIL%%dcc/libexec/dccifd
+%%WITH_DCCIFD%%dcc/libexec/dccifd
%%WITH_SENDMAIL%%dcc/libexec/dccm
dcc/libexec/dbclean
dcc/libexec/dblist
--
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.
More information about the freebsd-ports-bugs
mailing list