int list_aggregate_preference_attributes(const char *username) { agent_pref_t PTX = NULL; agent_pref_t STX = NULL; agent_pref_t UTX = NULL; agent_attrib_t pref; int i; STX = _ds_pref_load(agent_config, NULL, _ds_read_attribute(agent_config, "Home"), NULL); if (STX == NULL || STX[0] == 0) { if (STX) { _ds_pref_free(STX); } LOGDEBUG("default preferences empty. reverting to dspam.conf preferences."); STX = pref_config(); } else { LOGDEBUG("loaded default preferences externally"); } if (username[0] == 0 || !strncmp(username, "default", strlen(username))) UTX = _ds_pref_load(agent_config, NULL, _ds_read_attribute(agent_config, "Home"), NULL); else { UTX = _ds_pref_load(agent_config, username, _ds_read_attribute(agent_config, "Home"), NULL); } PTX = _ds_pref_aggregate(STX, UTX); _ds_pref_free(STX); free(STX); if (UTX != NULL) { _ds_pref_free(UTX); free(UTX); } for(i=0;PTX[i];i++) { pref = PTX[i]; printf("%s=%s\n", pref->attribute, pref->value); } _ds_pref_free(PTX); free(PTX); return 0; }
int list_preference_attributes(const char *username) { agent_pref_t PTX; agent_attrib_t pref; int i; if (username[0] == 0 || !strncmp(username, "default", strlen(username))) PTX = _ds_pref_load(agent_config, NULL, _ds_read_attribute(agent_config, "Home"), NULL); else PTX = _ds_pref_load(agent_config, username, _ds_read_attribute(agent_config, "Home"), NULL); if (PTX == NULL) return 0; for(i=0;PTX[i];i++) { pref = PTX[i]; printf("%s=%s\n", pref->attribute, pref->value); } _ds_pref_free(PTX); free(PTX); return 0; }
int process_unused (DSPAM_CTX *CTX, int any, int quota, int nospam, int onehit) { struct _ds_storage_record *sr; ds_diction_t del; time_t t = time(NULL); int delta, toe = 0, tum = 0; agent_pref_t PTX; #ifdef DEBUG printf("Processing unused; any: %d quota: %d nospam: %d onehit: %d\n", any, quota, nospam, onehit); #endif PTX = _ds_pref_load(agent_config, CTX->username, _ds_read_attribute(agent_config, "Home"), NULL); if (PTX == NULL || PTX[0] == 0) { if (PTX) _ds_pref_free(PTX); PTX = pref_config(); } if (!strcasecmp(_ds_pref_val(PTX, "trainingMode"), "toe")) { #ifdef DEBUG printf("Limiting unused token purges for user %s - TOE Training Mode Set\n", CTX->username); #endif toe = 1; } if (!strcasecmp(_ds_pref_val(PTX, "trainingMode"), "tum")) { #ifdef DEBUG printf("Limiting unused token purges for user %s - TUM Training Mode Set\n", CTX->username); #endif tum = 1; } if (PTX) _ds_pref_free(PTX); del = ds_diction_create(196613); if (del == NULL) return -1; sr = _ds_get_nexttoken (CTX); while (sr != NULL) { delta = (((t - sr->last_hit) / 60) / 60) / 24; if (!toe && (any == 0 || delta > any)) { if (!tum || sr->innocent_hits + sr->spam_hits < 50) ds_diction_touch(del, sr->token, "", 0); } else if ((sr->innocent_hits*2) + sr->spam_hits < 5) { if (quota == 0 || delta > quota) { ds_diction_touch(del, sr->token, "", 0); } else if (sr->innocent_hits == 0 && sr->spam_hits == 1 && (nospam == 0 || delta > nospam)) { ds_diction_touch(del, sr->token, "", 0); } else if (sr->innocent_hits == 1 && sr->spam_hits == 0 && (onehit == 0 || delta > onehit)) { ds_diction_touch(del, sr->token, "", 0); } } free (sr); sr = _ds_get_nexttoken (CTX); } _ds_delall_spamrecords(CTX, del); ds_diction_destroy(del); return 0; }