From 4dce9440947e3e3ff781c3b99ea64a7607e13729 Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Mon, 5 Apr 2010 18:40:25 +0100 Subject: [PATCH] Linked mail and forcemail: mail(no) implies forcemail(no) and forcemail(true) implies mail(true) --- doc/en/fcrontab.5.sgml | 2 ++ fileconf.c | 23 +++++++++++++++++------ job.c | 6 ++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/doc/en/fcrontab.5.sgml b/doc/en/fcrontab.5.sgml index 77b7e35..1a19903 100644 --- a/doc/en/fcrontab.5.sgml +++ b/doc/en/fcrontab.5.sgml @@ -473,6 +473,7 @@ useful when used in conjunction with option &optvolatile;. boolean(false) Mail output even if zero-length. + Setting this option to true will also set &optmail; to true. &seealso; options &optmail;, &optmailto;, &opterroronlymail;, &optnolog;. @@ -553,6 +554,7 @@ system load average values. boolean(true) Mail output (if any) or not. + Setting this option to false will also set &optforcemail; to false. &seealso; options &optmailto;, &optforcemail;, &opterroronlymail;, &optnolog;. diff --git a/fileconf.c b/fileconf.c index dddbd73..022ec87 100644 --- a/fileconf.c +++ b/fileconf.c @@ -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 488d53c..2364e4a 100644 --- 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. -- 2.50.1