On Wed, 2009-03-11 at 13:04 -0500, Matt Brookings wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Rick Romero wrote: > > According to the Wiki, it's supposed to be implemented as such: > > http://wiki.dovecot.org/LDA/Qmail > > > > Add the -d parameter to specify the destination username: > > > > |/var/qmail/bin/preline -f /usr/local/libexec/dovecot/deliver -d $...@$user > > > > But the 'core' LDA Wiki shows that to deliver WITHOUT doing a lookup > > (because we already know where it will be delivered), you can do: > > > > HOME=/path/to/user/homedir deliver -f $FROM_ENVELOPE > > > > What I was going to test (and just haven't gotten around to it) is what > > '-f' is for. If it's for bounces, then we can essentially ignore it as > > long as deliver doesn't complain. > > Then all vdelivermail would need to do is set the HOME environment > > variable, and pipe the message to deliver. > > Sounds easy enough. I'll look further into this once I get a chance. > Probably sometime early next week. > ..but, if someone has time now, be my guest :)
Ok. #1. deliver won't run as root. This is fine for us I belive, unless you want to test from the command line as root :/ #2. Once I figured out how to become vpopmail and run commands, simply doing (I was running csh on FreeBSD): %set home = /home/vpopmail/domains/havokmon.com/rick/ % cat /home/vpopmail/domains/havokmon.com/rick/Maildir/cur/1236788062.63198.mx.vfemail.net,S=2092:2,S | /usr/local/libexec/dovecot/deliver Delivered a brand new copy of an existing email into my Inbox. I think it'll work just dandy if vdelivermail set's the HOME variable and writes the email to stdout. I assume this would be a compile time option? Or how about one of those fancy, "if the program is called as 'x' do x, otherwise do y" filename checks? I attached a patch, but I think testing this is going to be a pita unless someone has some sort of shell 'vdelivermail' tester ? Oh - and I'm not sure what the best way is to 'chomp' /Maildir off the maildir variable.. I'm just a hacker. Rick !DSPAM:49b80efb32682044720806!
--- vpopmail-5.4.17/vdelivermail.c Thu Jun 29 14:36:43 2006 +++ vpopmail-5.4.17-vfe/vdelivermail.c Wed Mar 11 14:14:11 2009 @@ -411,6 +411,7 @@ size_t headerlen; int write_fd; char quota[80]; + char home[150]; headerlen = strlen (extra_headers); msgsize += headerlen; @@ -426,7 +427,19 @@ maildir, tm, pid, hostname, (long unsigned) msgsize); read_quota_from_maildir (maildir, quota, sizeof(quota)); - +#ifdef DELIVER_STDOUT + /* export HOME environment variable - strip /Maildir/ */ + sprintf(home, "HOME=%s", maildir); + putenv(home); + /* echo email */ + if (fdcopy (1, read_fd, extra_headers, headerlen) != 0) { + printf("echo to stdout failed\n"); + return -2; + }else{ + /* Email sent to STDOUT */ + return 0; + } +#else /* open the new email file */ if ((write_fd=open(local_file_tmp, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)) == -1) { if (errno == EDQUOT) return -1; @@ -487,6 +500,7 @@ /* return failure (sync/close failed, message NOT delivered) */ return -2; +#endif } /*