--- dspam-3.8.0.orig/src/tools/dspam_2sql.c 2006-05-13 03:13:01.000000000 +0200 +++ dspam-3.8.0/src/tools/dspam_2sql.c 2009-03-03 18:12:45.000000000 +0100 @@ -25,6 +25,7 @@ #endif #include +#include #include #include #include @@ -43,8 +44,9 @@ #include "language.h" DSPAM_CTX *open_ctx, *open_mtx; +static int32_t glob_uid = 10000; -int dump_user (const char *username); +int dump_user (const char *username, int32_t); int process_all_users (void); void dieout (int signal); @@ -57,15 +59,17 @@ #endif #endif int i, ret; + const char *user = NULL; + int32_t user_uid = -1; /* Read dspam.conf */ - + agent_config = read_config(NULL); if (!agent_config) { LOG(LOG_ERR, ERR_AGENT_READ_CONFIG); exit(EXIT_FAILURE); } - + if (!_ds_read_attribute(agent_config, "Home")) { LOG(LOG_ERR, ERR_AGENT_DSPAM_HOME); _ds_destroy_config(agent_config); @@ -73,7 +77,7 @@ } libdspam_init(_ds_read_attribute(agent_config, "StorageDriver")); - + #ifndef _WIN32 #ifdef TRUSTED_USER_SECURITY if (!_ds_match_attribute(agent_config, "Trust", p->pw_name) && p->pw_uid) { @@ -85,7 +89,6 @@ #endif for(i=0;ipw_uid; + } } CTX = dspam_create (username, NULL, _ds_read_attribute(agent_config, "Home"), DSM_CLASSIFY, 0); @@ -180,7 +204,7 @@ printf ("insert into dspam_stats (uid, spam_learned, innocent_learned, spam_misclassified, innocent_misclassified, spam_corpusfed, innocent_corpusfed, spam_classified, innocent_classified) values(%d, %ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld);\n", - (int) p->pw_uid, CTX->totals.spam_learned, CTX->totals.innocent_learned, + (int) uid, CTX->totals.spam_learned, CTX->totals.innocent_learned, CTX->totals.spam_misclassified, CTX->totals.innocent_misclassified, CTX->totals.spam_corpusfed, CTX->totals.innocent_corpusfed, CTX->totals.spam_classified, CTX->totals.innocent_classified); @@ -189,9 +213,9 @@ while (record != NULL) { printf - ("insert into dspam_token_data (uid, token, spam_hits, innocent_hits, last_hit) values(%d, \"%"LLU_FMT_SPEC"\", %ld, %ld, %ld);\n", - (int) p->pw_uid, record->token, record->spam_hits, - record->innocent_hits, (long) record->last_hit); + ("insert ignore into dspam_token_data (uid, token, spam_hits, innocent_hits, last_hit) values(%d, \"%"LLU_FMT_SPEC"\", %ld, %ld, from_unixtime(%ld));\n", + (int) uid, record->token, record->spam_hits, + record->innocent_hits, (unsigned long) record->last_hit); record = _ds_get_nexttoken (CTX); }