added the webui to the tarball

This commit is contained in:
SJ
2012-02-08 23:14:28 +01:00
parent 79cdeed1b6
commit 1211e9a39c
272 changed files with 26456 additions and 11 deletions

View File

@ -38,6 +38,7 @@
#define MSG_CONTENT_TRANSFER_ENCODING 7
#define MSG_CONTENT_DISPOSITION 8
#define MSG_MESSAGE_ID 9
#define MSG_REFERENCES 10
#define MAXHASH 8171
@ -144,6 +145,8 @@ struct _state {
int n_attachments;
struct attachment attachments[MAX_ATTACHMENTS];
char reference[SMALLBUFSIZE];
char b_from[SMALLBUFSIZE], b_from_domain[SMALLBUFSIZE], b_to[MAXBUFSIZE], b_to_domain[SMALLBUFSIZE], b_subject[MAXBUFSIZE], b_body[BIGBUFSIZE];
};

View File

@ -252,10 +252,6 @@ int store_recipients(struct session_data *sdata, char *to, uint64 id, struct __c
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_execute error: *%s*", sdata->ttmpfile, SQL_RECIPIENT_TABLE, mysql_error(&(sdata->mysql)));
ret = ERR;
}
} else {
syslog(LOG_PRIORITY, "%s: invalid email address: %s", sdata->ttmpfile, puf);
continue;
}
} while(p);
@ -273,8 +269,8 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c
char *subj, *p, s[MAXBUFSIZE], s2[SMALLBUFSIZE], vcode[2*DIGEST_LENGTH+1];
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
unsigned long len[4];
MYSQL_BIND bind[5];
unsigned long len[5];
my_ulonglong id=0;
@ -286,7 +282,7 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c
digest_string(s, &vcode[0]);
snprintf(s, MAXBUFSIZE-1, "INSERT INTO %s (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,%d,%ld,%ld,%d,%d,%d,%d,'%s',?,'%s','%s','%s')", SQL_METADATA_TABLE, sdata->spam_message, sdata->now, sdata->sent, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, sdata->digest, sdata->bodydigest, vcode);
snprintf(s, MAXBUFSIZE-1, "INSERT INTO %s (`from`,`fromdomain`,`subject`,`spam`,`arrived`,`sent`,`size`,`hlen`,`direction`,`attachments`,`piler_id`,`message_id`,`reference`,`digest`,`bodydigest`,`vcode`) VALUES(?,?,?,%d,%ld,%ld,%d,%d,%d,%d,'%s',?,?,'%s','%s','%s')", SQL_METADATA_TABLE, sdata->spam_message, sdata->now, sdata->sent, sdata->tot_len, sdata->hdr_len, sdata->direction, state->n_attachments, sdata->ttmpfile, sdata->digest, sdata->bodydigest, vcode);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: meta sql: *%s*", sdata->ttmpfile, s);
@ -335,6 +331,11 @@ int store_meta_data(struct session_data *sdata, struct _state *state, struct __c
bind[3].is_null = 0;
len[3] = strlen(state->message_id); bind[3].length = &len[3];
bind[4].buffer_type = MYSQL_TYPE_STRING;
bind[4].buffer = state->reference;
bind[4].is_null = 0;
len[4] = strlen(state->reference); bind[4].length = &len[4];
if(mysql_stmt_bind_param(stmt, bind)){
syslog(LOG_PRIORITY, "%s: %s.mysql_stmt_bind_param() error: %s", sdata->ttmpfile, SQL_METADATA_TABLE, mysql_stmt_error(stmt));
goto CLOSE;

View File

@ -90,7 +90,7 @@ void post_parse(struct session_data *sdata, struct _state *state, struct __confi
len = strlen(state->b_to);
if(state->b_to[len-1] == ' ') state->b_to[len-1] = '\0';
syslog(LOG_PRIORITY, "%s: from=%s, to=%s, subj=%s, message-id=%s", sdata->ttmpfile, state->b_from, state->b_to, state->b_subject, state->message_id);
syslog(LOG_PRIORITY, "%s: from=%s, to=%s, subj=%s, message-id=%s, reference=%s", sdata->ttmpfile, state->b_from, state->b_to, state->b_subject, state->message_id, state->reference);
}
@ -210,6 +210,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, stru
else if(strncasecmp(buf, "To:", 3) == 0) state->message_state = MSG_TO;
else if(strncasecmp(buf, "Cc:", 3) == 0) state->message_state = MSG_CC;
else if(strncasecmp(buf, "Message-Id:", 11) == 0) state->message_state = MSG_MESSAGE_ID;
else if(strncasecmp(buf, "References:", 11) == 0) state->message_state = MSG_REFERENCES;
else if(strncasecmp(buf, "Subject:", strlen("Subject:")) == 0) state->message_state = MSG_SUBJECT;
else if(strncasecmp(buf, "Date:", strlen("Date:")) == 0 && sdata->sent == 0) sdata->sent = parse_date_header(buf);
@ -231,6 +232,12 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, stru
}
if(state->is_1st_header == 1 && state->message_state == MSG_REFERENCES){
if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11);
else parse_reference(state, buf);
}
if(state->is_1st_header == 1 && state->message_state == MSG_SUBJECT && strlen(state->b_subject) + strlen(buf) < MAXBUFSIZE-1){
if(state->b_subject[0] == '\0'){

View File

@ -31,5 +31,6 @@ void degenerateToken(unsigned char *p);
void fixURL(char *url);
int extractNameFromHeaderLine(char *s, char *name, char *resultbuf);
char *determine_attachment_type(char *filename, char *type);
void parse_reference(struct _state *state, char *s);
#endif /* _PARSER_H */

View File

@ -74,6 +74,8 @@ void init_state(struct _state *state){
memset(state->attachments[i].digest, 0, 2*DIGEST_LENGTH+1);
}
memset(state->reference, 0, SMALLBUFSIZE);
memset(state->b_from, 0, SMALLBUFSIZE);
memset(state->b_from_domain, 0, SMALLBUFSIZE);
memset(state->b_to, 0, MAXBUFSIZE);
@ -679,3 +681,22 @@ char *determine_attachment_type(char *filename, char *type){
return "other,";
}
void parse_reference(struct _state *state, char *s){
int len;
char puf[SMALLBUFSIZE];
if(strlen(state->reference) > 10) return;
do {
s = split_str(s, " ", puf, sizeof(puf)-1);
len = strlen(puf);
if(len > 10 && len < SMALLBUFSIZE-1){
memcpy(&(state->reference[strlen(state->reference)]), puf, len);
return;
}
} while(s);
}

View File

@ -72,6 +72,7 @@ int main(int argc, char **argv){
printf("message-id: %s\n", state.message_id);
printf("from: *%s (%s)*\n", state.b_from, state.b_from_domain);
printf("to: *%s (%s)*\n", state.b_to, state.b_to_domain);
printf("reference: *%s*\n", state.reference);
printf("subject: *%s*\n", state.b_subject);
//printf("body: *%s*\n", state.b_body);