Lines 1-8
Link Here
|
1 |
Add SpamAssassin support. |
1 |
--- vdelivermail.c.orig 2007-11-18 06:15:19.000000000 +0100 |
2 |
Drop the unneeded MAX_ENV_BUFF definition. |
2 |
+++ vdelivermail.c 2009-10-25 10:44:40.000000000 +0100 |
3 |
|
|
|
4 |
--- a/vdelivermail.c |
5 |
+++ b/vdelivermail.c |
6 |
@@ -74,6 +74,7 @@ |
3 |
@@ -74,6 +74,7 @@ |
7 |
int is_spam(); |
4 |
int is_spam(); |
8 |
#endif |
5 |
#endif |
Lines 70-77
Link Here
|
70 |
return 0; |
67 |
return 0; |
71 |
} |
68 |
} |
72 |
|
69 |
|
73 |
@@ -495,6 +513,11 @@ |
70 |
@@ -481,8 +499,8 @@ |
|
|
71 |
int deliver_to_maildir ( |
72 |
const char *maildir, |
73 |
const char *extra_headers, |
74 |
- int read_fd, |
75 |
- ssize_t msgsize) |
76 |
+ int read_fd |
77 |
+ ) |
78 |
{ |
79 |
#ifdef HOST_NAME_MAX |
80 |
char hostname[HOST_NAME_MAX]; |
81 |
@@ -493,21 +511,25 @@ |
82 |
char local_file_tmp[FILE_SIZE]; |
83 |
char local_file_new[FILE_SIZE]; |
74 |
size_t headerlen; |
84 |
size_t headerlen; |
|
|
85 |
+ struct stat sb; |
86 |
+ size_t msgsize; |
75 |
int write_fd; |
87 |
int write_fd; |
76 |
char quota[80]; |
88 |
char quota[80]; |
77 |
+#ifdef SPAM_JUNKFOLDER |
89 |
+#ifdef SPAM_JUNKFOLDER |
Lines 81-90
Link Here
|
81 |
+#endif |
93 |
+#endif |
82 |
|
94 |
|
83 |
headerlen = strlen (extra_headers); |
95 |
headerlen = strlen (extra_headers); |
84 |
msgsize += headerlen; |
96 |
- msgsize += headerlen; |
85 |
@@ -557,6 +580,24 @@ |
97 |
|
|
|
98 |
/* Format the email file name */ |
99 |
/* we get the whole hostname, even though we only use 32 chars of it */ |
100 |
gethostname(hostname, sizeof(hostname)); |
101 |
pid = (long unsigned) getpid(); |
102 |
tm = (long unsigned) time((time_t *) NULL); |
103 |
- snprintf(local_file_tmp, sizeof(local_file_tmp), "%stmp/%lu.%lu.%.32s,S=%lu", |
104 |
- maildir, tm, pid, hostname, (long unsigned) msgsize); |
105 |
- snprintf(local_file_new, sizeof(local_file_new), "%snew/%lu.%lu.%.32s,S=%lu", |
106 |
- maildir, tm, pid, hostname, (long unsigned) msgsize); |
107 |
+ snprintf(local_file_tmp, sizeof(local_file_tmp), "%stmp/%lu.%lu.%.32s", |
108 |
+ maildir, tm, pid, hostname); |
109 |
|
110 |
read_quota_from_maildir (maildir, quota, sizeof(quota)); |
111 |
|
112 |
@@ -548,6 +570,9 @@ |
113 |
#endif |
114 |
close (write_fd) == 0 ) { |
115 |
|
116 |
+ if (stat(local_file_tmp, &sb) == -1) |
117 |
+ DeleteMail = 1; |
118 |
+ |
119 |
if(DeleteMail == 1) { |
120 |
if (unlink(local_file_tmp) != 0) { |
121 |
printf("unlink failed %s errno = %d\n", local_file_tmp, errno); |
122 |
@@ -556,7 +581,29 @@ |
123 |
return(0); |
86 |
} |
124 |
} |
87 |
|
125 |
|
|
|
126 |
+ msgsize = sb.st_size; |
127 |
+ snprintf(local_file_new, sizeof(local_file_new), "%snew/%lu.%lu.%.32s,S=%lu", |
128 |
+ maildir, tm, pid, hostname, (long unsigned) msgsize); |
129 |
+ |
88 |
/* if this succeeds link the file to the new directory */ |
130 |
/* if this succeeds link the file to the new directory */ |
89 |
+#ifdef SPAM_JUNKFOLDER |
131 |
+#ifdef SPAM_JUNKFOLDER |
90 |
+ if (MoveMail == 1) { |
132 |
+ if (MoveMail == 1) { |
Lines 107-113
Link Here
|
107 |
if ( link( local_file_tmp, local_file_new ) == 0 ) { |
149 |
if ( link( local_file_tmp, local_file_new ) == 0 ) { |
108 |
/* file was successfully delivered, remove temp file */ |
150 |
/* file was successfully delivered, remove temp file */ |
109 |
if ( unlink(local_file_tmp) != 0 ) { |
151 |
if ( unlink(local_file_tmp) != 0 ) { |
110 |
@@ -616,6 +657,9 @@ |
152 |
@@ -616,6 +663,9 @@ |
111 |
/* rewind the message */ |
153 |
/* rewind the message */ |
112 |
lseek(0,0L,SEEK_SET); |
154 |
lseek(0,0L,SEEK_SET); |
113 |
|
155 |
|
Lines 117-123
Link Here
|
117 |
/* This is an command */ |
159 |
/* This is an command */ |
118 |
if ( *address == '|' ) { |
160 |
if ( *address == '|' ) { |
119 |
|
161 |
|
120 |
@@ -895,9 +939,6 @@ |
162 |
@@ -723,7 +773,7 @@ |
|
|
163 |
email); |
164 |
} |
165 |
|
166 |
- switch (deliver_to_maildir (address, DeliveredTo, 0, message_size)) { |
167 |
+ switch (deliver_to_maildir (address, DeliveredTo, 0)) { |
168 |
case -1: |
169 |
vexiterr (EXIT_OVERQUOTA, "user is over quota"); |
170 |
break; |
171 |
@@ -895,9 +945,6 @@ |
121 |
*/ |
172 |
*/ |
122 |
void run_command(char *prog) |
173 |
void run_command(char *prog) |
123 |
{ |
174 |
{ |
Lines 127-133
Link Here
|
127 |
int child; |
178 |
int child; |
128 |
char *(args[4]); |
179 |
char *(args[4]); |
129 |
int wstat; |
180 |
int wstat; |
130 |
@@ -1211,19 +1252,22 @@ |
181 |
@@ -1183,7 +1230,7 @@ |
|
|
182 |
maildir_to_email(newdir), date_header()); |
183 |
} |
184 |
|
185 |
- err = deliver_to_maildir (dir, DeliveredTo, read_fd, sb.st_size); |
186 |
+ err = deliver_to_maildir (dir, DeliveredTo, read_fd); |
187 |
|
188 |
close (read_fd); |
189 |
|
190 |
@@ -1211,19 +1258,22 @@ |
131 |
* * in the email headers for X-Spam-Level: which |
191 |
* * in the email headers for X-Spam-Level: which |
132 |
* * we put in each spam email |
192 |
* * we put in each spam email |
133 |
* * |
193 |
* * |
Lines 154-160
Link Here
|
154 |
|
214 |
|
155 |
/* check for blank line, end of headers */ |
215 |
/* check for blank line, end of headers */ |
156 |
for(k=j,found=0;k<i;++k) { |
216 |
for(k=j,found=0;k<i;++k) { |
157 |
@@ -1246,13 +1290,19 @@ |
217 |
@@ -1246,13 +1296,19 @@ |
158 |
} |
218 |
} |
159 |
if ( found == 0 ) { |
219 |
if ( found == 0 ) { |
160 |
InHeaders=0; |
220 |
InHeaders=0; |