mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:31:58 +01:00
introduced helper_timeout parameter
This commit is contained in:
parent
7d1a8628ea
commit
6fed43bddd
34
configure
vendored
34
configure
vendored
@ -701,7 +701,6 @@ enable_starttls
|
||||
enable_tcpwrappers
|
||||
enable_tweak_sent_time
|
||||
with_database
|
||||
with_plugin_timeout
|
||||
with_piler_user
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
@ -1331,7 +1330,6 @@ Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--with-database[=mysql] select the used database, currently mysql only (default: none)
|
||||
--with-plugin-timeout=N use the timeout binary to kill a hanging extractor plugin program after N seconds
|
||||
--with-piler-user=username what user the piler daemon shall be run as
|
||||
|
||||
Some influential environment variables:
|
||||
@ -4504,26 +4502,18 @@ fi
|
||||
|
||||
|
||||
|
||||
if test z`which timeout 2>/dev/null` != "z"; then
|
||||
timeout_binary=`which timeout`
|
||||
|
||||
# Check whether --with-plugin-timeout was given.
|
||||
if test "${with_plugin_timeout+set}" = set; then :
|
||||
withval=$with_plugin_timeout;
|
||||
|
||||
if test z`which timeout 2>/dev/null` != "z"; then
|
||||
timeout_binary=`which timeout`" $withval "
|
||||
fi
|
||||
|
||||
if test "$withval" = "yes" || test "$withval" = ""; then
|
||||
echo "please specify the value for plugin-timeout, eg. --with-plugin-timeout=15";
|
||||
exit;
|
||||
fi
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define TIMEOUT_BINARY "$timeout_binary"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Check whether --with-piler-user was given.
|
||||
if test "${with_piler_user+set}" = set; then :
|
||||
withval=$with_piler_user; RUNNING_USER=$withval
|
||||
@ -4757,7 +4747,7 @@ if test z`which pdftotext 2>/dev/null` != "z"; then
|
||||
pdftotext=`which pdftotext`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_PDFTOTEXT "$timeout_binary$pdftotext"
|
||||
#define HAVE_PDFTOTEXT "$pdftotext"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4766,7 +4756,7 @@ if test z`which catdoc 2>/dev/null` != "z"; then
|
||||
catdoc=`which catdoc`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_CATDOC "$timeout_binary$catdoc"
|
||||
#define HAVE_CATDOC "$catdoc"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4776,7 +4766,7 @@ if test z`which catppt 2>/dev/null` != "z"; then
|
||||
catppt=`which catppt`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_CATPPT "$timeout_binary$catppt"
|
||||
#define HAVE_CATPPT "$catppt"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4786,7 +4776,7 @@ if test z`which ppthtml 2>/dev/null` != "z"; then
|
||||
ppthtml=`which ppthtml`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_PPTHTML "$timeout_binary$ppthtml"
|
||||
#define HAVE_PPTHTML "$ppthtml"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4796,7 +4786,7 @@ if test z`which xls2csv 2>/dev/null` != "z"; then
|
||||
xls2csv=`which xls2csv`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_XLS2CSV "$timeout_binary$xls2csv"
|
||||
#define HAVE_XLS2CSV "$xls2csv"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4806,7 +4796,7 @@ if test z`which unrtf 2>/dev/null` != "z"; then
|
||||
unrtf=`which unrtf`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_UNRTF "$timeout_binary$unrtf"
|
||||
#define HAVE_UNRTF "$unrtf"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
@ -4816,7 +4806,7 @@ if test z`which tnef 2>/dev/null` != "z"; then
|
||||
tnef=`which tnef`
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_TNEF "$timeout_binary$tnef"
|
||||
#define HAVE_TNEF "$tnef"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
31
configure.in
31
configure.in
@ -253,19 +253,12 @@ AC_ARG_WITH(database,
|
||||
])
|
||||
|
||||
|
||||
dnl timeout binary
|
||||
|
||||
AC_ARG_WITH(plugin-timeout,
|
||||
[ --with-plugin-timeout=N use the timeout binary to kill a hanging extractor plugin program after N seconds],[
|
||||
|
||||
if test z`which timeout 2>/dev/null` != "z"; then
|
||||
timeout_binary=`which timeout`" $withval "
|
||||
fi
|
||||
|
||||
if test "$withval" = "yes" || test "$withval" = ""; then
|
||||
echo "please specify the value for plugin-timeout, eg. --with-plugin-timeout=15";
|
||||
exit;
|
||||
fi
|
||||
])
|
||||
if test z`which timeout 2>/dev/null` != "z"; then
|
||||
timeout_binary=`which timeout`
|
||||
AC_DEFINE_UNQUOTED(TIMEOUT_BINARY, "$timeout_binary", [timeout binary])
|
||||
fi
|
||||
|
||||
|
||||
dnl user running piler
|
||||
@ -465,42 +458,42 @@ fi
|
||||
|
||||
if test z`which pdftotext 2>/dev/null` != "z"; then
|
||||
pdftotext=`which pdftotext`
|
||||
AC_DEFINE_UNQUOTED(HAVE_PDFTOTEXT, "$timeout_binary$pdftotext", [path to pdftotext])
|
||||
AC_DEFINE_UNQUOTED(HAVE_PDFTOTEXT, "$pdftotext", [path to pdftotext])
|
||||
fi
|
||||
|
||||
if test z`which catdoc 2>/dev/null` != "z"; then
|
||||
catdoc=`which catdoc`
|
||||
AC_DEFINE_UNQUOTED(HAVE_CATDOC, "$timeout_binary$catdoc", [path to catdoc])
|
||||
AC_DEFINE_UNQUOTED(HAVE_CATDOC, "$catdoc", [path to catdoc])
|
||||
fi
|
||||
|
||||
|
||||
if test z`which catppt 2>/dev/null` != "z"; then
|
||||
catppt=`which catppt`
|
||||
AC_DEFINE_UNQUOTED(HAVE_CATPPT, "$timeout_binary$catppt", [path to catppt])
|
||||
AC_DEFINE_UNQUOTED(HAVE_CATPPT, "$catppt", [path to catppt])
|
||||
fi
|
||||
|
||||
|
||||
if test z`which ppthtml 2>/dev/null` != "z"; then
|
||||
ppthtml=`which ppthtml`
|
||||
AC_DEFINE_UNQUOTED(HAVE_PPTHTML, "$timeout_binary$ppthtml", [path to ppthtml])
|
||||
AC_DEFINE_UNQUOTED(HAVE_PPTHTML, "$ppthtml", [path to ppthtml])
|
||||
fi
|
||||
|
||||
|
||||
if test z`which xls2csv 2>/dev/null` != "z"; then
|
||||
xls2csv=`which xls2csv`
|
||||
AC_DEFINE_UNQUOTED(HAVE_XLS2CSV, "$timeout_binary$xls2csv", [path to xls2csv])
|
||||
AC_DEFINE_UNQUOTED(HAVE_XLS2CSV, "$xls2csv", [path to xls2csv])
|
||||
fi
|
||||
|
||||
|
||||
if test z`which unrtf 2>/dev/null` != "z"; then
|
||||
unrtf=`which unrtf`
|
||||
AC_DEFINE_UNQUOTED(HAVE_UNRTF, "$timeout_binary$unrtf", [path to unrtf])
|
||||
AC_DEFINE_UNQUOTED(HAVE_UNRTF, "$unrtf", [path to unrtf])
|
||||
fi
|
||||
|
||||
|
||||
if test z`which tnef 2>/dev/null` != "z"; then
|
||||
tnef=`which tnef`
|
||||
AC_DEFINE_UNQUOTED(HAVE_TNEF, "$timeout_binary$tnef", [path to tnef])
|
||||
AC_DEFINE_UNQUOTED(HAVE_TNEF, "$tnef", [path to tnef])
|
||||
fi
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@ listen_port=25
|
||||
clamd_socket=/tmp/clamd
|
||||
|
||||
session_timeout=420
|
||||
helper_timeout=20
|
||||
|
||||
; the 2nd parameter of the listen() system call. Please note that this is set
|
||||
; when piler starts up and you should restart piler if you change this variable.
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#define HAVE_DAEMON 1
|
||||
|
||||
#undef TIMEOUT_BINARY
|
||||
|
||||
#undef HAVE_PDFTOTEXT
|
||||
#undef HAVE_CATDOC
|
||||
#undef HAVE_CATPPT
|
||||
|
@ -71,6 +71,7 @@ struct _parse_rule config_parse_rules[] =
|
||||
{ "enable_cjk", "integer", (void*) int_parser, offsetof(struct __config, enable_cjk), "0", sizeof(int)},
|
||||
{ "encrypt_messages", "integer", (void*) int_parser, offsetof(struct __config, encrypt_messages), "1", sizeof(int)},
|
||||
{ "extra_to_field", "string", (void*) string_parser, offsetof(struct __config, extra_to_field), "", MAXVAL-1},
|
||||
{ "helper_timeout", "integer", (void*) int_parser, offsetof(struct __config, helper_timeout), "20", sizeof(int)},
|
||||
{ "hostid", "string", (void*) string_parser, offsetof(struct __config, hostid), HOSTID, MAXVAL-1},
|
||||
{ "iv", "string", (void*) string_parser, offsetof(struct __config, iv), "", MAXVAL-1},
|
||||
{ "listen_addr", "string", (void*) string_parser, offsetof(struct __config, listen_addr), "0.0.0.0", MAXVAL-1},
|
||||
|
@ -52,6 +52,7 @@ struct __config {
|
||||
char locale[MAXVAL];
|
||||
|
||||
int session_timeout;
|
||||
int helper_timeout;
|
||||
|
||||
char piler_header_field[MAXVAL];
|
||||
char extra_to_field[MAXVAL];
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#define VERSION "1.1.1-pre"
|
||||
|
||||
#define BUILD 895
|
||||
#define BUILD 896
|
||||
|
||||
#define HOSTID "mailarchiver"
|
||||
|
||||
|
@ -91,7 +91,7 @@ int extract_opendocument(struct session_data *sdata, struct _state *state, char
|
||||
}
|
||||
|
||||
|
||||
int unzip_file(struct session_data *sdata, struct _state *state, char *filename, int *rec){
|
||||
int unzip_file(struct session_data *sdata, struct _state *state, char *filename, int *rec, struct __config *cfg){
|
||||
int errorp, i=0, len=0, fd;
|
||||
char *p, extracted_filename[SMALLBUFSIZE], buf[MAXBUFSIZE];
|
||||
struct zip *z;
|
||||
@ -127,7 +127,7 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
|
||||
|
||||
close(fd);
|
||||
|
||||
extract_attachment_content(sdata, state, extracted_filename, get_attachment_extractor_by_filename(extracted_filename), rec);
|
||||
extract_attachment_content(sdata, state, extracted_filename, get_attachment_extractor_by_filename(extracted_filename), rec, cfg);
|
||||
|
||||
unlink(extracted_filename);
|
||||
|
||||
@ -156,7 +156,7 @@ int unzip_file(struct session_data *sdata, struct _state *state, char *filename,
|
||||
|
||||
#ifdef HAVE_TNEF
|
||||
|
||||
int extract_tnef(struct session_data *sdata, struct _state *state, char *filename){
|
||||
int extract_tnef(struct session_data *sdata, struct _state *state, char *filename, struct __config *cfg){
|
||||
int rc=0, n, rec=1;
|
||||
char tmpdir[BUFLEN], buf[SMALLBUFSIZE];
|
||||
struct dirent **namelist;
|
||||
@ -179,7 +179,7 @@ int extract_tnef(struct session_data *sdata, struct _state *state, char *filenam
|
||||
if(strcmp(namelist[n]->d_name, ".") && strcmp(namelist[n]->d_name, "..")){
|
||||
snprintf(buf, sizeof(buf)-1, "%s/%s", tmpdir, namelist[n]->d_name);
|
||||
|
||||
extract_attachment_content(sdata, state, buf, get_attachment_extractor_by_filename(buf), &rec);
|
||||
extract_attachment_content(sdata, state, buf, get_attachment_extractor_by_filename(buf), &rec, cfg);
|
||||
|
||||
unlink(buf);
|
||||
}
|
||||
@ -196,11 +196,13 @@ int extract_tnef(struct session_data *sdata, struct _state *state, char *filenam
|
||||
|
||||
#endif
|
||||
|
||||
void read_content_with_popen(struct session_data *sdata, struct _state *state, char *cmd){
|
||||
void read_content_with_popen(struct session_data *sdata, struct _state *state, char *cmd, struct __config *cfg){
|
||||
int len;
|
||||
char buf[MAXBUFSIZE];
|
||||
FILE *f;
|
||||
|
||||
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_INFO, "running command: '%s'", cmd);
|
||||
|
||||
f = popen(cmd, "r");
|
||||
if(f){
|
||||
while(fgets(buf, sizeof(buf)-1, f)){
|
||||
@ -220,46 +222,51 @@ void read_content_with_popen(struct session_data *sdata, struct _state *state, c
|
||||
}
|
||||
|
||||
|
||||
void extract_attachment_content(struct session_data *sdata, struct _state *state, char *filename, char *type, int *rec){
|
||||
char cmd[SMALLBUFSIZE];
|
||||
void extract_attachment_content(struct session_data *sdata, struct _state *state, char *filename, char *type, int *rec, struct __config *cfg){
|
||||
char cmd[SMALLBUFSIZE], timeout[SMALLBUFSIZE];
|
||||
|
||||
if(strcmp(type, "other") == 0) return;
|
||||
|
||||
memset(cmd, 0, sizeof(cmd));
|
||||
memset(timeout, 0, sizeof(timeout));
|
||||
|
||||
#ifdef TIMEOUT_BINARY
|
||||
if(cfg->helper_timeout > 0) snprintf(timeout, sizeof(timeout)-1, "%s %d ", TIMEOUT_BINARY, cfg->helper_timeout);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PDFTOTEXT
|
||||
if(strcmp(type, "pdf") == 0) snprintf(cmd, sizeof(cmd)-1, "%s -enc UTF-8 %s -", HAVE_PDFTOTEXT, filename);
|
||||
if(strcmp(type, "pdf") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s -enc UTF-8 %s -", timeout, HAVE_PDFTOTEXT, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CATDOC
|
||||
if(strcmp(type, "doc") == 0) snprintf(cmd, sizeof(cmd)-1, "%s -d utf-8 %s", HAVE_CATDOC, filename);
|
||||
if(strcmp(type, "doc") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s -d utf-8 %s", timeout, HAVE_CATDOC, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CATPPT
|
||||
if(strcmp(type, "ppt") == 0) snprintf(cmd, sizeof(cmd)-1, "%s -d utf-8 %s", HAVE_CATPPT, filename);
|
||||
if(strcmp(type, "ppt") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s -d utf-8 %s", timeout, HAVE_CATPPT, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XLS2CSV
|
||||
if(strcmp(type, "xls") == 0) snprintf(cmd, sizeof(cmd)-1, "%s -d utf-8 %s", HAVE_XLS2CSV, filename);
|
||||
if(strcmp(type, "xls") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s -d utf-8 %s", timeout, HAVE_XLS2CSV, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PPTHTML
|
||||
if(strcmp(type, "ppt") == 0) snprintf(cmd, sizeof(cmd)-1, "%s %s", HAVE_PPTHTML, filename);
|
||||
if(strcmp(type, "ppt") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s %s", timeout, HAVE_PPTHTML, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNRTF
|
||||
if(strcmp(type, "rtf") == 0) snprintf(cmd, sizeof(cmd)-1, "%s --text %s", HAVE_UNRTF, filename);
|
||||
if(strcmp(type, "rtf") == 0) snprintf(cmd, sizeof(cmd)-1, "%s%s --text %s", timeout, HAVE_UNRTF, filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TNEF
|
||||
if(strcmp(type, "tnef") == 0){
|
||||
extract_tnef(sdata, state, filename);
|
||||
extract_tnef(sdata, state, filename, cfg);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(strlen(cmd) > 12){
|
||||
read_content_with_popen(sdata, state, cmd);
|
||||
read_content_with_popen(sdata, state, cmd, cfg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -288,7 +295,7 @@ void extract_attachment_content(struct session_data *sdata, struct _state *state
|
||||
|
||||
if(strcmp(type, "zip") == 0){
|
||||
if(*rec < MAX_ZIP_RECURSION_LEVEL){
|
||||
unzip_file(sdata, state, filename, rec);
|
||||
unzip_file(sdata, state, filename, rec, cfg);
|
||||
}
|
||||
else {
|
||||
syslog(LOG_PRIORITY, "%s: multiple recursion level zip attachment, skipping %s", sdata->ttmpfile, filename);
|
||||
|
@ -130,7 +130,7 @@ void post_parse(struct session_data *sdata, struct _state *state, struct __confi
|
||||
|
||||
if(state->attachments[i].dumped == 1){
|
||||
rec = 0;
|
||||
if(state->bodylen < BIGBUFSIZE-1024) extract_attachment_content(sdata, state, state->attachments[i].aname, get_attachment_extractor_by_filename(state->attachments[i].filename), &rec);
|
||||
if(state->bodylen < BIGBUFSIZE-1024) extract_attachment_content(sdata, state, state->attachments[i].aname, get_attachment_extractor_by_filename(state->attachments[i].filename), &rec, cfg);
|
||||
|
||||
unlink(state->attachments[i].aname);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ int add_new_folder(struct session_data *sdata, struct __data *data, char *folder
|
||||
|
||||
int store_index_data(struct session_data *sdata, struct _state *state, struct __data *data, uint64 id, struct __config *cfg);
|
||||
|
||||
void extract_attachment_content(struct session_data *sdata, struct _state *state, char *filename, char *type, int *rec);
|
||||
void extract_attachment_content(struct session_data *sdata, struct _state *state, char *filename, char *type, int *rec, struct __config *cfg);
|
||||
|
||||
int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *dest, struct __config *cfg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user