diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-10-01 14:49:35 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-10-01 14:49:35 +0000 |
commit | c99b1baee80ce21cddef57d80b1cec20e6f43c05 (patch) | |
tree | d2702879869a25007d508cb3efb48ab39f4036f1 | |
parent | ef347762e7b7bfe5f8cd2f9e5a9b8c8f84b874a6 (diff) | |
download | fetchmail-c99b1baee80ce21cddef57d80b1cec20e6f43c05.tar.gz fetchmail-c99b1baee80ce21cddef57d80b1cec20e6f43c05.tar.bz2 fetchmail-c99b1baee80ce21cddef57d80b1cec20e6f43c05.zip |
Added %F and %T escapes.
svn path=/trunk/; revision=1460
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | driver.c | 80 | ||||
-rw-r--r-- | fetchmail.man | 3 |
3 files changed, 62 insertions, 26 deletions
@@ -13,7 +13,10 @@ ------------------------------------------------------------------------------ fetchmail-4.3.0 () -* FAQ update. +* Rearranged IMAP authentication so CAPABILITY is done first, +* FAQ update, including a major new item on how to protect your password. +* Added code to have %F in an MDA string expand to the From address +* Added code to prevent buffer spamming via the MDA %T/%s escape. There are 286 people on the fetchmail-friends list. @@ -846,37 +846,69 @@ int num; /* index of message */ else if (ctl->mda) /* we have a declared MDA */ { int length = 0; - char *names, *cmd; + char *names, *before, *after; - desthost = "localhost"; - - /* - * We go through this in order to be able to handle very - * long lists of users and (re)implement %s. - */ for (idp = xmit_names; idp; idp = idp->next) if (idp->val.num == XMIT_ACCEPT) - { - length += (strlen(idp->id) + 1); good_addresses++; - } - names = (char *)alloca(++length); - names[0] = '\0'; - for (idp = xmit_names; idp; idp = idp->next) - if (idp->val.num == XMIT_ACCEPT) - { - strcat(names, idp->id); - strcat(names, " "); - } - length += strlen(ctl->mda); - cmd = (char *)alloca(length); + + desthost = "localhost"; + + length = strlen(ctl->mda) + 1; + before = strdup(ctl->mda); + + /* sub user addresses for %T (or %s for backward compatibility) */ + cp = (char *)NULL; + if (strstr(before, "%s") || (cp = strstr(before, "%T"))) + { + if (cp && cp[1] == 'T') + cp[1] = 's'; + + /* + * We go through this in order to be able to handle very + * long lists of users and (re)implement %s. + */ + for (idp = xmit_names; idp; idp = idp->next) + if (idp->val.num == XMIT_ACCEPT) + length += (strlen(idp->id) + 1); + + names = (char *)alloca(++length); + names[0] = '\0'; + for (idp = xmit_names; idp; idp = idp->next) + if (idp->val.num == XMIT_ACCEPT) + { + strcat(names, idp->id); + strcat(names, " "); + } + after = (char *)alloca(length); +#ifdef SNPRINTF + snprintf(after, length, before, names); +#else + sprintf(after, before, names); +#endif /* SNPRINTF */ + free(before); + before = after; + } + + /* substitute From address for %F */ + if ((cp = strstr(before, "%F"))) + { + char *from = nxtaddr(headers + from_offs); + + length += strlen(from); + after = alloca(length); + cp[1] = 's'; #ifdef SNPRINTF - snprintf(cmd, length, ctl->mda, names); + snprintf(after, length, before, from); #else - sprintf(cmd, ctl->mda, names); + sprintf(after, before, from); #endif /* SNPRINTF */ + free(before); + before = after; + } + if (outlevel == O_VERBOSE) - error(0, 0, "about to deliver with: %s", cmd); + error(0, 0, "about to deliver with: %s", before); #ifdef HAVE_SETEUID /* @@ -888,7 +920,7 @@ int num; /* index of message */ seteuid(ctl->uid); #endif /* HAVE_SETEUID */ - sinkfp = popen(cmd, "w"); + sinkfp = popen(before, "w"); #ifdef HAVE_SETEUID /* this will fail quietly if we didn't start as root */ diff --git a/fetchmail.man b/fetchmail.man index 53d50d63..6cb0e0e9 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -205,7 +205,8 @@ is running as root, it sets its userid to that of the target user while delivering mail through an MDA. Some possible MDAs are "/usr/sbin/sendmail -oem", "/usr/lib/sendmail -oem", "/usr/bin/formail", and "/usr/bin/deliver". Local delivery addresses -will be inserted into the MDA command wherever you place a %s. Do +will be inserted into the MDA command wherever you place a %T; the +mail message's From address will be inserted where you place an %F. Do \fInot\fR use an MDA invocation like "sendmail -oem -t" that dispatches on the contents of To/Cc/Bcc, it will create mail loops and bring the just wrath of many postmasters |