Re: [vchkpw] vdelivermail writes the wrong ,S= value when spamassassin is enabled

2015-09-17 Thread Rolf Eike Beer
> When spamassassin is enabled but maildrop is not I see failed assertions in
> dovecots POP server[2], which are caused by vdelivermail using a wrong
> filename. The filename, more exactly the S= value is calculated
> _before_ the mail is piped into spamassassin, which adds two more header
> lines with it's scan results, so the actual size afterwards is bigger than
> what is recorded. The attached patch #5 fixes this for me, with some
> cleanups in #1-#4 I did on the way to find the culprit.

Ping?

signature.asc
Description: This is a digitally signed message part.
!DSPAM:55fafb1041552455840022!

[vchkpw] vdelivermail writes the wrong ,S= value when spamassassin is enabled

2014-09-09 Thread Rolf Eike Beer
Hi,

my setup is as follows: I use Qsmtp[1] to do the SMTP part, use (net)qmail for
the queueing, use vpopmail 5.4.33 for the user/domain stuff. The users get
their mail through IMAP or POP using dovecot. For some users I have maildrop
and/or spamassassin enabled.

When spamassassin is enabled but maildrop is not I see failed assertions in
dovecots POP server[2], which are caused by vdelivermail using a wrong
filename. The filename, more exactly the S=size value is calculated _before_
the mail is piped into spamassassin, which adds two more header lines with
it's scan results, so the actual size afterwards is bigger than what is
recorded. The attached patch #5 fixes this for me, with some cleanups in #1-#4
I did on the way to find the culprit.

Also attached is another patch I on my server to make the user and domain
directories world-accessible so the incoming SMTP process can read config
files from the user and domain directories for user-defined filtering. The
maildirs itself are still 0700 so it has no access to them.

While talking about patches, here are the patches that Gentoo applies to
vpopmail, which may or may not be useful for being taken upstream:
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-mail/vpopmail/files/

Eike

1) shameless plug: http://opensource.sf-tec.de/Qsmtp/
2) http://dovecot.org/pipermail/dovecot/2014-August/097548.htmlFrom e402c2f49b25d78af3e9ee90b030678972294755 Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer k...@opensource.sf-tec.de
Date: Thu, 21 Aug 2014 17:34:27 +0200
Subject: [PATCH 1/5] vdelivermail: add static

---
 vdelivermail.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vdelivermail.c b/vdelivermail.c
index d94129f..241106e 100644
--- a/vdelivermail.c
+++ b/vdelivermail.c
@@ -322,7 +322,7 @@ int process_valias(void)
 #endif

 /* Forks off qmail-inject.  Returns PID of child, or 0 for failure. */
-pid_t qmail_inject_open(char *address)
+static pid_t qmail_inject_open(char *address)
 {
  int pim[2];
  pid_t pid;
@@ -351,7 +351,7 @@ pid_t qmail_inject_open(char *address)
 return(pid);
 }

-int fdcopy (int write_fd, int read_fd, const char *extra_headers, size_t headerlen, char *address)
+static int fdcopy (int write_fd, int read_fd, const char *extra_headers, size_t headerlen, char *address)
 {
   char msgbuf[4096];
   ssize_t file_count;
--
1.8.4.5

From af7e1c5ede39340e12f93253b6a53f5459c97900 Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer k...@opensource.sf-tec.de
Date: Thu, 21 Aug 2014 17:36:36 +0200
Subject: [PATCH 2/5] fix those vfork() instances that do more than exec*()

---
 vdelivermail.c | 4 ++--
 vpopmail.c | 8 
 vqmaillocal.c  | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/vdelivermail.c b/vdelivermail.c
index 241106e..be83a2a 100644
--- a/vdelivermail.c
+++ b/vdelivermail.c
@@ -330,7 +330,7 @@ static pid_t qmail_inject_open(char *address)

 if ( pipe(pim) == -1) return 0;

-switch(pid=vfork()){
+switch(pid=fork()){
   case -1:
 close(pim[0]);
 close(pim[1]);
@@ -381,7 +381,7 @@ static int fdcopy (int write_fd, int read_fd, const char *extra_headers, size_t
!(vpw-pw_gid  NO_SPAMASSASSIN) ) {

 if (!pipe(pim)) {
-  pid = vfork();
+  pid = fork();
   switch (pid) {
case -1:
 close(pim[0]);
diff --git a/vpopmail.c b/vpopmail.c
index a2bdc0b..7a4657f 100644
--- a/vpopmail.c
+++ b/vpopmail.c
@@ -1472,9 +1472,9 @@ int update_newu()
 {
  int pid;

-  pid=vfork();
+  pid=fork();
   if ( pid==0){
-			  umask(022);
+umask(022);
 execl(QMAILNEWU,qmail-newu, NULL);
 exit(127);
   } else {
@@ -3360,9 +3360,9 @@ long unsigned tcprules_open()
   /* create a pair of filedescriptors for our pipe */
   if (pipe(pim) == -1)  { return(-1);}

-  switch( pid=vfork()){
+  switch( pid=fork()){
case -1:
-/* vfork error. close pipes and exit */
+/* fork error. close pipes and exit */
 close(pim[0]); close(pim[1]);
 return(-1);
case 0:
diff --git a/vqmaillocal.c b/vqmaillocal.c
index 6d3068c..80efa24 100644
--- a/vqmaillocal.c
+++ b/vqmaillocal.c
@@ -359,7 +359,7 @@ long unsigned qmail_inject_open(char *address)

 if ( pipe(pim) == -1) return(-1);

-switch(pid=vfork()){
+switch(pid=fork()){
 case -1:
 close(pim[0]);
 close(pim[1]);
--
1.8.4.5

From 88d305d9f072639ed4bc2705b46708e706a50ffc Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer k...@opensource.sf-tec.de
Date: Thu, 21 Aug 2014 17:45:28 +0200
Subject: [PATCH 3/5] remove unneeded forward declaration

---
 vchkpw.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/vchkpw.c b/vchkpw.c
index b1c8a5d..d7d4351 100644
--- a/vchkpw.c
+++ b/vchkpw.c
@@ -91,7 +91,6 @@ void login_system_user();
 void read_user_pass();
 void vlog(int verror, char *TheUser, char *TheDomain, char *ThePass, char *TheName, char *IpAddr, char *LogLine);
 void vchkpw_exit(int err