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,
|
181 | 181 | dnl --------------------------------------------------------------------- |
182 | 182 | dnl Programs ... |
183 | 183 | |
184 | | AC_PATH_PROG(SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin ) |
| 184 | AC_PATH_PROG(FOUND_SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin ) |
| 185 | SENDMAIL= |
185 | 186 | USE_SENDMAIL=1 |
186 | 187 | AC_MSG_CHECKING([actual sendmail to use]) |
187 | 188 | AC_ARG_WITH(sendmail, [ --with-sendmail=PATH Path to sendmail.], |
… |
… |
AC_ARG_WITH(sendmail, [ --with-sendmail=PATH Path to sendmail.],
|
195 | 196 | if test "$USE_SENDMAIL" != "1" ; then |
196 | 197 | AC_MSG_RESULT([disabled]) |
197 | 198 | AC_MSG_WARN([Without sendmail you will not get the output of the jobs by mail]) |
198 | | elif test -z "$SENDMAIL" ; then |
| 199 | elif 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 |
| 209 | elif test -z "$FOUND_SENDMAIL" ; then |
| 210 | dnl The user didn't defined a program to use, and we didn't find one automatically |
199 | 211 | AC_MSG_RESULT([not found]) |
200 | 212 | 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]) |
204 | 213 | else |
| 214 | dnl Use the automatically found sendmail program: |
| 215 | SENDMAIL="$FOUND_SENDMAIL" |
205 | 216 | AC_MSG_RESULT([$SENDMAIL]) |
206 | 217 | fi |
207 | 218 | |
208 | 219 | AC_SUBST([SENDMAIL]) |
209 | | if test x"$USE_SENDMAIL" != x ; then |
| 220 | if test "$USE_SENDMAIL" = "1"; then |
210 | 221 | AC_DEFINE([USE_SENDMAIL]) |
211 | 222 | fi |
212 | 223 | |
diff --git a/fileconf.c b/fileconf.c
index 3605a7d..b1fbead 100644
a
|
b
|
read_freq(char *ptr, cf_t * cf)
|
1462 | 1462 | |
1463 | 1463 | #ifndef USE_SENDMAIL |
1464 | 1464 | clear_mail(cl->cl_option); |
1465 | | clear_forcemail(cl->cl_option); |
| 1465 | clear_mailzerolength(cl->cl_option); |
1466 | 1466 | #endif |
1467 | 1467 | |
1468 | 1468 | cl->cl_next = cf->cf_line_base; |
… |
… |
read_arys(char *ptr, cf_t * cf)
|
1566 | 1566 | |
1567 | 1567 | #ifndef USE_SENDMAIL |
1568 | 1568 | clear_mail(cl->cl_option); |
1569 | | clear_forcemail(cl->cl_option); |
| 1569 | clear_mailzerolength(cl->cl_option); |
1570 | 1570 | #endif |
1571 | 1571 | |
1572 | 1572 | cl->cl_next = cf->cf_line_base; |
… |
… |
read_period(char *ptr, cf_t * cf)
|
1721 | 1721 | ok: |
1722 | 1722 | #ifndef USE_SENDMAIL |
1723 | 1723 | clear_mail(cl->cl_option); |
1724 | | clear_forcemail(cl->cl_option); |
| 1724 | clear_mailzerolength(cl->cl_option); |
1725 | 1725 | #endif |
1726 | 1726 | |
1727 | 1727 | cl->cl_next = cf->cf_line_base; |
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,
|
768 | 768 | /* if task have made some output, mail it to user */ |
769 | 769 | { |
770 | 770 | |
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 | ) { |
789 | 791 | /* an output exit : we will mail it */ |
790 | 792 | 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 */ |
794 | 796 | |
795 | 797 | m = (mail_output == 1) ? " (mailing output)" : ""; |
796 | 798 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { |