From 4afb26581718df2d8e889bdf946fca2d58f7b2a7 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Tue, 23 Jul 2013 16:01:03 +0000 Subject: - Add support to have vdelivermail send to stdout by defining DELIVER_TO_STDOUT in the environment. This is useful when using dovecot as an LDA. See more discussion at: http://www.mail-archive.com/vchkpw@inter7.com/msg26694.html --- mail/vpopmail/Makefile | 2 +- mail/vpopmail/files/patch-vdelivermail.c | 39 +++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) (limited to 'mail') diff --git a/mail/vpopmail/Makefile b/mail/vpopmail/Makefile index 924b8c78df6c..99937a54b34b 100644 --- a/mail/vpopmail/Makefile +++ b/mail/vpopmail/Makefile @@ -3,7 +3,7 @@ PORTNAME= vpopmail PORTVERSION= 5.4.32 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= mail MASTER_SITES= SF/${PORTNAME}/${PORTNAME}-stable/${PORTVERSION} \ SF/${PORTNAME}/${PORTNAME}-devel/${PORTVERSION} diff --git a/mail/vpopmail/files/patch-vdelivermail.c b/mail/vpopmail/files/patch-vdelivermail.c index 166b3cc3a464..e59495558c6a 100644 --- a/mail/vpopmail/files/patch-vdelivermail.c +++ b/mail/vpopmail/files/patch-vdelivermail.c @@ -1,13 +1,15 @@ Description: SpamAssassin support, build optimization Add SpamAssassin support. Drop the unneeded MAX_ENV_BUFF definition. + Add DELIVER_TO_STDOUT support Forwarded: not-needed Author: Alex Dupre , - Peter Pentchev -Last-Update: 2010-01-05 + Peter Pentchev , + Bryan Drewery +Last-Update: 2013-07-23 ---- a/vdelivermail.c -+++ b/vdelivermail.c +--- vdelivermail.c.orig 2010-11-08 09:02:52.000000000 -0600 ++++ vdelivermail.c 2013-07-23 10:44:11.392127088 -0500 @@ -74,6 +74,7 @@ int is_spam(); #endif @@ -86,7 +88,7 @@ Last-Update: 2010-01-05 { #ifdef HOST_NAME_MAX char hostname[HOST_NAME_MAX]; -@@ -493,21 +511,25 @@ +@@ -493,21 +511,36 @@ char local_file_tmp[FILE_SIZE]; char local_file_new[FILE_SIZE]; size_t headerlen; @@ -103,6 +105,17 @@ Last-Update: 2010-01-05 headerlen = strlen (extra_headers); - msgsize += headerlen; ++ if ((getenv("DELIVER_TO_STDOUT")) != NULL) { ++ if (fdcopy (1, read_fd, extra_headers, headerlen, ++ maildir_to_email(maildir)) != 0) { ++ printf("echo to stdout failed\n"); ++ return -2; ++ } else{ ++ /* Email sent to STDOUT */ ++ return 0; ++ } ++ } ++ /* Format the email file name */ /* we get the whole hostname, even though we only use 32 chars of it */ gethostname(hostname, sizeof(hostname)); @@ -117,7 +130,7 @@ Last-Update: 2010-01-05 read_quota_from_maildir (maildir, quota, sizeof(quota)); -@@ -548,6 +570,9 @@ +@@ -548,6 +581,9 @@ #endif close (write_fd) == 0 ) { @@ -127,7 +140,7 @@ Last-Update: 2010-01-05 if(DeleteMail == 1) { if (unlink(local_file_tmp) != 0) { printf("unlink failed %s errno = %d\n", local_file_tmp, errno); -@@ -556,7 +581,29 @@ +@@ -556,7 +592,29 @@ return(0); } @@ -157,7 +170,7 @@ Last-Update: 2010-01-05 if ( link( local_file_tmp, local_file_new ) == 0 ) { /* file was successfully delivered, remove temp file */ if ( unlink(local_file_tmp) != 0 ) { -@@ -616,6 +663,9 @@ +@@ -616,6 +674,9 @@ /* rewind the message */ lseek(0,0L,SEEK_SET); @@ -167,7 +180,7 @@ Last-Update: 2010-01-05 /* This is an command */ if ( *address == '|' ) { -@@ -723,7 +773,7 @@ +@@ -723,7 +784,7 @@ email); } @@ -176,7 +189,7 @@ Last-Update: 2010-01-05 case -1: vexiterr (EXIT_OVERQUOTA, "user is over quota"); break; -@@ -898,9 +948,6 @@ +@@ -898,9 +959,6 @@ */ void run_command(char *prog) { @@ -186,7 +199,7 @@ Last-Update: 2010-01-05 int child; char *(args[4]); int wstat; -@@ -1186,7 +1233,7 @@ +@@ -1186,7 +1244,7 @@ maildir_to_email(newdir), date_header()); } @@ -195,7 +208,7 @@ Last-Update: 2010-01-05 close (read_fd); -@@ -1214,19 +1261,22 @@ +@@ -1214,19 +1272,22 @@ * * in the email headers for X-Spam-Level: which * * we put in each spam email * * @@ -222,7 +235,7 @@ Last-Update: 2010-01-05 /* check for blank line, end of headers */ for(k=j,found=0;k