mdadm/0054-mdmonitor-use-MAILFROM-to-set-sendmail-envelope-send.patch
Xiao Ni aa7b8fe976 Update to latest upstream
Resolves: RHEL-100004, RHEL-107084

Signed-off-by: Xiao Ni <xni@redhat.com>
2025-10-28 17:17:30 +08:00

48 lines
1.2 KiB
Diff

From 34f21b7acea8afbea9348d0f421beeeedca7a136 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 7 May 2025 17:49:05 +0200
Subject: [PATCH 54/74] mdmonitor: use MAILFROM to set sendmail envelope sender
address
Modern mail relays may reject emails with unknown envelope sender
address.
Use the MAILFROM address also as envelope sender address to work
around this issue.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
mdmonitor.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/mdmonitor.c b/mdmonitor.c
index d51617cd0981..ea35d98ede30 100644
--- a/mdmonitor.c
+++ b/mdmonitor.c
@@ -639,11 +639,20 @@ static void execute_alert_cmd(const struct event_data *data)
*/
static void send_event_email(const struct event_data *data)
{
- FILE *mp, *mdstat;
+ FILE *mp = NULL, *mdstat;
char buf[BUFSIZ];
int n;
- mp = popen(Sendmail, "w");
+ if (info.mailfrom) {
+ char cmd[1024];
+ int rc = snprintf(cmd, sizeof(cmd), "%s -f%s",
+ Sendmail, info.mailfrom);
+
+ if (rc >= 0 && (unsigned int)rc < sizeof(cmd))
+ mp = popen(cmd, "w");
+ }
+ if (mp == NULL)
+ mp = popen(Sendmail, "w");
if (!mp) {
pr_err("Cannot open pipe stream for sendmail.\n");
return;
--
2.50.1