From 26627b1a2064c484b8188335e40b72634ad23ba5 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Thu, 4 Apr 2024 12:57:32 +0200 Subject: [PATCH] pilerimport supports Zimbra IMAP impersonation (Credits: SEMATPL) Signed-off-by: Janos SUTO --- RELEASE_NOTES | 14 ++++++++++++++ src/imap.c | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index fce10d21..31c6dd47 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -5,6 +5,20 @@ If using sphinx, add the following to config-site.php: $config['SPHINX_HOSTNAME_READONLY'] = '127.0.0.1:9306'; +- pilerimport supports Zimbra IMAP impersonation + + Generate the following base64 encoded string: + (Be sure to use the actual usernames and password): + + pw="$( printf '%s\0%s\0%s' 'username' 'zimbra_admin_username' 'zimbra_admin_password' | base64 )" + + Then specify -u ZIMBRA -p "$pw" for pilerimport, eg. + + pilerimport -i imap.server -u ZIMBRA -p "$pw" ... + + Note that "ZIMBRA" is a special username, it indicates for pilerimport + to actually use the imap impersonation for Zimbra. + 1.4.4: ------ diff --git a/src/imap.c b/src/imap.c index 9f225180..5d7c7d08 100644 --- a/src/imap.c +++ b/src/imap.c @@ -105,7 +105,12 @@ int connect_to_imap_server(struct data *data){ /* imap cmd: LOGIN */ - snprintf(buf, sizeof(buf)-1, "A%d LOGIN %s \"%s\"\r\n", data->import->seq, data->import->username, data->import->password); + if(strcmp(data->import->username, "ZIMBRA") == 0){ + snprintf(buf, sizeof(buf)-1, "A%d AUTHENTICATE PLAIN %s\r\n", data->import->seq, data->import->password); + } + else { + snprintf(buf, sizeof(buf)-1, "A%d LOGIN %s \"%s\"\r\n", data->import->seq, data->import->username, data->import->password); + } write1(data->net, buf, strlen(buf)); if(read_response(buf, sizeof(buf), data) == 0){