On Friday 02 April 2004 12:07 pm, Tom Collins wrote:
This was emailed directly to me, but I think it is of importance to the
list. I don't have time to look into it further, but we definitely
need a change. vdelivermail() calls qmail-inject when processing
forwards in a .qmail file, but does not wait for qmail-inject to finish
before exiting.
On Mar 26, 2004, at 9:01 AM, Salvatore Lazzari wrote:
I've a question for you.
State of art:
- maildrop filter mail delivery
- i have some forwards sett'up via qmailadmin
Problem:
Vdelivermail doesn't process .qmail fw file created by qmailadmin
when
called by maildrop
Vdelivermail processes it well when called directly.
I solved it modifing the code in vdelivermail.c:
=if ( inject == 1 ) {
=close(write_fd);
+sleep(2);
=return(0);
=}
Question:
Is there a kind of security/performance related issue to add the
sleep()
call?
Instead of the sleep, vdelivermail should wait for the qmail-inject
process to finish.
Thanks for catching this, it will require a bit of extra coding and
testing to be sure that we're doing things correctly. It should work
something like this (I think).
pid_t pid;
int childstatus;
pid = qmail_inject_open(address);
...
if ( inject == 1 ) {
close(write_fd);
waitpid (pid, childstatus, 0);
/* we should check childstatus here and fail accordingly if
qmail-inject failed */
return (0);
}
one two continuing
Here is a patch. Tested on my machine and working nicely.
It is also in the cvs version. Basicly the same code as Tom
has above with a return(wait_exitcode(childstatus) instead
of return(0);
--- vpopmail-5.5.1/vdelivermail.c 2004-03-14 12:00:40.0 -0600
+++ vpopmail.new/vdelivermail.c 2004-04-02 12:40:52.0 -0600
@@ -448,8 +448,9 @@
time_t tm;
off_t file_count;
long unsigned pid;
+ long unsigned inject_pid = 0;
+ int child;
int write_fd;
- int inject = 0;
FILE *fs;
char tmp_file[256];
#ifdef SPAMASSASSIN
@@ -589,9 +590,8 @@
char *atpos;
int dtlen;
- qmail_inject_open(address);
+ inject_pid = qmail_inject_open(address);
write_fd = fdm;
- inject = 1;
/* use the DTLINE variable, but skip past the dash in
* [EMAIL PROTECTED]
@@ -729,9 +729,10 @@
}
}
}
-if ( inject == 1 ) {
+if ( inject_pid != 0 ) {
close(write_fd);
-return(0);
+waitpid(inject_pid,child,0);
+return(wait_exitcode(child));
}
/* if we are writing to a Maildir, move it