1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#include "fmt.h"
#include "qmail.h"
#include "now.h"
#include "datetime.h"
#include "date822fmt.h"
#include "received.h"
static int issafe(ch) char ch;
{
if (ch == '.') return 1;
if (ch == '@') return 1;
if (ch == '%') return 1;
if (ch == '+') return 1;
if (ch == '/') return 1;
if (ch == '=') return 1;
if (ch == ':') return 1;
if (ch == '-') return 1;
if ((ch >= 'a') && (ch <= 'z')) return 1;
if ((ch >= 'A') && (ch <= 'Z')) return 1;
if ((ch >= '0') && (ch <= '9')) return 1;
return 0;
}
void safeput(qqt,s)
struct qmail *qqt;
char *s;
{
char ch;
while (ch = *s++) {
if (!issafe(ch)) ch = '?';
qmail_put(qqt,&ch,1);
}
}
static char buf[DATE822FMT];
/* "Received: from relay1.uu.net (HELO uunet.uu.net) (7@192.48.96.5)\n" */
/* " by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n" */
/* "X-UD-Smtp-Session: sessionid */
void received(const struct qmail *qqt,
const char *protocol, const char *local,
const char *remoteip, const char *remotehost, const char *remoteinfo,
const char *remotesession, const char *helo)
{
struct datetime dt;
qmail_puts(qqt,"Received: from ");
safeput(qqt,remotehost);
if (helo) {
qmail_puts(qqt," (HELO ");
safeput(qqt,helo);
qmail_puts(qqt,")");
}
qmail_puts(qqt," (");
if (remoteinfo) {
safeput(qqt,remoteinfo);
qmail_puts(qqt,"@");
}
safeput(qqt,remoteip);
qmail_puts(qqt,")\n by ");
safeput(qqt,local);
qmail_puts(qqt," with ");
qmail_puts(qqt,protocol);
qmail_puts(qqt,"; ");
datetime_tai(&dt,now());
qmail_put(qqt,buf,date822fmt(buf,&dt));
if (remotesession) {
qmail_puts(qqt,"X-UD-Smtp-Session: ");
qmail_puts(qqt,remotesession);
qmail_put(qqt,"\n",1);
}
}
/* "Received: by silverton.berkeley.edu with SMTP; 26 Sep 1995 04:46:54 -0000\n"
* "X-UD-Smtp-Session: user@sessionid */
void received_authed(const struct qmail *qqt, const char *protocol,
const char *local, const char *remoteinfo, const char *remotesession)
{
struct datetime dt;
qmail_puts(qqt,"Received: by ");
safeput(qqt,local);
qmail_puts(qqt," with ");
qmail_puts(qqt,protocol);
qmail_puts(qqt,"; ");
datetime_tai(&dt,now());
qmail_put(qqt,buf,date822fmt(buf,&dt));
if (remoteinfo || remotesession) {
qmail_puts(qqt,"X-UD-Smtp-Session: ");
if (remoteinfo) {
safeput(qqt,remoteinfo);
qmail_puts(qqt,"@");
}
if (remotesession)
qmail_puts(qqt,remotesession);
qmail_put(qqt,"\n",1);
}
}
|