]> granicus.if.org Git - fcron/commitdiff
Linked mail and forcemail: mail(no) implies forcemail(no) and forcemail(true) implies...
authorThibault Godouet <thib@wind.(none)>
Mon, 5 Apr 2010 17:40:25 +0000 (18:40 +0100)
committerThibault Godouet <thib@wind.(none)>
Mon, 5 Apr 2010 17:45:08 +0000 (18:45 +0100)
doc/en/fcrontab.5.sgml
fileconf.c
job.c

index 77b7e35e6946b685d20a8e0c74f924ff5d8eb090..1a199031f0128d8f4fc6bb00baf5d6fa952743f0 100644 (file)
@@ -473,6 +473,7 @@ useful when used in conjunction with option &optvolatile;.</para>
                    <listitem>
                        <para><emphasis><type>boolean</type></emphasis>(<constant>false</constant>)</para>
                        <para>Mail output even if zero-length.</para>
+                       <para>Setting this option to true will also set &optmail; to true.</para>
                        <para>&seealso; options &optmail;, &optmailto;,
 &opterroronlymail;, &optnolog;.</para>
                    </listitem>
@@ -553,6 +554,7 @@ system load average values.</para>
                    <listitem>
                        <para><emphasis><type>boolean</type></emphasis>(<constant>true</constant>)</para>
                        <para>Mail output (if any) or not.</para>
+                       <para>Setting this option to false will also set &optforcemail; to false.</para>
                        <para>&seealso; options &optmailto;, &optforcemail;,
 &opterroronlymail;, &optnolog;.</para>
                    </listitem>
index dddbd734189776df0cd7b9600135b87b0cdcd554..022ec871de8f8c08065f766909e2f1c8b91b0cb1 100644 (file)
@@ -333,8 +333,10 @@ read_env(char *ptr, cf_t *cf)
      *  we don't store it in the same way. */
     /* please note that we check if the mailto is valid in conf.c */
     if ( strcmp(name, "MAILTO") == 0 ) {
-       if ( strcmp(val, "\0") == 0 )
+       if ( strcmp(val, "\0") == 0 ) {
            clear_mail(default_line.cl_option);
+           clear_forcemail(default_line.cl_option);
+        }
        else {
            Set(default_line.cl_mailto, val);
            set_mail(default_line.cl_option);
@@ -735,10 +737,12 @@ read_opt(char *ptr, cl_t *cl)
        else if(strcmp(opt_name, "m")==0 || strcmp(opt_name, "mail")==0){
            if ( in_brackets && (ptr = get_bool(ptr, &i)) == NULL )
                Handle_err;
-           if ( i == 0 )
+           if ( i == 0 ) {
                clear_mail(cl->cl_option);
+               clear_forcemail(cl->cl_option);
+            }
            else
-               set_mail(cl->cl_option);        
+               set_mail(cl->cl_option);
            if (debug_opt)
                fprintf(stderr, "  Opt : \"%s\" %d\n", opt_name, i);
        }
@@ -748,8 +752,10 @@ read_opt(char *ptr, cl_t *cl)
                Handle_err;
            if ( i == 0 )
                clear_mailzerolength(cl->cl_option);
-           else
-               set_mailzerolength(cl->cl_option);      
+           else {
+               set_mailzerolength(cl->cl_option);
+               set_mail(cl->cl_option);
+            }
            if (debug_opt)
                fprintf(stderr, "  Opt : \"%s\" %d\n", opt_name, i);
        }
@@ -765,8 +771,10 @@ read_opt(char *ptr, cl_t *cl)
            i = 0;
            while ( *ptr != ')' && i + 1 < sizeof(buf) )
                buf[i++] = *ptr++;
-           if ( strcmp(buf, "\0") == 0 )
+           if ( strcmp(buf, "\0") == 0 ) {
                clear_mail(cl->cl_option);
+               clear_forcemail(cl->cl_option);
+            }
            else {
                    Set(cl->cl_mailto, buf);
                    set_mail(cl->cl_option);
@@ -1191,6 +1199,7 @@ read_freq(char *ptr, cf_t *cf)
 
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
+    clear_forcemail(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
@@ -1296,6 +1305,7 @@ read_arys(char *ptr, cf_t *cf)
 
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
+    clear_forcemail(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
@@ -1434,6 +1444,7 @@ read_period(char *ptr, cf_t *cf)
   ok:
 #ifndef USE_SENDMAIL
     clear_mail(cl->cl_option);
+    clear_forcemail(cl->cl_option);
 #endif
 
     cl->cl_next = cf->cf_line_base;
diff --git a/job.c b/job.c
index 488d53c289fa5e2e7d7d0be6f6b3902c12492e2a..2364e4ad47ded6694264b485bbc3c35583141523 100644 (file)
--- a/job.c
+++ b/job.c
@@ -497,8 +497,7 @@ run_job(struct exe_t *exeent)
 
        /* // */
        debug("run_job(): child: %s, output to %s, %s, %s\n",
-             is_mail(line->cl_option) || is_mailzerolength(line->cl_option) ?
-             "mail" : "no mail",
+             is_mail(line->cl_option) ? "mail" : "no mail",
              to_stdout ? "stdout" : "file",
              foreground ? "running in foreground" : "running in background",
              is_stdout(line->cl_option) ? "stdout" : "normal" );
@@ -516,8 +515,7 @@ run_job(struct exe_t *exeent)
            error_e("child: could not close(pipe_pid_fd[0])");
 
        pipe_fd[0] = pipe_fd[1] = -1;
-       if ( ! to_stdout && 
-            ( is_mail(line->cl_option) || is_mailzerolength(line->cl_option))){
+       if ( ! to_stdout && is_mail(line->cl_option) ) {
            /* we create the temp file (if needed) before change_user(),
             * as temp_file() needs root privileges */
            /* if we run in foreground, stdout and stderr point to the console.