debian/0000775000000000000000000000000011666322011007166 5ustar debian/sm-archive.postinst0000664000000000000000000000026611440224141013030 0ustar #!/bin/sh -e if [ "$1" = "configure" ]; then if ! id -u sm-archive > /dev/null 2>&1; then adduser --quiet --system --home /nonexistent sm-archive fi fi #DEBHELPER# exit 0 debian/patches/0000775000000000000000000000000011440215736010622 5ustar debian/patches/nomacro_segfault0000664000000000000000000000245411440215556014102 0ustar Postfix makes the i macro available only after at the DATA stage, so when smfi_getsymval() is called earlier it returns NULL. --- a/src/sm-archive.cpp +++ b/src/sm-archive.cpp @@ -108,7 +108,8 @@ void mlfiPriv::reset(bool final) { void my_syslog(mlfiPriv *priv, const char *text) { char buf[maxlen]; if (priv) { - snprintf(buf, sizeof(buf), "%s: %s", priv->queueid, text); + snprintf(buf, sizeof(buf), "%s: %s", + priv->queueid ? priv->queueid : "NOQUEUE", text); text = buf; } if (use_syslog) { @@ -201,7 +202,8 @@ sfsistat mlfi_envrcpt(SMFICTX *ctx, char { mlfiPriv &priv = *MLFIPRIV; CONFIG &dc = *priv.pc; - if (!priv.queueid) priv.queueid = strdup(smfi_getsymval(ctx, (char*)"i")); + const char *i_macro = smfi_getsymval(ctx, (char*)"i"); + if (!priv.queueid && i_macro) priv.queueid = strdup(i_macro); const char *rcptaddr = to_lower_string(rcpt[0]); if (debug_syslog > 1) { char msg[maxlen]; @@ -220,6 +222,8 @@ sfsistat mlfi_eom(SMFICTX *ctx) { mlfiPriv &priv = *MLFIPRIV; CONFIG &dc = *priv.pc; + const char *i_macro = smfi_getsymval(ctx, (char*)"i"); + if (!priv.queueid && i_macro) priv.queueid = strdup(i_macro); const char *target = dc.find_from(priv.mailaddr); add_target(priv, target); for (string_set::iterator i=priv.targets.begin(); i!=priv.targets.end(); i++) { debian/patches/casts0000664000000000000000000000141611440215634011661 0ustar Fix build failure. --- a/src/context.cpp +++ b/src/context.cpp @@ -33,7 +33,7 @@ CONFIG::~CONFIG() { bool CONFIG::find(const char *needle, string_set &haystack) { string_set::iterator i = haystack.find(needle); if (i != haystack.end()) return true; // found user@domain.tld key - char *x = strchr(needle, '@'); + char *x = (char *) strchr(needle, '@'); if (x) { x++; i = haystack.find(x); @@ -51,7 +51,7 @@ bool CONFIG::find(const char *needle, st const char *CONFIG::find(const char *needle, string_map &haystack) { string_map::iterator i = haystack.find(needle); if (i != haystack.end()) return (*i).second; // found user@domain.tld key - char *x = strchr(needle, '@'); + char *x = (char *) strchr(needle, '@'); if (x) { x++; i = haystack.find(x); debian/patches/series0000664000000000000000000000007211440215670012033 0ustar casts conffile_path fix_canonicalization nomacro_segfault debian/patches/fix_canonicalization0000664000000000000000000000175511440215604014742 0ustar Postfix can return addresses without <>. --- a/src/sm-archive.cpp +++ b/src/sm-archive.cpp @@ -135,14 +135,26 @@ void my_syslog(const char *text) { // always be enclosed in <>. It may have mixed case, just // as the mail client sent it. We dup the string and convert // the duplicate to lower case. +// Postfix will return addresses without <> if they have been provided +// this way in the SMTP dialog. // const char *to_lower_string(const char *email); const char *to_lower_string(const char *email) { - int n = strlen(email)-2; - if (n < 1) return strdup(email); - char *key = strdup(email+1); - key[n] = '\0'; - for (int i=0; i") == 0) + return strdup(email); + if (email[0] == '<') + p = (char *) email + 1; + else + p = (char *) email; + key = (char *) malloc(strlen(p) + 1); + for (i = 0; p[i] != '\0'; i++) + key[i] = tolower(p[i]); + if (p[i - 1] == '>') + i--; + key[i] = '\0'; return key; } debian/patches/conffile_path0000664000000000000000000000171211440215736013347 0ustar Specify a path for the configuration file. --- a/src/sm-archive.cpp +++ b/src/sm-archive.cpp @@ -282,7 +282,7 @@ CONFIG* new_conf() { snprintf(buf, sizeof(buf), "loading configuration generation %d", newc->generation); my_syslog(buf); } - if (load_conf(*newc, "sm-archive.conf")) { + if (load_conf(*newc, "/etc/sm-archive.conf")) { newc->load_time = time(NULL); return newc; } @@ -325,7 +325,7 @@ void* config_loader(void *arg) { else { // failed to load new config my_syslog("failed to load new configuration"); - system("echo 'failed to load new sm-archive configuration from /etc/sm-archive' | mail -s 'error in /etc/sm-archive configuration' root"); + system("echo 'failed to load new sm-archive configuration from /etc/sm-archive.conf' | mail -s 'error in /etc/sm-archive.conf configuration' root"); // update the load time on the current config to prevent complaining every 3 minutes dc.load_time = time(NULL); } debian/sm-archive.doc-base0000664000000000000000000000042611440166321012625 0ustar Document: sm-archive Title: sm-archive milter manual Author: Carl Byington Section: Network/Communication Format: HTML Index: /usr/share/doc/sm-archive/html/index.html Files: /usr/share/doc/sm-archive/html/*.html Format: PDF Files: /usr/share/doc/sm-archive/sm-archive.pdf.gz debian/sm-archive.postrm0000664000000000000000000000021311440224131012460 0ustar #!/bin/sh -e if [ "$1" = "purge" ]; then if id -u sm-archive > /dev/null 2>&1; then userdel sm-archive fi fi #DEBHELPER# exit 0 debian/copyright0000664000000000000000000000043711440160460011123 0ustar This package was debianized by Marco d'Itri on Fri, 03 Sep 2010 13:47:32 +0200. It was downloaded from http://www.five-ten-sg.com/sm-archive/packages/ . Copyright (c) 2007 Carl Byington - 510 Software Group. License: GPLv3 (please see /usr/share/common-licenses/GPL-3). debian/compat0000664000000000000000000000000211440160017010360 0ustar 7 debian/control0000664000000000000000000000073111440223223010565 0ustar Source: sm-archive Section: mail Priority: extra Maintainer: Marco d'Itri Build-Depends: debhelper (>> 7), libmilter-dev, autotools-dev Standards-Version: 3.9.1 Package: sm-archive Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, adduser Description: A milter for archiving email This milter adds recipients to messages in transit accordingly to the rules specified in its configuration file. Homepage: http://www.five-ten-sg.com/sm-archive/ debian/watch0000664000000000000000000000013011440160340010204 0ustar version=3 http://www.five-ten-sg.com/sm-archive/packages/sm-archive-([\d\.]+)\.tar\.gz$ debian/changelog0000664000000000000000000000060311666322010011036 0ustar sm-archive (1.7-1build1) precise; urgency=low * No-change rebuild to drop spurious libsfgcc1 dependency on armhf. -- Adam Conrad Fri, 02 Dec 2011 21:22:32 -0700 sm-archive (1.7-1) unstable; urgency=low * Initial Release. This work has been funded by Seeweb s.r.l. . -- Marco d'Itri Fri, 03 Sep 2010 14:06:41 +0200 debian/sm-archive.init0000664000000000000000000000352011440224121012102 0ustar #!/bin/sh -e ### BEGIN INIT INFO # Provides: sm-archive # Required-Start: $syslog $local_fs $remote_fs # Required-Stop: $syslog $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: archiving milter # Description: Adds recipients to messages. ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/sm-archive PIDFILE=/var/run/sm-archive.pid [ -x $DAEMON -a -e /etc/sm-archive.conf ] || exit 0 . /lib/lsb/init-functions DEBUG='-d 1' SOCKET='inet:31950@localhost' if [ -x /usr/sbin/postfix ]; then #SOCKETDIR='/var/spool/postfix/sm-archive' SOCKETOWNER="postfix:" fi if [ -r /etc/default/sm-archive ]; then . /etc/default/sm-archive fi case "$SOCKET" in /*) SOCKET="local:$SOCKET"; SOCKETDIR="${SOCKET%/*}" ;; local:*) SOCKETDIR="${SOCKET%/*}"; SOCKETDIR="${SOCKETDIR#local:}" ;; esac if [ "$SOCKETDIR" -a ! -d "$SOCKETDIR" ]; then mkdir -p $SOCKETDIR chown sm-archive: $SOCKETDIR if [ "$SOCKETOWNER" ]; then chown $SOCKETOWNER $SOCKET; fi fi OPTIONS="$DEBUG -p $SOCKET" case "$1" in start) log_daemon_msg "Starting archiver milter" "sm-archive" start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE \ --exec $DAEMON -- $OPTIONS log_end_msg 0 ;; stop) log_daemon_msg "Stopping archiver milter" "sm-archive" start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE log_end_msg 0 ;; restart|force-reload) log_daemon_msg "Restarting archiver milter" "sm-archive" start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE sleep 1 start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON -- $OPTIONS log_end_msg 0 ;; status) status_of_proc -p $PIDFILE $DAEMON sm-archive && exit 0 || exit $? ;; *) echo "Usage: /etc/init.d/sm-archive {start|stop|force-reload|restart|status}" exit 2 ;; esac exit 0 debian/rules0000775000000000000000000000343411440174774010265 0ustar #!/usr/bin/make -f SHELL+= -e D := $(CURDIR)/debian/sm-archive ############################################################################## DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) CONFFLAGS += --build $(DEB_HOST_GNU_TYPE) else CONFFLAGS += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) endif ############################################################################## clean: rm -rf .stamp-* config.sub config.guess [ ! -f Makefile ] || $(MAKE) distclean dh_clean config.status: ln -sf /usr/share/misc/config.sub /usr/share/misc/config.guess . LDFLAGS='$(LDFLAGS) -L/usr/lib/libmilter' \ ./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man build: .stamp-build .stamp-build: config.status dh_testdir $(MAKE) touch $@ install: .stamp-build checkroot dh_testdir dh_prep $(MAKE) install DESTDIR=$D htmldir='$${datadir}/doc/sm-archive' cd $D/usr/share/doc/sm-archive/ && rm AUTHORS ChangeLog COPYING README mkdir $D/usr/share/doc/sm-archive/html/ cd $D/usr/share/doc/sm-archive/ && mv *.html html/ mv $D/etc/sm-archive/sm-archive.conf $D/etc/sm-archive.conf rm -r $D/etc/sm-archive/ mv $D/usr/sbin/smarchive $D/usr/sbin/sm-archive binary-arch: install dh_testdir dh_testroot dh_installchangelogs ChangeLog dh_installdocs NEWS dh_installinit dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-arch get-orig-source: cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \ uscan --rename --force-download --destdir $(CURDIR) checkroot: test root = "`whoami`" .PHONY: binary binary-arch binary-indep unpack build clean checkroot get-orig-source debian/source/0000775000000000000000000000000011440162265010471 5ustar debian/source/format0000664000000000000000000000001411440162265011677 0ustar 3.0 (quilt)