summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2020-09-28 11:50:33 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2020-09-28 11:50:33 (GMT)
commit7de713903958175e87c1f7c4967ef449ed749e7e (patch) (side-by-side diff)
tree5fb3df92d9bc47d78e932072f4780c5a5fdbf5a7
parent5ca6382fe8adb5bc436a6d873c8b86c69d5abfd1 (diff)
downloadmailutils-7de713903958175e87c1f7c4967ef449ed749e7e.tar.gz
mailutils-7de713903958175e87c1f7c4967ef449ed749e7e.tar.bz2
Fix last resort return for message_envelope_sender.
* libmailutils/mailbox/msgenv.c (message_envelope_sender): Fix conditional. Use mu_get_user_email instead of tinkering with mu_auth_data. * sieve/tests/moderator.at: Fix expected output.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libmailutils/mailbox/msgenv.c14
-rw-r--r--sieve/tests/moderator.at2
2 files changed, 8 insertions, 8 deletions
diff --git a/libmailutils/mailbox/msgenv.c b/libmailutils/mailbox/msgenv.c
index 530f73f..5ed0bde 100644
--- a/libmailutils/mailbox/msgenv.c
+++ b/libmailutils/mailbox/msgenv.c
@@ -214,7 +214,7 @@ message_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
mu_header_t header;
int status;
const char *sender;
- struct mu_auth_data *auth;
+ char *email;
static char *hdrnames[] = {
"Return-Path",
"X-Envelope-Sender",
@@ -277,7 +277,7 @@ message_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
return 0;
}
- if (save_i)
+ if (save_i != -1)
{
status = mu_header_sget_value (header, hdrnames[save_i], &sender);
if (status == 0)
@@ -287,11 +287,11 @@ message_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
}
}
- auth = mu_get_auth_by_uid (getuid ());
- if (!auth)
- return MU_ERR_NOENT;
- save_return (auth->name, buf, len, pnwrite);
- mu_auth_data_free (auth);
+ email = mu_get_user_email (NULL);
+ if (!email)
+ return errno;
+ save_return (email, buf, len, pnwrite);
+ free (email);
return 0;
}
diff --git a/sieve/tests/moderator.at b/sieve/tests/moderator.at
index 1d2dfa3..67aba7b 100644
--- a/sieve/tests/moderator.at
+++ b/sieve/tests/moderator.at
@@ -30,7 +30,7 @@ sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -f ./mailbox prog || exit 1
cat $MAIL_DUMP
],
[[MSGID: 0001
-SENDER: gray@nonexistent.net
+SENDER: foobar@nonexistent.net
NRCPT: 1
RCPT[0]: bug-foobar-request@example.org
LENGTH: 94

Return to:

Send suggestions and report system problems to the System administrator.