static SpamAssassinConfig config;
static PrefParam param[] = {
+ {"enable", "FALSE", &config.enable, P_BOOL,
+ NULL, NULL, NULL},
{"transport", "0", &config.transport, P_INT,
NULL, NULL, NULL},
{"hostname", "localhost", &config.hostname, P_STRING,
struct message m;
gboolean is_spam = FALSE;
+ if (!config.enable)
+ return FALSE;
+
transport_init(&trans);
switch (config.transport) {
case SPAMASSASSIN_TRANSPORT_LOCALHOST:
int pid = 0;
int status;
- if (config.transport == SPAMASSASSIN_DISABLED) {
+ /* SPAMASSASSIN_DISABLED : keep test for compatibility purpose */
+ if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
log_error("Spamassassin plugin is disabled by its preferences.\n");
return FALSE;
}
{
gchar *cmd = NULL;
gchar *file = NULL;
- gboolean async = FALSE;
const gchar *shell = g_getenv("SHELL");
gchar *spamc_wrapper = NULL;
tmpcmd = g_strconcat(shell?shell:"sh", " ", spamc_wrapper, " ",
tmpfile, NULL);
debug_print("%s\n", tmpcmd);
- execute_command_line(tmpcmd, TRUE);
+ execute_command_line(tmpcmd, FALSE);
g_free(tmpcmd);
}
if (tmpfile != NULL) {
g_free(tmpfile);
}
}
- async = TRUE;
}
}
if (cmd == NULL) {
return -1;
}
debug_print("%s\n", cmd);
- /* only run async if we have a list, or we could end up
- * forking lots of perl processes and bury the machine */
-
- execute_command_line(cmd, async);
+ /* only run sync calls to sa-learn/spamc to prevent system lockdown */
+ execute_command_line(cmd, FALSE);
g_free(cmd);
if (spamc_wrapper != NULL) {
g_free(spamc_wrapper);
spamassassin_register_hook();
}
- if (config.transport == SPAMASSASSIN_DISABLED) {
+ if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
log_error("Spamassassin plugin is loaded but disabled by its preferences.\n");
}
-
- if (config.transport != SPAMASSASSIN_DISABLED) {
+ else {
if (config.transport == SPAMASSASSIN_TRANSPORT_TCP)
debug_print("Enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
procmsg_register_spam_learner(spamassassin_learn);