From f28b8857a9fa7b2b137a19ce7069077da5706d78 Mon Sep 17 00:00:00 2001 From: "Raffaello D. Di Napoli" Date: Tue, 26 Jun 2018 19:17:45 -0400 Subject: sendmail: support AUTH PLAIN in addition to AUTH LOGIN Implement the -am argument to allow choosing an AUTH method. For now only PLAIN and LOGIN are supported, but others can be added easily in the future. AUTH PLAIN required adding a new variant of encode_base64() capable of handling NUL characters in the input string; the old function is now a wrapper for the newer one. function old new delta encode_n_base64 - 236 +236 sendmail_main 1199 1380 +181 packed_usage 32873 32877 +4 encode_base64 242 36 -206 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/1 up/down: 421/-206) Total: 215 bytes Signed-off-by: Raffaello D. Di Napoli Signed-off-by: Denys Vlasenko --- mailutils/mail.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mailutils/mail.c') diff --git a/mailutils/mail.c b/mailutils/mail.c index 7af7edd6c..2ad959f7d 100644 --- a/mailutils/mail.c +++ b/mailutils/mail.c @@ -108,6 +108,17 @@ static char* FAST_FUNC parse_url(char *url, char **user, char **pass) */ void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol) +{ + size_t len = len; + if (text) { + // though we do not call uuencode(NULL, NULL) explicitly + // still we do not want to break things suddenly + len = strlen(text); + } + encode_n_base64(fname, text, len, eol); +} + +void FAST_FUNC encode_n_base64(char *fname, const char *text, size_t len, const char *eol) { enum { SRC_BUF_SIZE = 57, /* This *MUST* be a multiple of 3 */ @@ -116,17 +127,12 @@ void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol) #define src_buf text char src[SRC_BUF_SIZE]; FILE *fp = fp; - ssize_t len = len; char dst_buf[DST_BUF_SIZE + 1]; if (fname) { fp = (NOT_LONE_DASH(fname)) ? xfopen_for_read(fname) : (FILE *)text; src_buf = src; - } else if (text) { - // though we do not call uuencode(NULL, NULL) explicitly - // still we do not want to break things suddenly - len = strlen(text); - } else + } else if (!text) return; while (1) { -- cgit v1.2.3