]> granicus.if.org Git - fcron/commitdiff
Fixed configure --without-sendmail, and compilation errors when sendmail is disabled
authorThibault Godouet <fcron@free.fr>
Sun, 3 Feb 2013 13:03:52 +0000 (13:03 +0000)
committerThibault Godouet <fcron@free.fr>
Sun, 3 Feb 2013 13:05:26 +0000 (13:05 +0000)
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
fileconf.c
job.c

index d0a4d7bd03cf0b175c6e66638f57ba8cf3635334..29abd5ee22726c21cc442d1203a53e3e81947b7e 100644 (file)
@@ -181,7 +181,8 @@ AC_ARG_ENABLE(checks,
 dnl ---------------------------------------------------------------------
 dnl Programs ...
 
-AC_PATH_PROG(SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin )
+AC_PATH_PROG(FOUND_SENDMAIL, sendmail, , $PATH:/usr/lib:/usr/sbin )
+SENDMAIL=
 USE_SENDMAIL=1
 AC_MSG_CHECKING([actual sendmail to use])
 AC_ARG_WITH(sendmail, [  --with-sendmail=PATH  Path to sendmail.],
@@ -195,18 +196,28 @@ AC_ARG_WITH(sendmail, [  --with-sendmail=PATH     Path to sendmail.],
 if test "$USE_SENDMAIL" != "1" ; then
   AC_MSG_RESULT([disabled])
   AC_MSG_WARN([Without sendmail you will not get the output of the jobs by mail])
-elif test -z "$SENDMAIL" ; then
+elif test -n "$SENDMAIL" ; then
+  dnl The user defined a sendmail program to use:
+  if test ! -x "$SENDMAIL" ; then
+    dnl ... but it is not an executable file!
+    AC_MSG_RESULT([$SENDMAIL])
+    AC_MSG_ERROR([File $SENDMAIL is not an executable file])
+  else
+    dnl ... and it is valid
+    AC_MSG_RESULT([$SENDMAIL])
+  fi
+elif test -z "$FOUND_SENDMAIL" ; then
+  dnl The user didn't defined a program to use, and we didn't find one automatically
   AC_MSG_RESULT([not found])
   AC_MSG_ERROR([Empty sendmail path or cannot determine path to sendmail: try option --with-sendmail=PATH])
-elif test ! -x "$SENDMAIL" ; then
-  AC_MSG_RESULT([$SENDMAIL])
-  AC_MSG_ERROR([File $SENDMAIL is not an executable file])
 else
+  dnl Use the automatically found sendmail program:
+  SENDMAIL="$FOUND_SENDMAIL"
   AC_MSG_RESULT([$SENDMAIL])
 fi
 
 AC_SUBST([SENDMAIL])
-if test x"$USE_SENDMAIL" != x ; then
+if test "$USE_SENDMAIL" = "1"; then
   AC_DEFINE([USE_SENDMAIL])
 fi
 
index 3605a7dbf7a72b46d72670726684ede1f0f3b6c6..b1fbead39aac4df469b0bf82909cc21e4bf1f107 100644 (file)
@@ -1462,7 +1462,7 @@ read_freq(char *ptr, cf_t * cf)
 
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
-    clear_forcemail(cl->cl_option);
+    clear_mailzerolength(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
@@ -1566,7 +1566,7 @@ read_arys(char *ptr, cf_t * cf)
 
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
-    clear_forcemail(cl->cl_option);
+    clear_mailzerolength(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
@@ -1721,7 +1721,7 @@ read_period(char *ptr, cf_t * cf)
  ok:
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
-    clear_forcemail(cl->cl_option);
+    clear_mailzerolength(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
diff --git a/job.c b/job.c
index c211d82304a76ea1a803c8495f2ee981cc9132bb..998da1271ff787ea1334bb66de5c0fccacffd152 100644 (file)
--- a/job.c
+++ b/job.c
@@ -768,29 +768,31 @@ end_job(cl_t * line, int status, FILE * mailf, short mailpos,
     /* if task have made some output, mail it to user */
 {
 
-    char mail_output;
-    char *m;
-
-    if (mailf != NULL && (is_mailzerolength(line->cl_option)
-                          || (is_mail(line->cl_option)
-                              && (
-                                     /* job wrote some output and we wan't it in any case: */
-                                     ((fseek(mailf, 0, SEEK_END) == 0
-                                       && ftell(mailf) > mailpos)
-                                      && !is_erroronlymail(line->cl_option))
-                                     ||
-                                     /* or we want an email only if the job returned an error: */
-                                     !(WIFEXITED(status)
-                                       && WEXITSTATUS(status) == 0)
-                              )
-                          )
-        )
-        )
+    char mail_output = 0;
+    char *m = NULL;
+
+#ifdef USE_SENDMAIL
+    if (mailf != NULL
+            && (is_mailzerolength(line->cl_option)
+                || (is_mail(line->cl_option)
+                    && (
+                        /* job wrote some output and we wan't it in any case: */
+                        ((fseek(mailf, 0, SEEK_END) == 0
+                          && ftell(mailf) > mailpos)
+                         && !is_erroronlymail(line->cl_option))
+                        ||
+                        /* or we want an email only if the job returned an error: */
+                        !(WIFEXITED(status)
+                            && WEXITSTATUS(status) == 0)
+                       )
+                   )
+               )
+        ) {
         /* an output exit : we will mail it */
         mail_output = 1;
-    else
-        /* no output */
-        mail_output = 0;
+    }
+    /* or else there is no output to email -- mail_output is already set to 0 */
+#endif /* USE_SENDMAIL */
 
     m = (mail_output == 1) ? " (mailing output)" : "";
     if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {