]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: specify recipient in message when sending email
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 20 Jun 2018 11:02:55 +0000 (13:02 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 20 Jun 2018 14:45:26 +0000 (16:45 +0200)
Instead of adding the recipient to the sendmail command line (which is
interpretted by the shell) add a "To" line to the message and run
sendmail with the -t option to read the recipient from the message.

reference.c

index 0ae7ab2d1848af47853df884087957e868cae5ad..9c1d70fb3f1436b4224dfe3882ce2b5060568bf5 100644 (file)
@@ -539,7 +539,7 @@ maybe_log_offset(double offset, time_t now)
 
   if (do_mail_change &&
       (abs_offset > mail_change_threshold)) {
-    snprintf(buffer, sizeof(buffer), "%s %." S_MAX_USER_LEN "s", MAIL_PROGRAM, mail_change_user);
+    snprintf(buffer, sizeof (buffer), "%s -t", MAIL_PROGRAM);
     p = popen(buffer, "w");
     if (p) {
       if (gethostname(host, sizeof(host)) < 0) {
@@ -547,6 +547,7 @@ maybe_log_offset(double offset, time_t now)
       }
       host[sizeof (host) - 1] = '\0';
 
+      fprintf(p, "To: %s\n", mail_change_user);
       fprintf(p, "Subject: chronyd reports change to system clock on node [%s]\n", host);
       fputs("\n", p);