Lines 21-26
Link Here
|
21 |
#include <arpa/inet.h> |
21 |
#include <arpa/inet.h> |
22 |
#include "libspamc.h" |
22 |
#include "libspamc.h" |
23 |
|
23 |
|
|
|
24 |
static void send_user_prefs_file (); |
25 |
|
24 |
/* RedHat 5.2 doesn't define Shutdown 2nd Parameter Constants */ |
26 |
/* RedHat 5.2 doesn't define Shutdown 2nd Parameter Constants */ |
25 |
/* KAM 12-4-01 */ |
27 |
/* KAM 12-4-01 */ |
26 |
#ifndef SHUT_RD |
28 |
#ifndef SHUT_RD |
Lines 85-90
Link Here
|
85 |
char *msg_buf; |
87 |
char *msg_buf; |
86 |
/* Keep track of how much is stored in this buffer in case of failure later */ |
88 |
/* Keep track of how much is stored in this buffer in case of failure later */ |
87 |
int amount_read; |
89 |
int amount_read; |
|
|
90 |
FILE *user_prefs_file; |
88 |
}; |
91 |
}; |
89 |
|
92 |
|
90 |
/* Dec 13 2001 jm: added safe full-read and full-write functions. These |
93 |
/* Dec 13 2001 jm: added safe full-read and full-write functions. These |
Lines 182-188
Link Here
|
182 |
{ |
185 |
{ |
183 |
if(NULL != username) |
186 |
if(NULL != username) |
184 |
{ |
187 |
{ |
185 |
bytes2 = snprintf(header_buf,1024,"PROCESS %s\r\nUser: %s\r\nContent-length: %d\r\n\r\n",PROTOCOL_VERSION,username,bytes); |
188 |
bytes2 = snprintf(header_buf,1024,"PROCESS %s\r\nUser: %s\r\nContent-length: %d\r\n",PROTOCOL_VERSION,username,bytes); |
186 |
} |
189 |
} |
187 |
else |
190 |
else |
188 |
{ |
191 |
{ |
Lines 191-196
Link Here
|
191 |
} |
194 |
} |
192 |
|
195 |
|
193 |
full_write (out,header_buf,bytes2); |
196 |
full_write (out,header_buf,bytes2); |
|
|
197 |
if (ctx->user_prefs_file != NULL) |
198 |
send_user_prefs_file(out,username,ctx->user_prefs_file); |
199 |
full_write (out,"\r\n",2); |
194 |
full_write (out,ctx->msg_buf,bytes); |
200 |
full_write (out,ctx->msg_buf,bytes); |
195 |
} |
201 |
} |
196 |
|
202 |
|
Lines 201-206
Link Here
|
201 |
return ret; |
207 |
return ret; |
202 |
} |
208 |
} |
203 |
|
209 |
|
|
|
210 |
static void send_user_prefs_file(int fd,char *username,FILE *up) |
211 |
{ |
212 |
char *home,linebuf[4096]; |
213 |
int c,state=0,len=0; |
214 |
|
215 |
while((c=fgetc(up)) >= 0) { |
216 |
if((len+20) > 4095) { |
217 |
full_write(fd,linebuf,len); |
218 |
len=0; |
219 |
} |
220 |
/* Remove comments and unnecessary white space when sending prefs */ |
221 |
switch (state) { |
222 |
case 0: |
223 |
/* In whitespace after newline (or start of file) */ |
224 |
if (c=='#') { |
225 |
/* start of comment */ |
226 |
state=2; |
227 |
} else if (c > ' ') { |
228 |
/* start of configuration directive */ |
229 |
len+=sprintf(linebuf+len,"User-pref: %c",(char)c); |
230 |
state=1; |
231 |
} |
232 |
break; |
233 |
case 1: |
234 |
/* In configuration directive */ |
235 |
if (c=='#') { |
236 |
/* comment at end of line */ |
237 |
linebuf[len++] = '\r'; |
238 |
linebuf[len++] = '\n'; |
239 |
state=2; |
240 |
} else if (c=='\n') { |
241 |
/* End of line */ |
242 |
linebuf[len++] = '\r'; |
243 |
linebuf[len++] = '\n'; |
244 |
state=0; |
245 |
} else { |
246 |
linebuf[len++] = (char)c; |
247 |
} |
248 |
break; |
249 |
case 2: |
250 |
/* In comment */ |
251 |
if (c=='\n') |
252 |
state=0; |
253 |
break; |
254 |
} |
255 |
} |
256 |
fclose(up); |
257 |
full_write(fd,linebuf,len); |
258 |
} |
259 |
|
204 |
static int read_message(int in, int out, int max_size, struct spamc_context *ctx) |
260 |
static int read_message(int in, int out, int max_size, struct spamc_context *ctx) |
205 |
{ |
261 |
{ |
206 |
size_t bytes; |
262 |
size_t bytes; |
Lines 426-432
Link Here
|
426 |
} |
482 |
} |
427 |
|
483 |
|
428 |
int process_message(const char *hostname, int port, char *username, int max_size, |
484 |
int process_message(const char *hostname, int port, char *username, int max_size, |
429 |
int in_fd, int out_fd, const int my_check_only, const int my_safe_fallback) |
485 |
int in_fd, int out_fd, const int my_check_only, const int my_safe_fallback, FILE *user_prefs_file) |
430 |
{ |
486 |
{ |
431 |
int exstatus; |
487 |
int exstatus; |
432 |
int mysock; |
488 |
int mysock; |
Lines 443-448
Link Here
|
443 |
ctx.amount_read = 0; |
499 |
ctx.amount_read = 0; |
444 |
ctx.check_only = my_check_only; |
500 |
ctx.check_only = my_check_only; |
445 |
ctx.safe_fallback = my_safe_fallback; |
501 |
ctx.safe_fallback = my_safe_fallback; |
|
|
502 |
ctx.user_prefs_file = user_prefs_file; |
446 |
|
503 |
|
447 |
/* first, try to mangle it directly into an addr. This will work |
504 |
/* first, try to mangle it directly into an addr. This will work |
448 |
* for numeric IP addresses, but not for hostnames... |
505 |
* for numeric IP addresses, but not for hostnames... |