Hi,

Currently, the crond (or cronie) has support for MAILTO variable to have the cron send the messages to a different email address than that of the user. I noticed that cron messages have weird subject form that of username, hostname and (lengthy) command line used.  I took a look at the cronie source and it sounded fairly trivial for adding support for configurable subject strings to the code base. 

So in the cronjobs, users can have MAIL_SUBJECT as the environment variable along with MAILTO environment variable that allows to modify the cron email's subject.

So, here is the patch I think works for me, but please let me know if there is anything else that needs to be checked in before having the patch committed.


thanks,
Nikhil


--- a/src/do_command.c
+++ b/src/do_command.c
@@ -88,7 +88,7 @@ void do_command(entry * e, user * u) {

 static int child_process(entry * e, char **jobenv) {
        int stdin_pipe[2], stdout_pipe[2];
-       char *input_data, *usernm, *mailto, *mailfrom;
+       char *input_data, *usernm, *mailto, *mailfrom, *mail_subject;
        int children = 0;
        pid_t pid = getpid();
        struct sigaction sa;
@@ -125,6 +125,7 @@ static int child_process(entry * e, char **jobenv) {
         */
        usernm = e->pwd->pw_name;
        mailto = env_get("MAILTO", jobenv);
+        mail_subject = env_get("MAIL_SUBJECT", jobenv);
        mailfrom = env_get("MAILFROM", e->envp);

        /* create some pipes to talk to our future child
@@ -437,8 +438,15 @@ static int child_process(entry * e, char **jobenv) {

                                fprintf(mail, "From: \"(Cron Daemon)\" <%s>\n", mailfrom);
                                fprintf(mail, "To: %s\n", mailto);
-                               fprintf(mail, "Subject: Cron <%s@%s> %s\n",
-                                       usernm, first_word(hostname, "."), e->cmd);
+                               /* MAIL_SUBJECT is set but if it is empty? */
+                               if (mail_subject && *mail_subject) {
+                                       fprintf(mail, "Subject: %s\n", mail_subject);
+                               } else {
+                                       fprintf(mail, "Subject: Cron <%s@%s> %s\n",
+                                               usernm,
+                                               first_word(hostname, "."),
+                                               e->cmd);
+                               }