From bf3b00ac7da00b26b9a768609d8aa75c2fef2606 Mon Sep 17 00:00:00 2001 From: boffart <> Date: Thu, 25 Jul 2024 10:11:23 +0300 Subject: [PATCH] =?UTF-8?q?#727=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BB=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D1=81=D1=81?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20/=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B4=D0=BB=D1=8F=20ssh.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/System/Configs/SSHConf.php | 8 ++++++++ src/Core/System/Notifications.php | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Core/System/Configs/SSHConf.php b/src/Core/System/Configs/SSHConf.php index 49bf68e1f..ee22044ef 100644 --- a/src/Core/System/Configs/SSHConf.php +++ b/src/Core/System/Configs/SSHConf.php @@ -145,6 +145,14 @@ private function getCreateSshUser(): string shell_exec("$bbPath addgroup -S '$sshLogin' $sshLogin"); // Adding a user to the group 'root' shell_exec("$bbPath addgroup -S '$sshLogin' root"); + + $cat = Util::which('cat'); + $cut = Util::which('cut'); + $sed = Util::which('sed'); + $chown = Util::which('chown'); + $currentGroupId = trim(shell_exec("$cat /etc/passwd | grep '^$sshLogin:' | $cut -f 3 -d ':'")); + shell_exec("$sed -i 's/$sshLogin:x:$currentGroupId:/$sshLogin:x:0:/g' /etc/passwd"); + shell_exec("$chown -R $sshLogin:$sshLogin $homeDir"); } return $sshLogin; } diff --git a/src/Core/System/Notifications.php b/src/Core/System/Notifications.php index 4f819fd95..6a13112cc 100644 --- a/src/Core/System/Notifications.php +++ b/src/Core/System/Notifications.php @@ -86,6 +86,9 @@ public static function sendAdminNotification(string $subject, array $messages, b { // Prevent sending the same message twice. $di = Di::getDefault(); + if(!$di){ + return; + } $managedCache = $di->getShared(ManagedCacheProvider::SERVICE_NAME); $cacheKey = 'sendAdminNotification:' . md5($subject . implode('', $messages)); $cacheTime = 3600 * 24; // 1 day @@ -96,7 +99,7 @@ public static function sendAdminNotification(string $subject, array $messages, b } // Check if the notification system is available (e.g., PHP Mailer is configured and working). - if (!Notifications::checkConnection(Notifications::TYPE_PHP_MAILER)) { + if (!self::checkConnection(self::TYPE_PHP_MAILER)) { return; } @@ -106,7 +109,8 @@ public static function sendAdminNotification(string $subject, array $messages, b foreach ($messages as $message) { $text .= '
' . Util::translate($message, false); } - $text = $text . '

' . SystemMessages::getInfoMessage("The MikoPBX connection information"); + $text .= '

' . SystemMessages::getInfoMessage("The MikoPBX connection information"); + $text = str_replace(PHP_EOL, '
', $text); // Get the admin email address from PbxSettings. $adminMail = PbxSettings::getValueByKey(PbxSettingsConstants::SYSTEM_NOTIFICATIONS_EMAIL);