git: 396010cb585a - main - mail/snappymail: Fix error while accessing admin page

From: Yasuhiro Kimura <yasu_at_FreeBSD.org>
Date: Fri, 08 Mar 2024 06:52:57 UTC
The branch main has been updated by yasu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=396010cb585aaaf9e3f87038f06760dece7e1fd7

commit 396010cb585aaaf9e3f87038f06760dece7e1fd7
Author:     Jesús Daniel Colmenares Oviedo <DtxdF@disroot.org>
AuthorDate: 2024-03-08 05:16:19 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2024-03-08 06:51:21 +0000

    mail/snappymail: Fix error while accessing admin page
    
    On a fresh installation, the admin page returns a 500 error, indicating
    a web server error. The logs reveal what the problem is, which is already
    fixed in upstream [1], but until a new version of snappymail is released,
    the user will see the following error:
    
    ```
    RainLoop\Config\Application::SetPassword(): Argument #1 ($oPassword) must be of type SnappyMail\SensitiveString, string given, called in /usr/local/www/snappymail/snapp
    ymail/v/2.35.2/app/libraries/RainLoop/Actions.php on line 672
    ```
    
    Reference:      https://github.com/the-djmaze/snappymail/issues/1472 [1]
    PR:             277571
    MFH:            2024Q1
---
 mail/snappymail/Makefile                                      |  2 +-
 ...tch-snappymail_v_2.35.2_app_libraries_RainLoop_Actions.php | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/mail/snappymail/Makefile b/mail/snappymail/Makefile
index 65ecf3ed20e7..c202afa3fb46 100644
--- a/mail/snappymail/Makefile
+++ b/mail/snappymail/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	snappymail
 DISTVERSION=	2.35.2
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	mail www
 MASTER_SITES=	https://github.com/the-djmaze/snappymail/releases/download/v${DISTVERSION}/
 PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}
diff --git a/mail/snappymail/files/patch-snappymail_v_2.35.2_app_libraries_RainLoop_Actions.php b/mail/snappymail/files/patch-snappymail_v_2.35.2_app_libraries_RainLoop_Actions.php
new file mode 100644
index 000000000000..861cd117553e
--- /dev/null
+++ b/mail/snappymail/files/patch-snappymail_v_2.35.2_app_libraries_RainLoop_Actions.php
@@ -0,0 +1,11 @@
+--- snappymail/v/2.35.2/app/libraries/RainLoop/Actions.php.orig	2024-03-08 05:14:45 UTC
++++ snappymail/v/2.35.2/app/libraries/RainLoop/Actions.php
+@@ -668,7 +668,7 @@ class Actions
+ 					$sPassword = \substr(\base64_encode(\random_bytes(16)), 0, 12);
+ 					Utils::saveFile($passfile, $sPassword . "\n");
+ //					\chmod($passfile, 0600);
+-					$oConfig->SetPassword($sPassword);
++					$oConfig->SetPassword(new \SnappyMail\SensitiveString($sPassword));
+ 					$oConfig->Save();
+ 				}
+ 			}