diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2019-01-07 21:48:38 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2019-01-07 21:48:38 +0100 |
commit | 98222694f92aeecfcbb216fd1cb835b9550aa6d6 (patch) | |
tree | 94f06e87ee4eb2145b46be89db141d82507c630d /src/cmd/upas/smtp | |
parent | d95f1bcc4938b3b0b7f832b67575e07a87095721 (diff) | |
parent | 2607cc565ee3d5facb8949e9acfed35c8ae300c9 (diff) | |
download | plan9port-98222694f92aeecfcbb216fd1cb835b9550aa6d6.tar.gz plan9port-98222694f92aeecfcbb216fd1cb835b9550aa6d6.tar.bz2 plan9port-98222694f92aeecfcbb216fd1cb835b9550aa6d6.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd/upas/smtp')
-rw-r--r-- | src/cmd/upas/smtp/mxdial.c | 48 | ||||
-rw-r--r-- | src/cmd/upas/smtp/smtp.c | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/cmd/upas/smtp/mxdial.c b/src/cmd/upas/smtp/mxdial.c index f3a2a209..56962dcd 100644 --- a/src/cmd/upas/smtp/mxdial.c +++ b/src/cmd/upas/smtp/mxdial.c @@ -2,6 +2,7 @@ #include <ndb.h> #include "smtp.h" /* to publish dial_string_parse */ #include <ip.h> +#include <thread.h> enum { @@ -27,6 +28,45 @@ static int callmx(DS*, char*, char*); static void expand_meta(DS *ds); extern int cistrcmp(char*, char*); +/* Taken from imapdial, replaces tlsclient call with stunnel */ +static int +smtpdial(char *server) +{ + int p[2]; + int fd[3]; + char *tmp; + char *fpath; + + if(pipe(p) < 0) + return -1; + fd[0] = dup(p[0], -1); + fd[1] = dup(p[0], -1); + fd[2] = dup(2, -1); +#ifdef PLAN9PORT + tmp = smprint("%s:587", server); + fpath = searchpath("stunnel3"); + if (!fpath) { + werrstr("stunnel not found. it is required for tls support."); + return -1; + } + if(threadspawnl(fd, fpath, "stunnel", "-n", "smtp" , "-c", "-r", tmp, nil) < 0) { +#else + tmp = smprint("tcp!%s!587", server); + if(threadspawnl(fd, "/bin/tlsclient", "tlsclient", tmp, nil) < 0){ +#endif + free(tmp); + close(p[0]); + close(p[1]); + close(fd[0]); + close(fd[1]); + close(fd[2]); + return -1; + } + free(tmp); + close(p[0]); + return p[1]; +} + int mxdial(char *addr, char *ddomain, char *gdomain) { @@ -100,13 +140,21 @@ callmx(DS *ds, char *dest, char *domain) } /* dial each one in turn */ for(i = 0; i < nmx; i++){ +#ifdef PLAN9PORT + snprint(addr, sizeof(addr), "%s", mx[i].host); +#else snprint(addr, sizeof(addr), "%s!%s!%s", ds->proto, mx[i].host, ds->service); +#endif if(debug) fprint(2, "mxdial trying %s (%d)\n", addr, i); atnotify(timeout, 1); alarm(10*1000); +#ifdef PLAN9PORT + fd = smtpdial(addr); +#else fd = dial(addr, 0, 0, 0); +#endif alarm(0); atnotify(timeout, 0); if(fd >= 0) diff --git a/src/cmd/upas/smtp/smtp.c b/src/cmd/upas/smtp/smtp.c index 9dd05596..92873723 100644 --- a/src/cmd/upas/smtp/smtp.c +++ b/src/cmd/upas/smtp/smtp.c @@ -467,6 +467,7 @@ hello(char *me, int encrypted) } ehlo = 1; + encrypted = 1; Again: if(ehlo) dBprint("EHLO %s\r\n", me); |