mailfront new plugin API
Bruce Guenter <[email protected]> Thu, 14 Jul 2011 14:34:59 -0600
| Newsgroups | gmane.comp.sysutils.bgware |
|---|---|
| Message-ID | <[email protected]> |
--XOIedfhf+7KOe/yw Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I've pushed out my current code for the next mailfront API to github as branch "api3". It incorporate all three suggestions -- plugins can now handle sender and recipient extra parameters, add capabilities, and add new commands. The command API is in a bit of flux -- the current fixed array of commands doesn't work well when the command is only present in certain cases. I've also adapted the mailfront ucspi-tls patch to this new API as "starttls-ucspi". It compiles, but I'm having a little trouble getting an appropriately patched sslserver setup on Gentoo. Could somebody test this for me? Just drop the attached file into the mailfront source directory and type: ./makeso plugin-starttls-ucspi.c -lbg -lbg-sysdeps and add starttls-ucspi to the mailfront command line. --=20 Bruce Guenter <[email protected]> http://untroubled.org/ --huq684BweRXVnRxX Content-Type: text/x-c; charset=us-ascii Content-Disposition: attachment; filename="plugin-starttls-ucspi.c" #include "mailfront.h" #include <stdlib.h> #include <unistd.h> static RESPONSE(unimp, 500, "5.5.1 Not implemented."); static RESPONSE(start, 220, "2.0.0 Ready to start TLS"); static int tls_available = 0; static const response* init(void) { tls_available = getenv("UCSPITLS") != 0; return 0; } static const response* helo(str* hostname, str* capabilities) { if (tls_available) if (!str_cats(capabilities, "STARTTLS\n")) return &resp_oom; return 0; (void)hostname; } static int starttls(void) { int fd; char *fdstr; if (!(fdstr=getenv("SSLCTLFD"))) return 0; if ((fd = atoi(fdstr)) <= 0) return 0; if (write(fd, "y", 1) < 1) return 0; if (!(fdstr=getenv("SSLREADFD"))) return 0; if ((fd = atoi(fdstr)) <= 0) return 0; if (dup2(fd, 0) != 0) return 0; if (!(fdstr=getenv("SSLWRITEFD"))) return 0; if ((fd = atoi(fdstr)) <= 0) return 0; if (dup2(fd, 1) != 1) return 0; return 1; } static int cmd_STARTTLS(void) { if (!tls_available) return respond(&resp_unimp); if (!respond(&resp_start)) return 0; if (!starttls()) return 0; tls_available = 0; return 1; } static const struct command commands[] = { { "STARTTLS", .fn_noparam = cmd_STARTTLS }, { .name = 0 } }; struct plugin plugin = { .version = PLUGIN_VERSION, .commands = commands, .init = init, .helo = helo, }; --huq684BweRXVnRxX-- --XOIedfhf+7KOe/yw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) iEYEARECAAYFAk4fUvMACgkQ6W+y3GmZgOjCVwCfV9VTe0wyLiC4DhG6zfiIHmSS BTAAoJK4xD3wvAPk5euTCMgCau997pAT =pjyV -----END PGP SIGNATURE----- --XOIedfhf+7KOe/yw--