ports/118364: [PATCH] port mail/qmail-scanner: new option to use C wrapper (no suid perl)
Rainer Schwarze
rsc at admadic.de
Sat Dec 1 00:00:05 UTC 2007
>Number: 118364
>Category: ports
>Synopsis: [PATCH] port mail/qmail-scanner: new option to use C wrapper (no suid perl)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Dec 01 00:00:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: Rainer Schwarze
>Release: FreeBSD 6.2-RELEASE i386
>Organization:
admaDIC
>Environment:
FreeBSD <not-shown> 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007 root at dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Using the port mail/qmail-scanner requires using suid perl or a C wrapper which simply calls the perl script. Using the C wrapper was not supported by the ports Makefile.
The attached patch adds an option CWRAPPER to the Makefile - turned on by default - which installs the C wrapper being located in the contrib directory of the qmail-scanner package. The patch also adjusts files/pkg-install.in and files/pkg-message.in .
The diff was created against the standard qmail-scanner revision, but with this patch applied:
http://www.freebsd.org/cgi/query-pr.cgi?prp=118139-2-diff
(PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/118139 )
(I'm new to FreeBSD / ports, so I'm not really sure, that I adjusted all relevant parts of the Makefile (CONTRIB?) and the other files.)
>How-To-Repeat:
>Fix:
see patch file
Patch attached with submission follows:
diff -ruN ../qmail-scanner-current/Makefile ./Makefile
--- ../qmail-scanner-current/Makefile Tue Nov 20 21:19:14 2007
+++ ./Makefile Fri Nov 30 23:21:50 2007
@@ -59,7 +59,8 @@
OPTIONS= TNEF "Mark Simpson's Patch (Recommended)" on \
FIX_MIME "Fix broken MIME messages" off \
REDUNDANT "Scan attachments and body mails" on \
- NORMALIZE "Decode encoded headers per MIME Base64" off
+ NORMALIZE "Decode encoded headers per MIME Base64" off \
+ CWRAPPER "use C wrapper (no suid perl script needed)" on
SUB_FILES= pkg-install pkg-message
SUB_LIST+= QS_USER=${QS_USER} \
@@ -85,6 +86,16 @@
CONFIGURE_ARGS+= --normalize no
.endif
+.if !defined(WITHOUT_CWRAPPER)
+SUB_LIST+= CWRAPPER=yes
+SUB_LIST+= QSQ_TARGET=qmail-scanner-queue
+CWRAPPER_FLG=yes
+.else
+SUB_LIST+= CWRAPPER=no
+SUB_LIST+= QSQ_TARGET=qmail-scanner-queue.pl
+CWRAPPER_FLG=no
+.endif
+
.if defined(QS_USER)
CONFIGURE_ARGS+= --qs-user "${QS_USER}"
.endif
@@ -218,11 +229,20 @@
@${ECHO_MSG} " (Default: yes, Options: yes|no|number)"
@${ECHO_MSG} ""
@${SED} -e 's,%%SPOOLDIR%%,${SPOOLDIR},g; s,%%QS_USER%%,${QS_USER},g; \
- s,%%QS_ID%%,${QS_ID},g' ${FILESDIR}/pkg-install.in > ${PKGINSTALL}
+ s,%%QS_ID%%,${QS_ID},g; s,%%CWRAPPER%%,${CWRAPPER_FLG},g' \
+ ${FILESDIR}/pkg-install.in > ${PKGINSTALL}
@${SETENV} PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL
do-build:
@${REINPLACE_CMD} -E 's,^#!.*perl(.*)$$,#!${PERL}\1,' ${WRKSRC}/qmail-scanner-queue.pl
+.if !defined(WITHOUT_CWRAPPER)
+# remove the -T option in the perl script:
+ @${REINPLACE_CMD} -E 's,^(#!${PERL}.*)-T(.*)$$,\1\2,' ${WRKSRC}/qmail-scanner-queue.pl
+# patch the correct paths into the c wrapper:
+ @${REINPLACE_CMD} -E 's|^(#define REAL_PATH ")/var/qmail/bin/qmail-scanner-queue.pl(".*)$$|\1${PREFIX}/bin/qmail-scanner-queue.pl\2|' ${WRKSRC}/contrib/qmail-scanner-queue.c
+# compile the c wrapper:
+ @${CC} ${CFLAGS} -o ${WRKSRC}/contrib/qmail-scanner-queue ${WRKSRC}/contrib/qmail-scanner-queue.c
+.endif
do-install:
.if !defined(NOPORTDOCS)
@@ -236,6 +256,9 @@
.endif
@${MKDIR} ${SPOOLDIR}
@${INSTALL_SCRIPT} ${WRKSRC}/qmail-scanner-queue.pl ${PREFIX}/bin
+.if !defined(WITHOUT_CWRAPPER)
+ @${INSTALL_PROGRAM} ${WRKSRC}/contrib/qmail-scanner-queue ${PREFIX}/bin
+.endif
@${INSTALL_DATA} ${WRKSRC}/quarantine-events.txt ${SPOOLDIR}/quarantine-events.txt.sample
@${SETENV} PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
@${CAT} ${PKGMESSAGE}
diff -ruN ../qmail-scanner-current/files/pkg-install.in ./files/pkg-install.in
--- ../qmail-scanner-current/files/pkg-install.in Tue Nov 20 21:17:15 2007
+++ ./files/pkg-install.in Fri Nov 30 23:28:53 2007
@@ -10,6 +10,7 @@
QS_ID=%%QS_ID%%
SPOOLDIR=%%SPOOLDIR%%
+CWRAPPER=%%CWRAPPER%%
case "$2" in
PRE-INSTALL)
@@ -35,7 +36,13 @@
# Mod and owner
${CHOWN} -R ${QS_USER}:${QS_USER} ${SPOOLDIR}
${CHOWN} ${QS_USER}:${QS_USER} ${PKG_PREFIX}/bin/qmail-scanner-queue.pl
- ${CHMOD} 4755 ${PKG_PREFIX}/bin/qmail-scanner-queue.pl
+ if [ ":${CWRAPPER}" = ":yes" ]; then
+ ${CHOWN} ${QS_USER}:${QS_USER} ${PKG_PREFIX}/bin/qmail-scanner-queue
+ ${CHMOD} 6755 ${PKG_PREFIX}/bin/qmail-scanner-queue
+ ${CHMOD} 0755 ${PKG_PREFIX}/bin/qmail-scanner-queue.pl
+ else
+ ${CHMOD} 4755 ${PKG_PREFIX}/bin/qmail-scanner-queue.pl
+ fi
# Initialize
${PKG_PREFIX}/bin/qmail-scanner-queue.pl -z
diff -ruN ../qmail-scanner-current/files/pkg-message.in ./files/pkg-message.in
--- ../qmail-scanner-current/files/pkg-message.in Tue Nov 20 21:17:15 2007
+++ ./files/pkg-message.in Wed Nov 28 23:29:24 2007
@@ -16,12 +16,12 @@
You just need to add for your tcpserver file (generally called
as: tcp.smtp):
-QMAILQUEUE="%%PREFIX%%/bin/qmail-scanner-queue.pl"
+QMAILQUEUE="%%PREFIX%%/bin/%%QSQ_TARGET%%"
Or create an new file in /service/smtpd/env, with the following
content and called as "QMAILQUEUE":
-%%PREFIX%%/bin/qmail-scanner-queue.pl
+%%PREFIX%%/bin/%%QSQ_TARGET%%
NOTE: always you change anything in your environment dir, you just
need to restart your smtpd, for it use: "svc -k /service/smtpd".
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list