1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-17 00:00:40 +00:00
freebsd-ports/mail/popper/files/patch-ad
Andrey A. Chernov 76441fe1da Fix two longstanding bugs with Return-Path patch
1) wrong mbox size calculation
2) Return-Path was _never_ sent out
1998-06-30 06:42:18 +00:00

216 lines
6.2 KiB
Plaintext

These paths translate From_ lines into Return-Path: in unix style mailboxes.
If the mailbox is in MMDF format, it does nothing (since MMDF has already
done the Return-Path: translation while writing the message out.
WARNING: Do not merge these patches in with other patch files.
Keep them separate (Andrey, I mean you).
-- Paul Traina
17-Feb-1997
With old variant of this patch message size was counted incorrectly,
"rpath" variable can be referenced without initialization, second
Return-Path not skipped, fixed now.
-- Andrey Chernov
8-Oct-1997
This patch hits again: wrong mbox size calculation and Return-Path was never
writted out
-- Andrey Chernov
30-Jun-1998
*** pop_dropcopy.c.orig Thu Nov 20 00:20:38 1997
--- pop_dropcopy.c Tue Jun 30 10:19:40 1998
***************
*** 155,160 ****
--- 155,191 ----
return(ti != 0);
}
+ char *
+ return_path (const char *unixfrom)
+ {
+ static char tmpbuf[MAXLINELEN];
+ int fromlen = sizeof("From ") - 1;
+ const char *fp, *hp, *cp, *ep;
+
+ /* if it doesn't start with a From_, it's not */
+ if (strncmp(unixfrom, "From ", fromlen))
+ return NULL;
+
+ fp = unixfrom + fromlen;
+ hp = cp = strchr(fp, ' ');
+ while (hp = strchr(++hp, 'r'))
+ if (!strncmp(hp, "remote from", sizeof("remote from") - 1)) {
+ hp = strrchr(hp, ' ');
+ break;
+ }
+
+ if (hp) {
+ ep = strrchr(++hp, '\n');
+ snprintf(tmpbuf, sizeof(tmpbuf)-2, "Return-Path: %.*s!%.*s",
+ ep - hp, hp,
+ cp - fp, fp);
+ } else
+ snprintf(tmpbuf, sizeof(tmpbuf)-2, "Return-Path: %.*s",
+ cp - fp, fp);
+ strcat(tmpbuf, "\n");
+ return tmpbuf;
+ }
+
/* Hashing to a spool directory helps reduce the lookup time for sites
* with thousands of mail spool files. Unix uses a linear list to
* save directory information and the following methods attempt to
***************
*** 279,284 ****
--- 310,316 ----
char buffer[MAXLINELEN]; /* Read buffer */
MD5_CTX mdContext;
unsigned char digest[16];
+ char *rpath = NULL;
#ifdef DEBUG
if(p->debug)
***************
*** 343,348 ****
--- 375,383 ----
(p->mmdf_separator ? !strcmp(p->mmdf_separator, buffer) :
isfromline(buffer))) {
+ if (!p->mmdf_separator)
+ rpath = return_path(buffer);
+
if (expecting_trailer) {
/* skip over the MMDF trailer */
expecting_trailer = 0;
***************
*** 388,393 ****
--- 423,435 ----
mp->retr_flag = FALSE;
mp->orig_retr_state = FALSE;
mp->uidl_str = "\n";
+ mp->return_path = rpath ? strdup(rpath) : NULL;
+ if (rpath) {
+ int i = strlen(rpath) + 1;
+ mp->length += i;
+ p->drop_size += i;
+ mp->lines++;
+ }
#ifdef DEBUG
if(p->debug)
pop_log(p,POP_DEBUG, "Msg %d being added to list", mp->number);
***************
*** 466,471 ****
--- 508,515 ----
mp->retr_flag = TRUE;
mp->orig_retr_state = TRUE;
}
+ } else if (rpath && (strncasecmp(buffer,"Return-Path:",12) == 0)) {
+ continue;
}
} else {
content_nchar += nchar;
***************
*** 505,510 ****
--- 549,555 ----
int content_length, content_nchar, cont_len;
MD5_CTX mdContext;
unsigned char digest[16];
+ char *rpath = NULL;
FILE *mail_drop; /* Streams for fids */
***************
*** 577,582 ****
--- 622,630 ----
(p->mmdf_separator ? !strcmp(p->mmdf_separator, buffer) :
isfromline(buffer))) {
+ if (!p->mmdf_separator)
+ rpath = return_path(buffer);
+
if (expecting_trailer) {
expecting_trailer = 0;
continue;
***************
*** 622,628 ****
mp->retr_flag = FALSE;
mp->orig_retr_state = FALSE;
mp->uidl_str = "\n";
!
#ifdef DEBUG
if(p->debug)
pop_log(p,POP_DEBUG, "Msg %d being added to list", mp->number);
--- 670,682 ----
mp->retr_flag = FALSE;
mp->orig_retr_state = FALSE;
mp->uidl_str = "\n";
! mp->return_path = rpath ? strdup(rpath) : NULL;
! if (rpath) {
! int i = strlen(rpath) + 1;
! mp->length += i;
! p->drop_size += i;
! mp->lines++;
! }
#ifdef DEBUG
if(p->debug)
pop_log(p,POP_DEBUG, "Msg %d being added to list", mp->number);
***************
*** 705,710 ****
--- 759,766 ----
mp->retr_flag = TRUE;
mp->orig_retr_state = TRUE;
}
+ } else if (rpath && (strncasecmp(buffer,"Return-Path:",12) == 0)) {
+ continue;
}
} else {
content_nchar += nchar;
--- popper.h Mon Feb 17 13:15:44 1997
+++ popper.h Mon Feb 17 13:35:48 1997
@@ -260,6 +263,8 @@
Used for RSET cmd. */
char *uidl_str; /* Cache of the UIDL str for
faster access */
+ char *return_path; /* Cache of the rpath str for
+ faster access */
} MsgInfoList;
typedef struct { /* POP parameter block */
*** pop_send.c.old Thu Nov 20 00:20:38 1997
--- pop_send.c Tue Jun 30 10:06:23 1998
***************
*** 38,43 ****
--- 38,44 ----
register int msg_num;
register int msg_lines;
register int uidl_sent = 0;
+ register int rpath_sent = 0;
char buffer[MAXMSGLINELEN];
/* Convert the first parameter into an integer */
***************
*** 86,91 ****
--- 87,93 ----
/* Send the header of the message followed by a blank line */
while (fgets(buffer, MAXMSGLINELEN, p->drop)) {
if (!strncasecmp(buffer, "Content-Length:", 15) ||
+ (mp->return_path && !strncasecmp(buffer,"Return-Path:",12)) ||
!strncasecmp(buffer, "X-UIDL:", 7)) { /* Skip UIDLs */
continue; /* Content-Length is MTA dependent, don't send to MUA */
}
***************
*** 96,101 ****
--- 98,109 ----
sprintf(uidl_buf, "%s %s", "X-UIDL:", mp->uidl_str);
pop_sendline(p, uidl_buf);
uidl_sent++;
+ }
+ if (mp->return_path && !rpath_sent && (*buffer=='\n' ||
+ !strncasecmp(buffer,"Status:",7) ||
+ !strncasecmp(buffer,"Received:",9))) {
+ pop_sendline(p, mp->return_path);
+ rpath_sent++;
}
pop_sendline(p, buffer);