#include "defs.h"
#include <glib.h>
-
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
-
#include <clamav.h>
#include "common/plugin.h"
static PrefParam param[] = {
{"clamav_enable", "FALSE", &config.clamav_enable, P_BOOL,
NULL, NULL, NULL},
- {"clamav_enable_archive", "FALSE", &config.clamav_archive_enable, P_BOOL,
+ {"clamav_enable_arc", "FALSE", &config.clamav_enable_arc, P_BOOL,
NULL, NULL, NULL},
{"clamav_max_size", "1", &config.clamav_max_size, P_USHORT,
NULL, NULL, NULL},
- {"clamav_receive_infected", "TRUE", &config.clamav_receive_infected, P_BOOL,
+ {"clamav_recv_infected", "TRUE", &config.clamav_recv_infected, P_BOOL,
NULL, NULL, NULL},
{"clamav_save_folder", NULL, &config.clamav_save_folder, P_STRING,
NULL, NULL, NULL},
MimeInfo *child;
gchar *infile;
gchar *outfile;
+ gint scan_archive = 0;
int ret, no;
unsigned long int size;
if (!config.clamav_enable)
return FALSE;
- debug_print("Scanning message %d for viruses\n", msginfo->msgnum);
-
fp = procmsg_open_message(msginfo);
if (fp == NULL) {
debug_print("failed to open message file");
return FALSE;
}
+ debug_print("Scanning message %d for viruses\n", msginfo->msgnum);
+
if (IS_FIRST_PART_TEXT(child))
child = child->next;
cl_buildtrie(root);
limits.maxfiles = 1000; /* max files */
- limits.maxfilesize = config.clamav_max_size * 1048576; /* maximal archived file size == 10 Mb */
- limits.maxreclevel = 8; /* maximal recursion level */
+ limits.maxfilesize = config.clamav_max_size * 1048576; /* maximum archived file size */
+ limits.maxreclevel = 8; /* maximum recursion level */
+
+ if (config.clamav_enable_arc)
+ scan_archive = TRUE;
while (child != NULL) {
if (child->children || child->mime_type == MIME_MULTIPART) {
g_warning("Can't get the part of multipart message.");
else {
debug_print("Scanning %s\n", outfile);
-
- if((ret = cl_scanfile(outfile, &virname, &size, root,
- &limits, CL_ARCHIVE)) == CL_VIRUS) {
+ if ((ret = cl_scanfile(outfile, &virname, &size, root,
+ &limits, scan_archive)) == CL_VIRUS) {
is_infected = TRUE;
debug_print("Detected %s virus.\n", virname);
} else {
debug_print("No virus detected.\n");
- if(ret != CL_CLEAN)
+ if (ret != CL_CLEAN)
debug_print("Error: %s\n", cl_perror(ret));
}
kb = size * (CL_COUNT_PRECISION / 1024);
debug_print("Data scanned: %2.2Lf Kb\n", kb);
- if (is_infected) {
- debug_print("message part(s) infected with %s\n", virname);
- if (config.clamav_receive_infected) {
- FolderItem *clamav_save_folder;
-
- if ((!config.clamav_save_folder) ||
- (config.clamav_save_folder[0] == '\0') ||
- ((clamav_save_folder = folder_find_item_from_identifier(config.clamav_save_folder)) == NULL))
- clamav_save_folder = folder_get_default_trash();
-
- procmsg_msginfo_unset_flags(msginfo, ~0, 0);
- folder_item_move_msg(clamav_save_folder, msginfo);
- } else {
- folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
- }
-
- return TRUE;
- }
- child = child->next;
+ unlink(outfile);
+
+ if (is_infected) break;
+ child = child->next;
}
}
+
+ if (is_infected) {
+ debug_print("message part(s) infected with %s\n", virname);
+ if (config.clamav_recv_infected) {
+ FolderItem *clamav_save_folder;
+
+ if ((!config.clamav_save_folder) ||
+ (config.clamav_save_folder[0] == '\0') ||
+ ((clamav_save_folder = folder_find_item_from_identifier(config.clamav_save_folder)) == NULL))
+ clamav_save_folder = folder_get_default_trash();
+
+ procmsg_msginfo_unset_flags(msginfo, ~0, 0);
+ folder_item_move_msg(clamav_save_folder, msginfo);
+ } else {
+ folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
+ }
+ }
+
cl_freetrie(root);
g_free(infile);
procmime_mimeinfo_free_all(mimeinfo);
-
- return FALSE;
+
+ return is_infected;
}
#undef IS_FIRST_PART_TEXT
const gchar *plugin_desc()
{
- return "This plugin checks all message attachments that are received "
- "from a POP account for viruses using Clam AntiVirus. You will "
- "need to have ClamAv installed.\n"
+ return "This plugin uses Clam AntiVirus to scan all message attachments "
+ "that are received from a POP account.\n"
"\n"
"When a message attachment is found to contain a virus it can be "
- "deleted or saved in a special folder.\n"
+ "deleted or saved in a specially designated folder.\n"
"\n"
- "This plugin only contains the actual function for filtering "
+ "This plugin only contains the actual function for scanning "
"and deleting or moving the message. You probably want to load "
- "a User Interface plugin too, otherwise you will have to "
+ "the Gtk+ User Interface plugin too, otherwise you will have to "
"manually write the plugin configuration.\n";
}