Sat Jun 17 13:55:06 2017 UTC ()
Add pymsgauth-tag, a Unix filter that takes an RFC822 mail message on stdin
and prints it to stdout, adding a pymsgauth token in the header if needed.
Patch has been submitted upstream. Bump PKGREVISION.


(schmonz)
diff -r1.14 -r1.15 pkgsrc/mail/pymsgauth/Makefile
diff -r1.2 -r1.3 pkgsrc/mail/pymsgauth/PLIST
diff -r1.2 -r1.3 pkgsrc/mail/pymsgauth/distinfo
diff -r0 -r1.1 pkgsrc/mail/pymsgauth/patches/patch-pymsgauth-tag
diff -r0 -r1.1 pkgsrc/mail/pymsgauth/patches/patch-pymsgauth.py

cvs diff -r1.14 -r1.15 pkgsrc/mail/pymsgauth/Makefile (expand / switch to unified diff)

--- pkgsrc/mail/pymsgauth/Makefile 2017/05/26 01:35:58 1.14
+++ pkgsrc/mail/pymsgauth/Makefile 2017/06/17 13:55:06 1.15
@@ -1,44 +1,47 @@ @@ -1,44 +1,47 @@
1# $NetBSD: Makefile,v 1.14 2017/05/26 01:35:58 schmonz Exp $ 1# $NetBSD: Makefile,v 1.15 2017/06/17 13:55:06 schmonz Exp $
2# 2#
3 3
4DISTNAME= pymsgauth-2.1.0 4DISTNAME= pymsgauth-2.1.0
5PKGREVISION= 6 5PKGREVISION= 7
6CATEGORIES= mail 6CATEGORIES= mail
7MASTER_SITES= ${HOMEPAGE} 7MASTER_SITES= ${HOMEPAGE}
8 8
9MAINTAINER= schmonz@NetBSD.org 9MAINTAINER= schmonz@NetBSD.org
10HOMEPAGE= http://pyropus.ca/software/pymsgauth/ 10HOMEPAGE= http://pyropus.ca/software/pymsgauth/
11COMMENT= Automatically process qsecretary confirmation requests 11COMMENT= Automatically process qsecretary confirmation requests
12LICENSE= gnu-gpl-v2 12LICENSE= gnu-gpl-v2
13 13
14PYMSGAUTH_PROGRAMS= pymsgauth-* 14PYMSGAUTH_PROGRAMS= pymsgauth-*
15DOCS= BUGS CHANGELOG COPYING pymsgauth.txt 15DOCS= BUGS CHANGELOG COPYING pymsgauth.txt
16HTMLDOCS= pymsgauth.html 16HTMLDOCS= pymsgauth.html
17EXAMPLES= pymsgauthrc-example 17EXAMPLES= pymsgauthrc-example
18 18
19SHAREDIR= share/pymsgauth 19SHAREDIR= share/pymsgauth
20DOCDIR= share/doc/pymsgauth 20DOCDIR= share/doc/pymsgauth
21HTMLDOCDIR= share/doc/html/pymsgauth 21HTMLDOCDIR= share/doc/html/pymsgauth
22EGDIR= share/examples/pymsgauth 22EGDIR= share/examples/pymsgauth
23 23
24NO_BUILD= yes 24NO_BUILD= yes
25REPLACE_PYTHON= ${PYMSGAUTH_PROGRAMS} *.py 25REPLACE_PYTHON= ${PYMSGAUTH_PROGRAMS} *.py
26PYTHON_VERSIONS_ACCEPTED= 27 26PYTHON_VERSIONS_ACCEPTED= 27
27 27
28FILES_SUBST+= SHAREDIR=${SHAREDIR:Q} 28FILES_SUBST+= SHAREDIR=${SHAREDIR:Q}
29 29
30INSTALLATION_DIRS= ${SHAREDIR} ${DOCDIR} ${HTMLDOCDIR} ${EGDIR} bin 30INSTALLATION_DIRS= ${SHAREDIR} ${DOCDIR} ${HTMLDOCDIR} ${EGDIR} bin
31 31
 32pre-install:
 33 cd ${WRKSRC} && ${RM} -f *.orig
 34
32do-install: 35do-install:
33 for f in ${REPLACE_PYTHON}; do \ 36 for f in ${REPLACE_PYTHON}; do \
34 ${INSTALL_SCRIPT} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${SHAREDIR}; \ 37 ${INSTALL_SCRIPT} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${SHAREDIR}; \
35 done 38 done
36 39
37 for f in ${DOCS}; do \ 40 for f in ${DOCS}; do \
38 ${INSTALL_DATA} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${DOCDIR}; \ 41 ${INSTALL_DATA} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${DOCDIR}; \
39 done 42 done
40 43
41 for f in ${HTMLDOCS}; do \ 44 for f in ${HTMLDOCS}; do \
42 ${INSTALL_DATA} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${HTMLDOCDIR}; \ 45 ${INSTALL_DATA} ${WRKSRC}/$${f} ${DESTDIR}${PREFIX}/${HTMLDOCDIR}; \
43 done 46 done
44 47

cvs diff -r1.2 -r1.3 pkgsrc/mail/pymsgauth/PLIST (expand / switch to unified diff)

--- pkgsrc/mail/pymsgauth/PLIST 2009/06/14 18:04:40 1.2
+++ pkgsrc/mail/pymsgauth/PLIST 2017/06/17 13:55:06 1.3
@@ -1,12 +1,13 @@ @@ -1,12 +1,13 @@
1@comment $NetBSD: PLIST,v 1.2 2009/06/14 18:04:40 joerg Exp $ 1@comment $NetBSD: PLIST,v 1.3 2017/06/17 13:55:06 schmonz Exp $
2share/doc/html/pymsgauth/pymsgauth.html 2share/doc/html/pymsgauth/pymsgauth.html
3share/doc/pymsgauth/BUGS 3share/doc/pymsgauth/BUGS
4share/doc/pymsgauth/CHANGELOG 4share/doc/pymsgauth/CHANGELOG
5share/doc/pymsgauth/COPYING 5share/doc/pymsgauth/COPYING
6share/doc/pymsgauth/pymsgauth.txt 6share/doc/pymsgauth/pymsgauth.txt
7share/examples/pymsgauth/pymsgauthrc-example 7share/examples/pymsgauth/pymsgauthrc-example
8share/pymsgauth/ConfParser.py 8share/pymsgauth/ConfParser.py
9share/pymsgauth/pymsgauth-clean 9share/pymsgauth/pymsgauth-clean
10share/pymsgauth/pymsgauth-confirm 10share/pymsgauth/pymsgauth-confirm
11share/pymsgauth/pymsgauth-mail 11share/pymsgauth/pymsgauth-mail
 12share/pymsgauth/pymsgauth-tag
12share/pymsgauth/pymsgauth.py 13share/pymsgauth/pymsgauth.py

cvs diff -r1.2 -r1.3 pkgsrc/mail/pymsgauth/distinfo (expand / switch to unified diff)

--- pkgsrc/mail/pymsgauth/distinfo 2015/11/03 23:27:17 1.2
+++ pkgsrc/mail/pymsgauth/distinfo 2017/06/17 13:55:06 1.3
@@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
1$NetBSD: distinfo,v 1.2 2015/11/03 23:27:17 agc Exp $ 1$NetBSD: distinfo,v 1.3 2017/06/17 13:55:06 schmonz Exp $
2 2
3SHA1 (pymsgauth-2.1.0.tar.gz) = fe6c60022529ce2444db3423f84d44e457ae61bb 3SHA1 (pymsgauth-2.1.0.tar.gz) = fe6c60022529ce2444db3423f84d44e457ae61bb
4RMD160 (pymsgauth-2.1.0.tar.gz) = 0a5d7d6be65d9623647a3dfe014cb89a2c213183 4RMD160 (pymsgauth-2.1.0.tar.gz) = 0a5d7d6be65d9623647a3dfe014cb89a2c213183
5SHA512 (pymsgauth-2.1.0.tar.gz) = a53ab929659106903a0c0fb83984a478d3bf32556467cf2ccf88d36f7b749a692edc3253a49ef78b0a3fe6e7475cca1ae583d4b8bc162fb693b395b6ab80ebc1 5SHA512 (pymsgauth-2.1.0.tar.gz) = a53ab929659106903a0c0fb83984a478d3bf32556467cf2ccf88d36f7b749a692edc3253a49ef78b0a3fe6e7475cca1ae583d4b8bc162fb693b395b6ab80ebc1
6Size (pymsgauth-2.1.0.tar.gz) = 17915 bytes 6Size (pymsgauth-2.1.0.tar.gz) = 17915 bytes
 7SHA1 (patch-pymsgauth-tag) = 44d27f8d915752c35cd07acd556490d93945d21e
 8SHA1 (patch-pymsgauth.py) = 2d27f17b1c37d7e4646a69424bec68aa3380c29f

File Added: pkgsrc/mail/pymsgauth/patches/Attic/patch-pymsgauth-tag
$NetBSD: patch-pymsgauth-tag,v 1.1 2017/06/17 13:55:06 schmonz Exp $

Add pymsgauth-tag, a Unix filter that takes an RFC822 mail message on stdin
and prints it to stdout, adding a pymsgauth token in the header if needed.

--- pymsgauth-tag.orig	2017-05-31 01:57:20.000000000 +0000
+++ pymsgauth-tag
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+from pymsgauth import *
+
+import cStringIO
+import sys
+
+msg = tokenize_message_if_needed (cStringIO.StringIO (sys.stdin.read ()))
+sys.stdout.write (msg)

File Added: pkgsrc/mail/pymsgauth/patches/Attic/patch-pymsgauth.py
$NetBSD: patch-pymsgauth.py,v 1.1 2017/06/17 13:55:06 schmonz Exp $

Add pymsgauth-tag, a Unix filter that takes an RFC822 mail message on stdin
and prints it to stdout, adding a pymsgauth token in the header if needed.

--- pymsgauth.py.orig	2003-12-15 16:49:28.000000000 +0000
+++ pymsgauth.py
@@ -362,9 +362,24 @@ def sendmail_wrapper (args):
         mailcmd += args
         log (TRACE, 'mailcmd == %s' % mailcmd)
         buf = cStringIO.StringIO (sys.stdin.read())
-        msg = rfc822.Message (buf, seekable=1)
+        new_buf = tokenize_message_if_needed (buf, args)
+
+        send_mail (new_buf, mailcmd)
+        if (new_buf != buf.getvalue ()):
+            log (TRACE, 'Sent tokenized mail.')
+        else:
+            log (TRACE, 'Passed mail through unchanged.')
+
+    except StandardError, txt:
+        log (FATAL, 'Fatal:  caught exception (%s)' % txt)
+        log_exception ()
+        sys.exit (1)
 
+#############################
+def should_tokenize_message (msg, *args):
+    try:
         sign_message = 0
+
         for arg in args:
             if arg in config['token_recipient']:
                 sign_message = 1
@@ -378,15 +393,27 @@ def sendmail_wrapper (args):
                 if recip in config['token_recipient']:
                     sign_message = 1
                     break
-        if sign_message:
+
+        return sign_message
+
+    except StandardError, txt:
+        log (FATAL, 'Fatal:  caught exception (%s)' % txt)
+        log_exception ()
+        sys.exit (1)
+
+#############################
+def tokenize_message_if_needed (buf, *args):
+    try:
+        read_config ()
+        log (TRACE)
+        msg = rfc822.Message (buf, seekable=1)
+
+        if should_tokenize_message (msg, args):
             token = gen_token (msg)
             log (INFO, 'Generated token %s.' % token)
-            new_buf = '%s: %s\n' % (config['auth_field'], token) + buf.getvalue ()
-            send_mail (new_buf, mailcmd)
-            log (TRACE, 'Sent tokenized mail.')
+            return '%s: %s\n' % (config['auth_field'], token) + buf.getvalue ()
         else:
-            send_mail (buf.getvalue (), mailcmd)
-            log (TRACE, 'Passed mail through unchanged.')
+            return buf.getvalue ()
 
     except StandardError, txt:
         log (FATAL, 'Fatal:  caught exception (%s)' % txt)