From 04e46f9f5b1e14ba99fe2ec6ca776a69aba9f262 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Fri, 3 Mar 2023 09:57:09 +0100 Subject: [PATCH] [Imapsync] Use pure perl code for XOAUTH2 authmech --- data/Dockerfiles/dovecot/Dockerfile | 4 ++++ data/Dockerfiles/dovecot/imapsync | 6 ++++-- docker-compose.yml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/data/Dockerfiles/dovecot/Dockerfile b/data/Dockerfiles/dovecot/Dockerfile index 1d8e1e5b..ae7984e3 100644 --- a/data/Dockerfiles/dovecot/Dockerfile +++ b/data/Dockerfiles/dovecot/Dockerfile @@ -21,6 +21,7 @@ RUN groupadd -g 5000 vmail \ && touch /etc/default/locale \ && apt-get update \ && apt-get -y --no-install-recommends install \ + build-essential \ apt-transport-https \ ca-certificates \ cpanminus \ @@ -61,6 +62,7 @@ RUN groupadd -g 5000 vmail \ libproc-processtable-perl \ libreadonly-perl \ libregexp-common-perl \ + libssl-dev \ libsys-meminfo-perl \ libterm-readkey-perl \ libtest-deep-perl \ @@ -110,6 +112,8 @@ RUN groupadd -g 5000 vmail \ && apt-get autoclean \ && rm -rf /var/lib/apt/lists/* \ && rm -rf /tmp/* /var/tmp/* /root/.cache/ +# imapsync dependencies +RUN cpan Crypt::OpenSSL::PKCS12 COPY trim_logs.sh /usr/local/bin/trim_logs.sh COPY clean_q_aged.sh /usr/local/bin/clean_q_aged.sh diff --git a/data/Dockerfiles/dovecot/imapsync b/data/Dockerfiles/dovecot/imapsync index 0d34504e..de63d658 100755 --- a/data/Dockerfiles/dovecot/imapsync +++ b/data/Dockerfiles/dovecot/imapsync @@ -8492,6 +8492,7 @@ sub xoauth2 require HTML::Entities ; require JSON ; require JSON::WebToken::Crypt::RSA ; + require Crypt::OpenSSL::PKCS12; require Crypt::OpenSSL::RSA ; require Encode::Byte ; require IO::Socket::SSL ; @@ -8532,8 +8533,9 @@ sub xoauth2 $sync->{ debug } and myprint( "Service account: $iss\nKey file: $keyfile\nKey password: $keypass\n"); - # Get private key from p12 file (would be better in perl...) - $key = `openssl pkcs12 -in "$keyfile" -nodes -nocerts -passin pass:$keypass -nomacver`; + # Get private key from p12 file + my $pkcs12 = Crypt::OpenSSL::PKCS12->new_from_file($keyfile); + $key = $pkcs12->private_key($keypass); $sync->{ debug } and myprint( "Private key:\n$key\n"); } diff --git a/docker-compose.yml b/docker-compose.yml index 7c6c5d6a..40d22ce0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -216,7 +216,7 @@ services: - sogo dovecot-mailcow: - image: mailcow/dovecot:1.22 + image: mailcow/dovecot:1.23 depends_on: - mysql-mailcow dns: