From nobody Fri Oct 20 16:22:35 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SBqcX1Gswz4xy3R; Fri, 20 Oct 2023 16:22:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SBqcX0kcPz3Msn; Fri, 20 Oct 2023 16:22:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697818956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j65jvkUaBJ7TywmtoxrxlMVtsGBe17v5389YrAxNwzE=; b=nc4G0Qpq7n5NqhkLsZE6RnPsajd8jugaMTjVhWz3Fx+B8jrwzKmZ9TYP3ip4yuxTuqRog/ kcfq+B4FJn/0r6f5e34G8kKNjsj42hDQDLvvc2ZSDKwiwrFkrDHfhQ5cEtzhIMaBt6uRlw woN5Xy9nOQpUNjF05FR/iwuwOHgid0Xh/KEwcNCDoDzsd+AdlX/OfbQJ2Op5Or+uoK7F5T UYB8pEz2vR5kCKBJ8v3R3RDSbGQpzI0ziOVRM0J43nZUoHrCPQ0PZG9jBM4/c0XQED/t50 PiOUb28/ZvuLPu4rHCF9Izx/xgx4e1MPKiwn+MFAx5a6Q+RTziQ4vTuruBC3SA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697818956; a=rsa-sha256; cv=none; b=OuURghuv7K0DecZEoUxxeLLOO1uH0NiaB/e+bNhrP6Lx66ZKJf5Swug9FJTftonrN6ibHN cRahyKc00kzN+pF+zL87KS3QwdlvFJ3BYtoAisblO/9OgnYHl48oMh/iEw4GCgOA9fTPp/ Hjq+8/i3rxksrmEwEx1SDggICGVpd6Xq1NPlHTHX3Cn7us44qH2eXyj/JQtc08tHlYjBBV 9+pQj/f9ARXH0AtKb7LIL90QDAr4MvuA/Q3oFydoTrnph45Dip9eu4ZP5qjOLlewy2LbLX N5xUiYwWScmDoykoBet4vaaN3suemMmztcdbUtB6j/cfDHYez2LgH5NdUncBpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697818956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j65jvkUaBJ7TywmtoxrxlMVtsGBe17v5389YrAxNwzE=; b=n6+WgZxdT6rqenN+VEKJnsF0aXqDi0kjgzkcy5fy9PsUliHlFsq6kKy2GrOjzZqVZy73ya 3F6Aj/JJ3HjTQwacIxazNBy9aA+NbAXaqB1MpSFGSqL91FbgG+dIn7PQPvfyMfi2JxKaOq GA4C1BqEkXxulSegW+Hj18wrCaVC41D02Y725Yl6cHkIBQQEAMAIMhsJ/Ypp/W5YLeWZzZ UGz95l7MbjNgOi92yNgEsl7JHJ85lwNf4EvedvUWlpIXhHD/CHmnoBfSG5jCtAunGbIvy2 mfyfS90XwdfYjPlAPk4+9E3EQNy4V9+X6qmbb7x4nwKvmhwahFuyAlOGDgkaXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SBqcW6vtzzg5q; Fri, 20 Oct 2023 16:22:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39KGMZrC072351; Fri, 20 Oct 2023 16:22:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39KGMZsN072348; Fri, 20 Oct 2023 16:22:35 GMT (envelope-from git) Date: Fri, 20 Oct 2023 16:22:35 GMT Message-Id: <202310201622.39KGMZsN072348@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Emanuel Haupt Subject: git: a4ef2ba2e61e - main - mail/isync: Resolve "unexpected EOF" SSL error List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ehaupt X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a4ef2ba2e61e3a4190f04c889ded4f6688163354 Auto-Submitted: auto-generated The branch main has been updated by ehaupt: URL: https://cgit.FreeBSD.org/ports/commit/?id=a4ef2ba2e61e3a4190f04c889ded4f6688163354 commit a4ef2ba2e61e3a4190f04c889ded4f6688163354 Author: François Charlier AuthorDate: 2023-10-20 16:15:41 +0000 Commit: Emanuel Haupt CommitDate: 2023-10-20 16:15:41 +0000 mail/isync: Resolve "unexpected EOF" SSL error Fixes an issue where some IMAP servers, such as Gmail, do not send a close notification (SSL_shutdown()) before closing the TCP socket, leading to "unexpected EOF" errors with OpenSSL 3.0. Now mbsync gracefully handles this scenario, preventing the following error: Socket error: secure read from imap.gmail.com ([IPv6 Address Redacted]:993): error:0A000126:SSL routines::unexpected eof while reading PR: 274604 --- mail/isync/Makefile | 1 + mail/isync/files/patch-src_drv__imap.c | 25 +++++++++++++++++++++++++ mail/isync/files/patch-src_socket.c | 18 ++++++++++++++++++ mail/isync/files/patch-src_socket.h | 10 ++++++++++ 4 files changed, 54 insertions(+) diff --git a/mail/isync/Makefile b/mail/isync/Makefile index 2bc408fa5f33..9de86aec08f2 100644 --- a/mail/isync/Makefile +++ b/mail/isync/Makefile @@ -1,5 +1,6 @@ PORTNAME= isync PORTVERSION= 1.4.4 +PORTREVISION= 1 CATEGORIES= mail MASTER_SITES= SF diff --git a/mail/isync/files/patch-src_drv__imap.c b/mail/isync/files/patch-src_drv__imap.c new file mode 100644 index 000000000000..bd3e044136a8 --- /dev/null +++ b/mail/isync/files/patch-src_drv__imap.c @@ -0,0 +1,25 @@ +--- src/drv_imap.c.orig 2021-12-03 10:56:16 UTC ++++ src/drv_imap.c +@@ -1620,6 +1620,7 @@ imap_socket_read( void *aux ) + error( "IMAP error: unexpected BYE response: %s\n", cmd ); + /* We just wait for the server to close the connection now. */ + ctx->expectEOF = 1; ++ socket_expect_eof( &ctx->conn ); + } else { + /* We still need to wait for the LOGOUT's tagged OK. */ + } +@@ -1882,10 +1883,12 @@ imap_cleanup_p2( imap_store_t *ctx, + imap_cleanup_p2( imap_store_t *ctx, + imap_cmd_t *cmd ATTR_UNUSED, int response ) + { +- if (response == RESP_NO) ++ if (response == RESP_NO) { + imap_cancel_store( &ctx->gen ); +- else if (response == RESP_OK) ++ } else if (response == RESP_OK) { + ctx->expectEOF = 1; ++ socket_expect_eof( &ctx->conn ); ++ } + } + + /******************* imap_open_store *******************/ diff --git a/mail/isync/files/patch-src_socket.c b/mail/isync/files/patch-src_socket.c new file mode 100644 index 000000000000..61b4a1872c87 --- /dev/null +++ b/mail/isync/files/patch-src_socket.c @@ -0,0 +1,18 @@ +--- src/socket.c.orig 2021-12-03 10:56:16 UTC ++++ src/socket.c +@@ -810,6 +810,15 @@ socket_expect_activity( conn_t *conn, int expect ) + conf_wakeup( &conn->fd_timeout, expect ? conn->conf->timeout : -1 ); + } + ++void ++socket_expect_eof( conn_t *sock ) ++{ ++#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF // implies HAVE_LIBSSL ++ if (sock->ssl) ++ SSL_set_options( sock->ssl, SSL_OP_IGNORE_UNEXPECTED_EOF ); ++#endif ++} ++ + int + socket_read( conn_t *conn, char *buf, uint len ) + { diff --git a/mail/isync/files/patch-src_socket.h b/mail/isync/files/patch-src_socket.h new file mode 100644 index 000000000000..986b52657e8e --- /dev/null +++ b/mail/isync/files/patch-src_socket.h @@ -0,0 +1,10 @@ +--- src/socket.h.orig 2021-12-03 10:56:16 UTC ++++ src/socket.h +@@ -142,6 +142,7 @@ void socket_expect_activity( conn_t *sock, int expect + void socket_start_deflate( conn_t *conn ); + void socket_close( conn_t *sock ); + void socket_expect_activity( conn_t *sock, int expect ); ++void socket_expect_eof( conn_t *sock ); + int socket_read( conn_t *sock, char *buf, uint len ); /* never waits */ + char *socket_read_line( conn_t *sock ); /* don't free return value; never waits */ + typedef enum { KeepOwn = 0, GiveOwn } ownership_t;