From f9884d1c0e012e8d6dc9f5995419b98ca251a2f2 Mon Sep 17 00:00:00 2001 From: Simon Barner Date: Fri, 12 May 2006 16:58:48 +0000 Subject: [PATCH] - Update to 6.3.4 [1] - Add rcNG script. See $PREFIX/etc/rc.d/fetchmail for instructions. Inspired by [2] and ports/www/apache22. PR: ports/96987 [1], ports/96079 Submitted by: Rob MacGregor [1], Martin Jackson --- UPDATING | 14 +++ mail/fetchmail/Makefile | 14 ++- mail/fetchmail/distinfo | 6 +- mail/fetchmail/files/fetchmail.in | 135 ++++++++++++++++++++++++ mail/fetchmail/files/fetchmailrc.sample | 1 + mail/fetchmail/files/patch-netrc.c | 15 --- mail/fetchmail/pkg-install | 44 ++++++++ mail/fetchmail/pkg-plist | 7 ++ 8 files changed, 216 insertions(+), 20 deletions(-) create mode 100644 mail/fetchmail/files/fetchmail.in create mode 100644 mail/fetchmail/files/fetchmailrc.sample delete mode 100644 mail/fetchmail/files/patch-netrc.c create mode 100644 mail/fetchmail/pkg-install diff --git a/UPDATING b/UPDATING index 4280b9dd406a..0184362ebbb7 100644 --- a/UPDATING +++ b/UPDATING @@ -6,6 +6,20 @@ You should get into the habit of checking this file for changes each time you update your ports collection, before attempting any port upgrades. +20060512: + AFFECTS: users of mail/fetchmail + AUTHOR: barner@FreeBSD.org + + Fetchmail now has a rcNG script. It supports two modes: + + - one fetchmail instance per user: Set the `fetchmail_users' + variable to a list of users for which you want to start + fetchmail. + - a global system wide daemon (runs per default as user + `fetchmail') + + See $PREFIX/etc/rc.d/fetchmail for details. + 20060509: AFFECTS: users of net-im/sulci AUTHOR: Denis Shaposhnikov diff --git a/mail/fetchmail/Makefile b/mail/fetchmail/Makefile index 98f5b12f292c..6336cf297a76 100644 --- a/mail/fetchmail/Makefile +++ b/mail/fetchmail/Makefile @@ -10,8 +10,7 @@ # want fetchmailconf to work, define WITH_X11 PORTNAME= fetchmail -PORTVERSION= 6.3.2 -PORTREVISION= 1 +PORTVERSION= 6.3.4 CATEGORIES= mail ipv6 MASTER_SITES= http://download.berlios.de/%SUBDIR%/ \ http://home.pages.de/~mandree/%SUBDIR%/ \ @@ -23,6 +22,9 @@ COMMENT= Batch mail retrieval utility for IMAP/POP2/POP3/ETRN/ODMR RUN_DEPENDS= ${LOCALBASE}/share/certs/ca-root.crt:${PORTSDIR}/security/ca-roots +USE_RC_SUBR= fetchmail +FETCHMAILRC= ${PREFIX}/etc//fetchmailrc + USE_BZIP2= yes USE_GMAKE= yes GNU_CONFIGURE= yes @@ -98,6 +100,9 @@ pre-configure: @${ECHO_CMD} "You can use -DWITHOUT_NLS to suppress national language support (NLS)." .endif +pre-install: + @${SETENV} ${SCRIPTS_ENV} PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL + post-install: .if !defined(NOPORTDOCS) ${INSTALL} -d -m 555 -o ${DOCOWN} -g ${DOCGRP} ${DOCSDIR} @@ -106,5 +111,10 @@ post-install: ${INSTALL_SCRIPT} ${WRKDIR}/fetchmailconf ${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKSRC}/fetchmailconf.py ${PREFIX}/libexec + ${INSTALL} -d -m 755 -o fetchmail -g fetchmail /var/run/fetchmail + ${INSTALL} -m 644 -o fetchmail -g fetchmail ${FILESDIR}/fetchmailrc.sample ${PREFIX}/etc/fetchmailrc.sample + if [ ! -f ${PREFIX}/etc/fetchmailrc ]; then \ + ${CP} -p ${PREFIX}/etc/fetchmailrc.sample ${PREFIX}/etc/fetchmailrc ; \ + fi .include diff --git a/mail/fetchmail/distinfo b/mail/fetchmail/distinfo index ec2228bca12a..663cbbb71563 100644 --- a/mail/fetchmail/distinfo +++ b/mail/fetchmail/distinfo @@ -1,3 +1,3 @@ -MD5 (fetchmail-6.3.2.tar.bz2) = a532134a5e3b35b4f8b78a8184439837 -SHA256 (fetchmail-6.3.2.tar.bz2) = 4fbb779c0fddf74af8267a8e8a68bc276c7afc2c854e04b754ca7ebbab2f876e -SIZE (fetchmail-6.3.2.tar.bz2) = 1190838 +MD5 (fetchmail-6.3.4.tar.bz2) = 35ded0414fcff79b492d6ade2ce48911 +SHA256 (fetchmail-6.3.4.tar.bz2) = a090cfc47949e4ea5eebd46c82e82be35cdc743488e6d7258089591521b5db4f +SIZE (fetchmail-6.3.4.tar.bz2) = 1210405 diff --git a/mail/fetchmail/files/fetchmail.in b/mail/fetchmail/files/fetchmail.in new file mode 100644 index 000000000000..14078f2676ee --- /dev/null +++ b/mail/fetchmail/files/fetchmail.in @@ -0,0 +1,135 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# PROVIDE: fetchmail +# REQUIRE: mail +# BEFORE: LOGIN +# KEYWORD: shutdown + +# +# Add the following lines to /etc/rc.conf to enable fetchmail: +# +# fetchmail_enable="YES" +# +# There are two modes: +# +# * Single system-wide fetchmail daemon: +# - It is run as user `fetchmail_user' (default: fetchmail) +# - All configuration is contained in one global file +# `fetchmail_config' (default: %%PREFIX/etc/fetchmailrc), +# that must be owned by `fetchmail_user' (mode 700) +# - The fetchmail daemon awakes to fetch mail every +# `fetchmail_polling_interval' seconds (default: 900). +# +# * Per-user daemon +# - Users for which a fetchmail daemon is to be started must be +# listed in `fetchmail_users', e.g. fetchmail_users="user1 user2" +# - The config files for the individual users must be located at +# ${fetchmail_home_prefix}/${user}/${fetchmail_config_name}. The +# default for `fetchmail_home_prefix' is "/home", and that for +# `fetchmail_config_name' is ".fetchmailrc". +# - Note that "${fetchmail_home_prefix}/${user}" must be writable +# for ${user} since it is used to store the per-user PID files! +# - There are user-specific versions of `fetchmail_config' and +# `fetchmail_polling_interval' that can be used to override the +# defaults, i.e. for the user `user1' there are variables +# `fetchmail_user1_config' and `fetchmail_user1_polling_interval' +# - All commands (e.g. start, stop, awaken (see below)) can be either +# passed to all instances of the daemon (if %%PREFIX/etc/rc.d/fetchmail) +# is run as root), or just to the instance belonging to the respective +# user. +# +# Extra commands: +# +# * `awaken': Sends a signal to the daemon(s) to check for new mail +# immediately + +. /etc/rc.subr + +name=fetchmail +rcvar=`set_rcvar` + +command=%%PREFIX%%/bin/${name} +pidfile=/var/run/${name}.pid +extra_commands="awaken" +awaken_cmd="fetchmail_awaken" + +# read settings, set default values +load_rc_config "$name" +: ${fetchmail_enable="NO"} +: ${fetchmail_config="%%PREFIX%%/etc/fetchmailrc"} +: ${fetchmail_polling_interval="900"} +: ${fetchmail_home_prefix="/home"} +: ${fetchmail_config_name=".fetchmailrc"} + +# send signal to fetchmail process(es) to check for new mail immediately +fetchmail_awaken() +{ + if [ $rc_pid ]; then + echo "Forcing fetchmail to check mailbox(es)..." + kill -USR1 $rc_pid + else + echo "$name not running? (check $pidfile)" + fi + + return +} + +if [ -n "$2" ]; then + # perform action for an instance of fetchmail daemon + user="$2" + if [ "x${fetchmail_users}" != "x" -o "x$3" = "xGLOBALCONFIG" ]; then + if [ "x${fetchmail_users}" != "x" ]; then + # multiuser setup: determine user specific config and pid file + eval fetchmail_config="\${fetchmail_${user}_config:-${fetchmail_home_prefix}/${user}}/${fetchmail_config_name}" + eval pidfile="${fetchmail_home_prefix}/${user}/.fetchmail.pid" + eval fetchmail_user=$user + else + eval fetchmail_user=fetchmail + eval pidfile=/var/run/fetchmail/fetchmail.pid + fi + required_files=${fetchmail_config} + eval fetchmail_polling_interval="\${fetchmail_${user}_polling_interval:-${fetchmail_polling_interval}}" + fetchmail_flags="-f ${fetchmail_config} \ + --pidfile ${pidfile} \ + -d ${fetchmail_polling_interval} \ + --syslog" + else + echo "$0: extra argument ignored" + fi +else + uid=`id -u` + if [ "x${fetchmail_users}" != "x" -a "x$1" != "x" -a "$uid" = "0" ]; then + # root mode: multiple user profiles are handled by recursive + # calls of this script + for user in ${fetchmail_users}; do + echo "===> fetchmail user: ${user}" + %%PREFIX%%/etc/rc.d/fetchmail $1 ${user} + retcode="$?" + if [ "0${retcode}" -ne 0 ]; then + failed="${user} (${retcode}) ${failed:-}" + else + success="${user} ${success:-}" + fi + done + exit 0 + else + if [ "x${fetchmail_users}" = "x" ]; then + # There is only one global configuration file + globalconfig=GLOBALCONFIG + fi + %%PREFIX%%/etc/rc.d/fetchmail $1 `id -u -n` $globalconfig + retcode="$?" + if [ "0${retcode}" -ne 0 ]; then + failed="${user} (${retcode}) ${failed:-}" + else + success="${user} ${success:-}" + fi + exit 0 + fi +fi + +# actually execute the fetchmail program +run_rc_command "$1" diff --git a/mail/fetchmail/files/fetchmailrc.sample b/mail/fetchmail/files/fetchmailrc.sample new file mode 100644 index 000000000000..cf2f29147890 --- /dev/null +++ b/mail/fetchmail/files/fetchmailrc.sample @@ -0,0 +1 @@ +# Sample diff --git a/mail/fetchmail/files/patch-netrc.c b/mail/fetchmail/files/patch-netrc.c deleted file mode 100644 index fcd9bafc4f21..000000000000 --- a/mail/fetchmail/files/patch-netrc.c +++ /dev/null @@ -1,15 +0,0 @@ ---- netrc.c (Revision 4683) -+++ netrc.c (Revision 4684) -@@ -314,8 +314,10 @@ - free_netrc(netrc_entry *a) { - while(a) { - netrc_entry *n = a->next; -- memset(a->password, 0x55, strlen(a->password)); -- xfree(a->password); -+ if (a->password != NULL) { -+ memset(a->password, 0x55, strlen(a->password)); -+ free(a->password); -+ } - xfree(a->login); - xfree(a->host); - xfree(a); diff --git a/mail/fetchmail/pkg-install b/mail/fetchmail/pkg-install new file mode 100644 index 000000000000..f7b4a2857948 --- /dev/null +++ b/mail/fetchmail/pkg-install @@ -0,0 +1,44 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +PKG_PREFIX=${PKG_PREFIX:=/usr/local} + +if [ -x /usr/sbin/nologin ]; then + NOLOGIN=/usr/sbin/nologin +else + NOLOGIN=/sbin/nologin +fi + +if [ x"$2" = xPRE-INSTALL ]; then + USER=fetchmail + UID=124 + GROUP=fetchmail + GID=124 + + if /usr/sbin/pw groupshow "${GROUP}" 2>/dev/null; then + echo "You already have a group \"${GROUP}\", so I will use it." + else + if /usr/sbin/pw groupadd ${GROUP} -g ${GID} + then + echo "Added group \"${GROUP}\"." + else + echo "Adding group \"${GROUP}\" failed..." + echo "Please create it, and try again." + exit 1 + fi + fi + + if /usr/sbin/pw user show "${USER}" 2>/dev/null; then + echo "You already have a user \"${USER}\", so I will use it." + else + if /usr/sbin/pw useradd ${USER} -u ${UID} -g ${GROUP} -h - -d /var/run/fetchmail -s ${NOLOGIN} -c "Fetchmail mail-retrieval daemon"; then + echo "Added user \"${USER}\"." + else + echo "Adding user \"${USER}\" failed..." + echo "Please create it, and try again." + exit 1 + fi + fi +fi diff --git a/mail/fetchmail/pkg-plist b/mail/fetchmail/pkg-plist index 4b1f3d312b64..c0569f1596e5 100644 --- a/mail/fetchmail/pkg-plist +++ b/mail/fetchmail/pkg-plist @@ -23,3 +23,10 @@ libexec/fetchmailconf.py %%NLS%%share/locale/pl/LC_MESSAGES/fetchmail.mo %%NLS%%share/locale/ru/LC_MESSAGES/fetchmail.mo %%NLS%%share/locale/sq/LC_MESSAGES/fetchmail.mo +%%NLS%%share/locale/vi/LC_MESSAGES/fetchmail.mo +@unexec if cmp -s %D/etc/fetchmailrc.sample %D/etc/fetchmailrc; then rm -f %D/etc/fetchmailrc; fi +etc/fetchmailrc.sample +@exec if [ ! -f %D/etc/fetchmailrc ] ; then cp -p %D/%F %B/fetchmailrc; fi +@cwd / +@unexec rm -f /var/run/fetchmail/fetchmail.pid 2>/dev/null || true +@dirrm /var/run/fetchmail