Ticket #3661: fcron-3.1.1-sendmail-upstream-1.patch

File fcron-3.1.1-sendmail-upstream-1.patch, 5.3 KB (added by thomas, 11 years ago)

Upstream patch against 3.1.1

  • configure.in

    From df13ddfffb37ed797386c1afc7658c9e8b171af3 Mon Sep 17 00:00:00 2001
    From: Thibault Godouet <fcron@free.fr>
    Date: Sun, 3 Feb 2013 13:03:52 +0000
    Subject: [PATCH] Fixed configure --without-sendmail, and compilation errors when sendmail is disabled
     Also don't check if email should be output if sendmail is disabled
     (Thank you Thomas Trepl for pointing out the problem and submitting a patch)
    
    ---
     configure.in |   23 +++++++++++++++++------
     fileconf.c   |    6 +++---
     job.c        |   44 +++++++++++++++++++++++---------------------
     3 files changed, 43 insertions(+), 30 deletions(-)
    
    diff --git a/configure.in b/configure.in
    index d0a4d7b..29abd5e 100644
    a b AC_ARG_ENABLE(checks,  
    181181dnl ---------------------------------------------------------------------
    182182dnl Programs ...
    183183
    184 AC_PATH_PROG(SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin )
     184AC_PATH_PROG(FOUND_SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin )
     185SENDMAIL=
    185186USE_SENDMAIL=1
    186187AC_MSG_CHECKING([actual sendmail to use])
    187188AC_ARG_WITH(sendmail, [  --with-sendmail=PATH   Path to sendmail.],
    AC_ARG_WITH(sendmail, [ --with-sendmail=PATH Path to sendmail.],  
    195196if test "$USE_SENDMAIL" != "1" ; then
    196197  AC_MSG_RESULT([disabled])
    197198  AC_MSG_WARN([Without sendmail you will not get the output of the jobs by mail])
    198 elif test -z "$SENDMAIL" ; then
     199elif test -n "$SENDMAIL" ; then
     200  dnl The user defined a sendmail program to use:
     201  if test ! -x "$SENDMAIL" ; then
     202    dnl ... but it is not an executable file!
     203    AC_MSG_RESULT([$SENDMAIL])
     204    AC_MSG_ERROR([File $SENDMAIL is not an executable file])
     205  else
     206    dnl ... and it is valid
     207    AC_MSG_RESULT([$SENDMAIL])
     208  fi
     209elif test -z "$FOUND_SENDMAIL" ; then
     210  dnl The user didn't defined a program to use, and we didn't find one automatically
    199211  AC_MSG_RESULT([not found])
    200212  AC_MSG_ERROR([Empty sendmail path or cannot determine path to sendmail: try option --with-sendmail=PATH])
    201 elif test ! -x "$SENDMAIL" ; then
    202   AC_MSG_RESULT([$SENDMAIL])
    203   AC_MSG_ERROR([File $SENDMAIL is not an executable file])
    204213else
     214  dnl Use the automatically found sendmail program:
     215  SENDMAIL="$FOUND_SENDMAIL"
    205216  AC_MSG_RESULT([$SENDMAIL])
    206217fi
    207218
    208219AC_SUBST([SENDMAIL])
    209 if test x"$USE_SENDMAIL" != x ; then
     220if test "$USE_SENDMAIL" = "1"; then
    210221  AC_DEFINE([USE_SENDMAIL])
    211222fi
    212223
  • fileconf.c

    diff --git a/fileconf.c b/fileconf.c
    index 3605a7d..b1fbead 100644
    a b read_freq(char *ptr, cf_t * cf)  
    14621462
    14631463#ifndef USE_SENDMAIL
    14641464    clear_mail(cl->cl_option);
    1465     clear_forcemail(cl->cl_option);
     1465    clear_mailzerolength(cl->cl_option);
    14661466#endif
    14671467
    14681468    cl->cl_next = cf->cf_line_base;
    read_arys(char *ptr, cf_t * cf)  
    15661566
    15671567#ifndef USE_SENDMAIL
    15681568    clear_mail(cl->cl_option);
    1569     clear_forcemail(cl->cl_option);
     1569    clear_mailzerolength(cl->cl_option);
    15701570#endif
    15711571
    15721572    cl->cl_next = cf->cf_line_base;
    read_period(char *ptr, cf_t * cf)  
    17211721 ok:
    17221722#ifndef USE_SENDMAIL
    17231723    clear_mail(cl->cl_option);
    1724     clear_forcemail(cl->cl_option);
     1724    clear_mailzerolength(cl->cl_option);
    17251725#endif
    17261726
    17271727    cl->cl_next = cf->cf_line_base;
  • job.c

    diff --git a/job.c b/job.c
    index c211d82..998da12 100644
    a b end_job(cl_t * line, int status, FILE * mailf, short mailpos,  
    768768    /* if task have made some output, mail it to user */
    769769{
    770770
    771     char mail_output;
    772     char *m;
    773 
    774     if (mailf != NULL && (is_mailzerolength(line->cl_option)
    775                           || (is_mail(line->cl_option)
    776                               && (
    777                                      /* job wrote some output and we wan't it in any case: */
    778                                      ((fseek(mailf, 0, SEEK_END) == 0
    779                                        && ftell(mailf) > mailpos)
    780                                       && !is_erroronlymail(line->cl_option))
    781                                      ||
    782                                      /* or we want an email only if the job returned an error: */
    783                                      !(WIFEXITED(status)
    784                                        && WEXITSTATUS(status) == 0)
    785                               )
    786                           )
    787         )
    788         )
     771    char mail_output = 0;
     772    char *m = NULL;
     773
     774#ifdef USE_SENDMAIL
     775    if (mailf != NULL
     776            && (is_mailzerolength(line->cl_option)
     777                || (is_mail(line->cl_option)
     778                    && (
     779                        /* job wrote some output and we wan't it in any case: */
     780                        ((fseek(mailf, 0, SEEK_END) == 0
     781                          && ftell(mailf) > mailpos)
     782                         && !is_erroronlymail(line->cl_option))
     783                        ||
     784                        /* or we want an email only if the job returned an error: */
     785                        !(WIFEXITED(status)
     786                            && WEXITSTATUS(status) == 0)
     787                       )
     788                   )
     789               )
     790        ) {
    789791        /* an output exit : we will mail it */
    790792        mail_output = 1;
    791     else
    792         /* no output */
    793         mail_output = 0;
     793    }
     794    /* or else there is no output to email -- mail_output is already set to 0 */
     795#endif /* USE_SENDMAIL */
    794796
    795797    m = (mail_output == 1) ? " (mailing output)" : "";
    796798    if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {