lovstrand.EuroPARC@XEROX.COM (07/21/90)
OK, on the suggestion of Nathaniel Borenstein, here comes a patch to ams/libs/ms/cvtold.c that will convert incoming "From " lines to "Return-Paths". As a bonus (but probably not with nsb's blessing ;-), I've also included a patch to ams/libs/ms/submsg.c that will adhere to RFC822 and allow user-supplied "From" lines while inserting an additional "Sender" if necessary. I also took the liberty of disabling the requirement of a "Subject". OK, so sue me, as someone else said recently... Cheers, --Lennart (Off to Bonny Scotland for half a fortnight) Prerequisits: AMS patch level 5. Apply by connecting to ams/libs/ms and piping the message through patch. *** cvtold.c~ Wed Nov 22 16:32:32 1989 --- cvtold.c Fri Jul 20 18:54:56 1990 *************** *** 252,257 **** --- 252,289 ---- AnyWrittenToThisOne = 1; ReadyToStartAgain = 0; } + } else if (!AnyWrittenToThisOne && strncmp(buffer, "From ", 5) == 0) { + /* + * Andrew makes a bit of a mess out of UNIX envelope sender + * lines ("From " lines), so we'd better change them into + * something useful, like "Return-Path:"'s. + * --Lennart Lovstrand, Rank Xerox EuroPARC, May 1990. + * + * The format of a "From " line is: + * "From <sender> <date> [remote from <host>]" + * There is a chance sender will contain spaces (enclosed in + * quotes or escaped by backslash), so we can't just index on + * a space. + */ + char *p; + int quoted = FALSE, escaped = FALSE; + + for (p = &buffer[5]; *p != '\0'; p++) { + if (escaped) + escaped = FALSE; + else if (*p == '\\') + escaped = TRUE; + else if (*p == '"') + quoted = !quoted; + else if (*p == ' ') + break; + } + *p = '\0'; + writeall(wfd, "Return-Path: <", 14); + writeall(wfd, &buffer[5], strlen(&buffer[5])); + writeall(wfd, ">\n", 2); + AnyWrittenToThisOne = TRUE; + ReadyToStartAgain = FALSE; } else { ReadyToStartAgain = (buffer[0] == '\n') ? 1 : 0; writeall(wfd, buffer, strlen(buffer)); *** submsg.c~ Fri Jan 26 22:14:51 1990 --- submsg.c Fri Jul 20 19:37:10 1990 *************** *** 200,209 **** --- 200,217 ---- } } else { + /* + * Wait a minute, they've gotten a bit overboard here -- there + * is nothing wrong with a user-supplied "From" line, it's only + * the authenticity of the "Sender" that has to be protected. + * --Lennart Lovstrand, Rank Xerox EuroPARC, May 1990 + */ + #ifdef notdef while (Msg->ParsedStuff->HeadBody[HP_FROM]) { NonfatalBizarreError("Deleting a user-supplied 'From' header line."); DeleteHeader(Msg, HP_FROM); } + #endif notdef while (Msg->ParsedStuff->HeadBody[HP_SENDER]) { NonfatalBizarreError("Deleting a user-supplied 'Sender' header line."); DeleteHeader(Msg, HP_SENDER); *************** *** 278,289 **** newreceived(ClientProgram), newmid(), arpadate(), MyPrettyAddress); } else { ! sprintf(NewHeads, "%sMessage-ID: %s\nDate: %sFrom: %s", ! newreceived(ClientProgram), newmid(), arpadate(), MyPrettyAddress); if (Msg->ParsedStuff->HeadBody[HP_SUBJECT] == NULL) { /* OK in resend */ FreeMessage(Msg, TRUE); AMS_RETURN_ERRCODE(EMSNOSUBJ, EIN_PARAMCHECK, EVIA_SUBMITMESSAGE); } } AddHeader(Msg, NewHeads); if (DeliveryOptions & AMS_SEND_ISRESEND) { --- 286,313 ---- newreceived(ClientProgram), newmid(), arpadate(), MyPrettyAddress); } else { ! /* ! * Insert a authenticated "Sender" if a "From" header already ! * exists. Ideally, we ought to first check if the user-supplied ! * "From" address is semantically the same as the sender, but ! * it's easier (and safer) to just add a new "Sender". ! * --Lennart Lovstrand, Rank Xerox EuroPARC, May 1990. ! */ ! sprintf(NewHeads, "%sMessage-ID: %s\nDate: %s%s: %s", ! newreceived(ClientProgram), newmid(), arpadate(), ! Msg->ParsedStuff->HeadBody[HP_FROM] ? "Sender" : "From", ! MyPrettyAddress); ! /* ! * This is bogus -- there is nothing illegal with a subjectless ! * message. (I wish they'd just issued a warning instead) ! * --Lennart Lovstrand, Rank Xerox EuroPARC, May 1990. ! */ ! #ifdef notdef if (Msg->ParsedStuff->HeadBody[HP_SUBJECT] == NULL) { /* OK in resend */ FreeMessage(Msg, TRUE); AMS_RETURN_ERRCODE(EMSNOSUBJ, EIN_PARAMCHECK, EVIA_SUBMITMESSAGE); } + #endif notdef } AddHeader(Msg, NewHeads); if (DeliveryOptions & AMS_SEND_ISRESEND) {