diff --git a/Dockerfile b/Dockerfile index b6c4ce551183b77dc68231c5e3971519ddd1ec25..3b57fd7ad16c17386a0f838e16772264995f68d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -124,6 +124,7 @@ RUN patch -u ${BASE_DIR}/lib/private/Authentication/Token/PublicKeyTokenProvider RUN patch -u ${BASE_DIR}/lib/private/legacy/OC_Helper.php -i ${TMP_PATCH_DIR}/014-add-mail-usage.patch RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/015-email-mail-template.patch RUN patch -u ${BASE_DIR}/core/templates/layout.guest.php -i ${TMP_PATCH_DIR}/016-login-screen.patch +RUN patch -u ${BASE_DIR}/lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php -i ${TMP_PATCH_DIR}/017-storage-wrapper.patch RUN rm -rf ${TMP_PATCH_DIR} # autocomplete leak tweak apps frontend with sed, disable group suggestion diff --git a/patches/006-recovery-email-changes.patch b/patches/006-recovery-email-changes.patch index f576607a0441c4baf22a6374e4517c66f1ff166f..38c6657f3c2d6f9b39e6f7db490a0b5a5a88aee6 100644 --- a/patches/006-recovery-email-changes.patch +++ b/patches/006-recovery-email-changes.patch @@ -1,18 +1,9 @@ -From: ArnauVP -Date: Fri, 27 Mar 2022 00:00:00 +0000 -Subject: [PATCH] Makes password reset links use recovery email set through "email-recovery" app - -This patch adds the necessary changes to core NC controller for "email-recovery" app to work correctly. -Instead of the user's email address, the user's recovery email address set through the "email-recovery" app is used for the password reset email. -It also handles different input types like username, username@domain, username@aliasdomain. - ---- LostController.php.orig 2022-05-27 02:05:38.000000000 +0200 -+++ LostController.php 2022-05-27 02:08:24.000000000 +0200 -@@ -174,6 +174,21 @@ +--- ./core/Controller/LostController.php 2022-05-27 14:46:14.400838300 +0530 ++++ .//core/Controller/LostController-new.php 2022-05-27 14:46:16.710838300 +0530 +@@ -174,6 +174,20 @@ */ protected function checkPasswordResetToken(string $token, string $userId): void { try { -+ + $domain = $this->config->getSystemValue('mail_domain', ''); + $domainSuffix = !empty($domain) ? '@' . $domain : ''; + $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); @@ -30,27 +21,27 @@ It also handles different input types like username, username@domain, username@a $user = $this->userManager->get($userId); $this->verificationToken->check($token, $user, 'lostpassword', $user ? $user->getEMailAddress() : '', true); } catch (InvalidTokenException $e) { -@@ -287,8 +302,22 @@ +@@ -287,8 +301,22 @@ * @throws \OCP\PreConditionNotMetException */ protected function sendEmail($input) { -+ $domain = $this->config->getSystemValue('mail_domain', ''); -+ $domainSuffix = !empty($domain) ? '@' . $domain : ''; -+ $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); -+ $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; -+ if (stristr($input, $domainSuffix) !== FALSE) { -+ $input = str_replace($domainSuffix, '', $input); -+ } -+ if(stristr($input, $altDomainSuffix) !== FALSE) { -+ $input = str_replace($altDomainSuffix, '', $input); -+ } -+ if(!$this->userManager->userExists($input) ) { -+ $input = $input . $domainSuffix; -+ } ++ $domain = $this->config->getSystemValue('mail_domain', ''); ++ $domainSuffix = !empty($domain) ? '@' . $domain : ''; ++ $altDomain = $this->config->getSystemValue('alt_mail_domain', ''); ++ $altDomainSuffix = !empty($altDomain) ? '@' . $altDomain : ''; ++ if (stristr($input, $domainSuffix) !== FALSE) { ++ $input = str_replace($domainSuffix, '', $input); ++ } ++ if(stristr($input, $altDomainSuffix) !== FALSE) { ++ $input = str_replace($altDomainSuffix, '', $input); ++ } ++ if(!$this->userManager->userExists($input) ) { ++ $input = $input . $domainSuffix; ++ } + $user = $this->findUserByIdOrMail($input); - $email = $user->getEMailAddress(); + $email = $this->config->getUserValue($user->getUID(), 'email-recovery', 'recovery-email'); - + if (empty($email)) { throw new ResetPasswordException('Could not send reset e-mail since there is no email for username ' . $input); diff --git a/patches/017-storage-wrapper.patch b/patches/017-storage-wrapper.patch new file mode 100644 index 0000000000000000000000000000000000000000..0d2c900f00bc80266b88d24bed7cf7ebf90f7abe --- /dev/null +++ b/patches/017-storage-wrapper.patch @@ -0,0 +1,22 @@ +--- ./lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener.php 2022-05-27 12:40:13.680838300 +0530 ++++ ./lib/private/Authentication/Listeners/UserDeletedFilesCleanupListener-new.php 2022-05-27 12:41:07.530838300 +0530 +@@ -26,6 +26,7 @@ + namespace OC\Authentication\Listeners; + + use OC\Files\Cache\Cache; ++use OC\Files\Storage\Wrapper\Wrapper; + use OCP\EventDispatcher\Event; + use OCP\EventDispatcher\IEventListener; + use OCP\Files\Config\IMountProviderCollection; +@@ -56,6 +57,11 @@ + if (!$storage) { + throw new \Exception("User has no home storage"); + } ++ // remove all wrappers, so we do the delete directly on the home storage bypassing any wrapper ++ while ($storage->instanceOfStorage(Wrapper::class)) { ++ /** @var Wrapper $storage */ ++ $storage = $storage->getWrapperStorage(); ++ } + $this->homeStorageCache[$event->getUser()->getUID()] = $storage; + } + if ($event instanceof UserDeletedEvent) {