From b6b1a203d049cf0f6e97675b64f8147829790bc2 Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 22 Feb 2013 15:01:21 +0100 Subject: [PATCH] added a tweak option to change the sent time piler stores --- configure | 215 ++++++++++++++++++++++++------------------- configure.in | 11 +++ etc/example.conf | 7 ++ piler-config.h.in | 1 + src/cfg.c | 1 + src/cfg.h | 2 + src/config.h | 2 +- src/import.c | 3 +- src/misc.c | 8 +- src/misc.h | 2 +- src/pilerexport.c | 2 +- src/pilerpurge.c | 2 +- src/reindex.c | 2 +- src/session.c | 6 +- src/test.c | 2 +- test/debug.c | 2 +- test/import_helper.c | 2 +- test/ptest.c | 2 +- 18 files changed, 163 insertions(+), 109 deletions(-) diff --git a/configure b/configure index 06cc348d..7193cb9e 100755 --- a/configure +++ b/configure @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68. +# Generated by GNU Autoconf 2.69. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -212,21 +236,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -328,6 +356,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -504,28 +544,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -677,6 +697,7 @@ enable_clamd enable_memcached enable_starttls enable_tcpwrappers +enable_tweak_sent_time with_piler_user ' ac_precious_vars='build_alias @@ -1143,8 +1164,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1302,6 +1321,7 @@ Optional Features: --enable-memcached build memcached support --enable-starttls build starttls support --enable-tcpwrappers build tcpwrappers support + --tweak-sent-time tweak sent time Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1385,9 +1405,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1660,7 +1680,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1683,7 +1703,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2060,7 +2080,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2100,7 +2120,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2153,7 +2173,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2194,7 +2214,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2252,7 +2272,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2296,7 +2316,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2742,8 +2762,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -2925,7 +2944,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -3137,7 +3156,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3203,7 +3222,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3420,6 +3439,7 @@ have_zip="no" have_zlib="no" have_starttls="no" have_tcpwrappers="no" +have_tweak_sent_time="no" pdftotext="no" catdoc="no" @@ -3618,6 +3638,15 @@ ac_cv_lib_wrap=ac_cv_lib_wrap_main fi +# Check whether --enable-tweak-sent-time was given. +if test "${enable_tweak_sent_time+set}" = set; then : + enableval=$enable_tweak_sent_time; have_tweak_sent_time=$enableval +else + have_tweak_sent_time="no" +fi + + + for ac_header in math.h do : @@ -4221,7 +4250,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MYSQL_CONFIG="yes" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4577,6 +4606,16 @@ _ACEOF fi +if test "$have_tweak_sent_time" = "yes"; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_TWEAK_SENT_TIME 1 +_ACEOF + +fi + + + echo echo "pdftotext: $pdftotext" echo "catdoc: $catdoc" @@ -5006,16 +5045,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -5075,28 +5114,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -5118,7 +5145,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5180,10 +5207,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -5272,7 +5299,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/configure.in b/configure.in index 36db57bf..0ae71afa 100644 --- a/configure.in +++ b/configure.in @@ -42,6 +42,7 @@ have_zip="no" have_zlib="no" have_starttls="no" have_tcpwrappers="no" +have_tweak_sent_time="no" pdftotext="no" catdoc="no" @@ -124,6 +125,10 @@ if test "$want_tcpwrappers" = "yes"; then fi +AC_ARG_ENABLE(tweak-sent-time, + [ --tweak-sent-time tweak sent time], have_tweak_sent_time=$enableval, have_tweak_sent_time="no") + + dnl math library AC_CHECK_HEADERS(math.h, have_math=yes, have_math=no) @@ -376,6 +381,12 @@ if test z`which unrtf 2>/dev/null` != "z"; then fi +if test "$have_tweak_sent_time" = "yes"; then + AC_DEFINE_UNQUOTED(HAVE_TWEAK_SENT_TIME, 1, [tweak sent time]) +fi + + + echo echo "pdftotext: $pdftotext" echo "catdoc: $catdoc" diff --git a/etc/example.conf b/etc/example.conf index 9ed92b39..47386d98 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -150,3 +150,10 @@ mysqlpwd=verystrongpassword mysqldb=piler mysql_connect_timeout=2 + + +; if you want to change the 'sent' time as you archive the message +; set this in seconds. This can be a postive or negative value. +; By default this feature is not enabled, use --tweak-sent-time +; configure option to enable it. +tweak_sent_time_offset=0 diff --git a/piler-config.h.in b/piler-config.h.in index 01cc644c..7c58d171 100644 --- a/piler-config.h.in +++ b/piler-config.h.in @@ -20,3 +20,4 @@ #undef HAVE_STARTTLS #undef HAVE_LIBWRAP +#undef HAVE_TWEAK_SENT_TIME diff --git a/src/cfg.c b/src/cfg.c index 7f4a5b4b..2c7e8bc8 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -95,6 +95,7 @@ struct _parse_rule config_parse_rules[] = { "session_timeout", "integer", (void*) int_parser, offsetof(struct __config, session_timeout), "420", sizeof(int)}, { "spam_header_line", "string", (void*) string_parser, offsetof(struct __config, spam_header_line), "", MAXVAL-1}, { "tls_enable", "integer", (void*) int_parser, offsetof(struct __config, tls_enable), "0", sizeof(int)}, + { "tweak_sent_time_offset", "integer", (void*) int_parser, offsetof(struct __config, tweak_sent_time_offset), "0", sizeof(int)}, { "update_counters_to_memcached", "integer", (void*) int_parser, offsetof(struct __config, update_counters_to_memcached), "0", sizeof(int)}, { "username", "string", (void*) string_parser, offsetof(struct __config, username), "piler", MAXVAL-1}, { "use_antivirus", "integer", (void*) int_parser, offsetof(struct __config, use_antivirus), "1", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index c74baf7b..09e23946 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -72,6 +72,8 @@ struct __config { int min_word_len; + int tweak_sent_time_offset; + int debug; }; diff --git a/src/config.h b/src/config.h index 0bd77572..b1190ddd 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.23-master-branch" -#define BUILD 768 +#define BUILD 769 #define HOSTID "mailarchiver" diff --git a/src/import.c b/src/import.c index d64541ba..c4eb55c0 100644 --- a/src/import.c +++ b/src/import.c @@ -26,7 +26,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da struct __counters counters; - init_session_data(sdata, cfg->server_id); + init_session_data(sdata, cfg); if(cfg->verbosity > 1) printf("processing: %s\n", filename); @@ -109,6 +109,7 @@ ENDE: case ERR_EXISTS: rc = OK; + printf("duplicate: %s (id: %s)\n", filename, sdata->ttmpfile); break; default: diff --git a/src/misc.c b/src/misc.c index b83ea6c7..7c9b8bad 100644 --- a/src/misc.c +++ b/src/misc.c @@ -449,13 +449,13 @@ int is_email_address_on_my_domains(char *email, struct __data *data){ } -void init_session_data(struct session_data *sdata, unsigned char server_id){ +void init_session_data(struct session_data *sdata, struct __config *cfg){ int i; sdata->fd = -1; - create_id(&(sdata->ttmpfile[0]), server_id); + create_id(&(sdata->ttmpfile[0]), cfg->server_id); unlink(sdata->ttmpfile); snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", sdata->ttmpfile); @@ -496,6 +496,10 @@ void init_session_data(struct session_data *sdata, unsigned char server_id){ time(&(sdata->now)); sdata->sent = sdata->delivered = sdata->retained = sdata->now; + +#ifdef HAVE_TWEAK_SENT_TIME + sdata->sent += cfg->tweak_sent_time_offset; +#endif } diff --git a/src/misc.h b/src/misc.h index 24c6a7c5..bb1769cd 100644 --- a/src/misc.h +++ b/src/misc.h @@ -35,7 +35,7 @@ void write_pid_file(char *pidfile); int drop_privileges(struct passwd *pwd); int is_email_address_on_my_domains(char *email, struct __data *data); -void init_session_data(struct session_data *sdata, unsigned char server_id); +void init_session_data(struct session_data *sdata, struct __config *cfg); int read_from_stdin(struct session_data *sdata); void strtolower(char *s); diff --git a/src/pilerexport.c b/src/pilerexport.c index 12786a0e..09302a93 100644 --- a/src/pilerexport.c +++ b/src/pilerexport.c @@ -401,7 +401,7 @@ int main(int argc, char **argv){ if(read_key(&cfg)) p_clean_exit(ERR_READING_KEY, 1); - init_session_data(&sdata, cfg.server_id); + init_session_data(&sdata, &cfg); mysql_init(&(sdata.mysql)); diff --git a/src/pilerpurge.c b/src/pilerpurge.c index 4485f473..31d36330 100644 --- a/src/pilerpurge.c +++ b/src/pilerpurge.c @@ -348,7 +348,7 @@ int main(int argc, char **argv){ setlocale(LC_CTYPE, cfg.locale); - init_session_data(&sdata, cfg.server_id); + init_session_data(&sdata, &cfg); i = is_purge_allowed(&sdata, &cfg); if(i == 1){ diff --git a/src/reindex.c b/src/reindex.c index 6d48c0e0..7fe98830 100644 --- a/src/reindex.c +++ b/src/reindex.c @@ -212,7 +212,7 @@ int main(int argc, char **argv){ } } - init_session_data(&sdata, cfg.server_id); + init_session_data(&sdata, &cfg); mysql_init(&(sdata.mysql)); diff --git a/src/session.c b/src/session.c index c8b7d92b..23212831 100644 --- a/src/session.c +++ b/src/session.c @@ -54,7 +54,7 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ state = SMTP_STATE_INIT; - init_session_data(&sdata, cfg->server_id); + init_session_data(&sdata, cfg); sdata.tls = 0; bzero(&counters, sizeof(counters)); @@ -383,7 +383,7 @@ AFTER_PERIOD: unlink(sdata.ttmpfile); unlink(sdata.tmpframe); - init_session_data(&sdata, cfg->server_id); + init_session_data(&sdata, cfg); } state = SMTP_STATE_MAIL_FROM; @@ -489,7 +489,7 @@ AFTER_PERIOD: unlink(sdata.ttmpfile); unlink(sdata.tmpframe); - init_session_data(&sdata, cfg->server_id); + init_session_data(&sdata, cfg); state = SMTP_STATE_HELO; diff --git a/src/test.c b/src/test.c index 881afc87..08a60226 100644 --- a/src/test.c +++ b/src/test.c @@ -62,7 +62,7 @@ int main(int argc, char **argv){ load_mydomains(&sdata, &data, &cfg); - init_session_data(&sdata, cfg.server_id); + init_session_data(&sdata, &cfg); sdata.sent = 0; sdata.delivered = 0; diff --git a/test/debug.c b/test/debug.c index c589d737..e29952e5 100644 --- a/test/debug.c +++ b/test/debug.c @@ -34,7 +34,7 @@ int main(int argc, char **argv){ cfg = read_config(CONFIG_FILE); - init_session_data(&sdata, cfg.server_id); + init_session_data(&sdata, &cfg); sdata.sent = 0; sdata.tot_len = st.st_size; diff --git a/test/import_helper.c b/test/import_helper.c index 107341da..a7b68826 100644 --- a/test/import_helper.c +++ b/test/import_helper.c @@ -24,7 +24,7 @@ int import_message2(char *filename, struct session_data *sdata, struct __data *d struct _state state; - init_session_data(sdata, cfg->server_id); + init_session_data(sdata, cfg); if(strcmp(filename, "-") == 0){ diff --git a/test/ptest.c b/test/ptest.c index 74f864f0..f52b7b3c 100644 --- a/test/ptest.c +++ b/test/ptest.c @@ -40,7 +40,7 @@ int parse_it(char *filename, struct session_data *sdata, struct __data *data, st struct _state state; - init_session_data(sdata, cfg->server_id); + init_session_data(sdata, cfg); if(stat(filename, &st) != 0){ printf("cannot stat() %s\n", filename);