I wrote a patch that adds an extension to maildrop to support vpopmail.
Using this patch maildrop can totally replace vdelivermail and can by
invoked from the .qmail-default of a virtual domain. It also adds the
ability to specify a virtual address in the form of [EMAIL PROTECTED]
after the -d option. It also adds a new option [-b defaultaccount] that
if specified it would deliver mail to the default mailbox if the user
does not exist, if not specified the mail will bounce back to sender.
Offcourse, it could not be used together with userdb extension. It also
needs adding two lines in maildrop/config.h ( should be automatically
added by configure script , but till now do it manually ).
#define VPOPMAIL 1
#define VPOPUSER vpopmail

In maildrop/Makefile add
LIBS = -lvpopmail -L/home/vpopmail/lib
( I also add -lmysqlclient since I use mysql authentication for vpopmail
)

I tested it on my system, and it seems to be working fine.

28,30c28
< #if   VPOPMAIL
< #include      "vpopmail.h"
< #endif
---
> 
65,69c63
<       mout << "Usage: maildrop [options] [-d user] 
< #if VPOPMAIL
<       [-b defaultuser]
< #endif
<       [arg] [arg] ...\n";
---
>       mout << "Usage: maildrop [options] [-d user] [arg] [arg] ...\n";
91,97d84
< #if VPOPMAIL
< static void argconflict()
< {
<       errexit=EX_TEMPFAIL;
<       throw "Cannot use both -b and -d options together.";
< }
< #endif
193,200d179
< #if VPOPMAIL
<       "Vpopmail extension enabled."
< #if CRLF_TERM
<       "\r\n"
< #else
<       "\n"
< #endif
< #endif
252,254d230
< #if VPOPMAIL
< const char *defaultaccount = 0;
< #endif
290,292d265
< #if VPOPMAIL
<                       if (defaultaccount) argconflict();                      
< #endif
342,348d314
< #if VPOPMAIL
<               case 'b':
<                       if (deliverymode) argconflict();
<                       if (!*optarg && argn < argc)    optarg=argv[argn++];
<                       defaultaccount = optarg;
<                       break;
< #endif
418,459d383
< #if VPOPMAIL
<               struct passwd *pw=NULL, *vpoppw=NULL;
<               char *maildir;
<               char *addr = strdup(deliverymode);
<               char *user = strtok(addr , "@");
<               char *host = strtok(NULL, "|");
<               
<               if ((vpoppw = getpwnam(VPOPUSER)) == NULL) {
<                       errexit=EX_TEMPFAIL;
<                       throw "Vpopmail user unknown";
<               }
<               
<               pw = vauth_getpw(user , host);
<               free(addr);
<               
<                       if (pw != NULL )
<                       {
< #if   RESET_GID
<                               setgroupid(getgid());
< #endif
<                               setuid(vpoppw->pw_uid);
<                               if (getuid() != vpoppw->pw_uid)
<                                       nochangeuidgid(); // Security violation.
< 
<                               if (strncmp(pw->pw_shell , "NOQUOTA" , 7 ))
<                                       maildrop.init_quota=pw->pw_shell;
<                               maildrop.init_home=pw->pw_dir;
<                               maildir = (char *) malloc(strlen(pw->pw_dir)+ 10);
<                               strcat(strcpy(maildir,pw->pw_dir),"/Maildir/");
<                               // maybe an error here
<                               maildrop.init_logname=deliverymode;
<                               maildrop.init_shell="/bin/sh";
<                               maildrop.init_default=maildir;
<                               free(maildir);
<                               //mout << "Debugging \n";
<                               //mout << maildrop.init_home << maildrop.init_logname;
<                               //free(pw);
<                               //free(vpoppw);
<                               found=1;
<                       }
<                       else
< #endif
479c403
<                       } 
---
>                       }
590,626d513
< #if   VPOPMAIL
<               struct passwd *pw=NULL, *vpoppw=NULL;
<               char *maildir;
<               char *user = getenv("EXT");
<               char *domain = getenv("HOST");
<               if ((vpoppw = getpwnam(VPOPUSER)) == NULL) {
<                                       errexit=EX_TEMPFAIL;
<                                       throw "Vpopmail user unknown";
<               } 
<               if ((vpoppw->pw_uid == my_u)) {
<               if ((pw = vauth_getpw( user , domain)) == NULL)
<               {
<               // bounceit or deliver to default account
<               if (!defaultaccount) {
<                       mout << "Sorry, no mail box here by this name";
<                       exit(100);
<               } else  if ((pw = vauth_getpw((char *) defaultaccount , domain )) == 
NULL ) {
<                                       errexit=EX_TEMPFAIL;
<                                       throw "GAG : Default user for domain does not 
exist";
<                       } 
<               
<               }
<               
<               if (strncmp(pw->pw_shell , "NOQUOTA" , 7 ))
<                       maildrop.init_quota=pw->pw_shell;
<               maildrop.init_home=pw->pw_dir;
<               maildir = (char *) malloc(strlen(pw->pw_dir)+ 10);
<               strcat(strcpy(maildir,pw->pw_dir),"/Maildir/");
<               // maybe an error here
<               maildrop.init_logname=pw->pw_name;
<               maildrop.init_shell="/bin/sh";
<               maildrop.init_default=maildir;
<               free(maildir);
<               
<               }
<               else
< #endif
647,649d533
< #endif
< #if   VPOPMAIL
<       vclose();
#ifndef vpopheader
#define vpopheader
extern "C" struct passwd *vauth_getpw(char *,char *);
extern "C" int vclose(void);
#endif

Reply via email to