vrcptcheck is a recipient check for e.h. s/qmail Just call this program within /var/qmail/control/recipients as follows: cat /home/vpopmail/bin/vrcptcheck > /var/qmail/control/recipients You have to provide an "autoreconf -f -i" before configuring, as the original Makefile.am has been modified. Roberto Puzzanghera, https://notes.sagredo.eu, Sep 23, 2021 ====================================================================================================== diff -ruN vpopmail-5.4.33-original/Makefile.am vpopmail-5.4.33/Makefile.am --- vpopmail-5.4.33-original/Makefile.am 2011-02-28 18:00:45.000000000 +0100 +++ vpopmail-5.4.33/Makefile.am 2021-09-23 19:01:43.513865014 +0200 @@ -31,7 +31,7 @@ vdeldomain vpasswd vadduser vdeluser vaddaliasdomain vsetuserquota \ vpopbull vdeloldusers vmoduser valias vuserinfo vmkpasswd vipmap \ vdominfo vconvert vkill vmoddomlimits vchangepw dotqmail2valias \ - vpopmaild vlist authvchkpw vusagec + vpopmaild vlist authvchkpw vusagec vrcptcheck vusagec_SOURCES = vusagec.c client.c conf.c ippp.c vusagec_LDADD = libvpopmail.a @auth_libs@ @@ -114,6 +114,9 @@ vmoddomlimits_SOURCES = vmoddomlimits.c vmoddomlimits_LDADD = libvpopmail.a @auth_libs@ +vrcptcheck_SOURCES = vrcptcheck.c +vrcptcheck_LDADD = libvpopmail.a @auth_libs@ + DEFS=-I. @auth_inc@ install: install-recursive vusage-msg diff -ruN vpopmail-5.4.33-original/doc/README.vrcptcheck vpopmail-5.4.33/doc/README.vrcptcheck --- vpopmail-5.4.33-original/doc/README.vrcptcheck 1970-01-01 01:00:00.000000000 +0100 +++ vpopmail-5.4.33/doc/README.vrcptcheck 2021-09-23 19:03:14.620060288 +0200 @@ -0,0 +1,8 @@ +vrcptcheck is a recipient check for s/qmail + +Just call this program within /var/qmail/control/recipients as follows: + +cat /home/vpopmail/bin/vrcptcheck > /var/qmail/control/recipients + +You have to provide an "autoreconf -f -i" before configuring, as the original +Makefiele.am has been modified. diff -ruN vpopmail-5.4.33-original/vrcptcheck.c vpopmail-5.4.33/vrcptcheck.c --- vpopmail-5.4.33-original/vrcptcheck.c 1970-01-01 01:00:00.000000000 +0100 +++ vpopmail-5.4.33/vrcptcheck.c 2021-09-24 13:42:48.251707925 +0200 @@ -0,0 +1,62 @@ +/* + * $Id: vrcptcheck.c 2021-09-23 + * Roberto Puzzanghera - https://notes.sagredo.eu + * + * Recipient check for s/qmail. + * Just call this program within /var/qmail/control/recipients as follows: + * cat /home/vpopmail/bin/vrcptcheck > /var/qmail/control/recipients + + * @file vrcptcheck.c + @return 0: virtual user exists + 1: virtual user does not exist + 111: temporary problem + */ + +#include +#include +#include +#include +#include +#include "vpopmail.h" + +#define FDAUTH 3 +char inputbuf[MAX_BUFF]; + +void pam_exit(int fail, DIR *dir) +{ + int i; + close(FDAUTH); + for (i = 0; i < sizeof(inputbuf); ++i) inputbuf[i] = 0; + if (dir != NULL) closedir(dir); + vexit(fail); +} + +void main(int argc, char *argv[]) +{ + char path[MAX_BUFF]; + DIR *dir; + + /* read input */ + if (read(FDAUTH, inputbuf, sizeof(inputbuf)) == -1) + { + fprintf(stderr, "qmail-smtpd: Error while reading file descriptor in vrcptcheck\n"); + pam_exit(111,NULL); + } + close(FDAUTH); + + /* retrieve username/domain (assuming that MAV has already been done) */ + int i = 0; + char *p = strtok (inputbuf, "@"); + char *recipient[2]; + while (p != NULL) + { + recipient[i++] = p; + p = strtok (NULL, "@"); + } + + /* recipient check */ + snprintf(path, MAX_BUFF, "%s/%s", vget_assign(recipient[1], NULL, 0, NULL, NULL), recipient[0]); + dir = opendir(path); + if (dir) pam_exit(0, dir); + else pam_exit(1, dir); +}