From 55b91a2b54c665efb3388793427779a1159a15ee Mon Sep 17 00:00:00 2001 From: boffart <> Date: Mon, 28 Oct 2024 12:10:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D1=83=D1=8E?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B1=D0=BB=D0=B5=D0=BC=D1=83=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B8=20=D0=B2=20trim=20?= =?UTF-8?q?=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/System/CloudProvisioning/CloudProvider.php | 2 +- src/Core/System/Configs/SSHConf.php | 2 +- src/Core/System/DockerEntrypoint.php | 4 ++-- src/Core/System/System.php | 4 ++-- src/Core/System/SystemConfiguration.php | 2 +- src/Core/System/SystemMessages.php | 2 +- src/PBXCoreREST/Lib/System/UpgradeFromImageAction.php | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Core/System/CloudProvisioning/CloudProvider.php b/src/Core/System/CloudProvisioning/CloudProvider.php index 561e018dd..67f166493 100644 --- a/src/Core/System/CloudProvisioning/CloudProvider.php +++ b/src/Core/System/CloudProvisioning/CloudProvider.php @@ -127,7 +127,7 @@ protected function updateHostName(string $hostname): void */ protected function updateSSHCredentials(string $sshLogin, string $hashSalt): void { - $data = md5(shell_exec(Util::which('ifconfig')) . $hashSalt . time()); + $data = md5(shell_exec(Util::which('ifconfig'))??'' . $hashSalt . time()); $this->updatePbxSettings(PbxSettings::SSH_LOGIN, $sshLogin); $this->updatePbxSettings(PbxSettings::SSH_PASSWORD, $data); $this->updatePbxSettings(PbxSettings::SSH_DISABLE_SSH_PASSWORD, '1'); diff --git a/src/Core/System/Configs/SSHConf.php b/src/Core/System/Configs/SSHConf.php index 77cf3eea6..037d5ffb2 100644 --- a/src/Core/System/Configs/SSHConf.php +++ b/src/Core/System/Configs/SSHConf.php @@ -277,7 +277,7 @@ private function updateUserGroupId(string $sshLogin): void $cut = Util::which('cut'); $sed = Util::which('sed'); - $currentGroupId = trim(shell_exec("$cat /etc/passwd | grep '^$sshLogin:' | $cut -f 3 -d ':'")); + $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"); } } diff --git a/src/Core/System/DockerEntrypoint.php b/src/Core/System/DockerEntrypoint.php index 8b67e68c0..f16bbd4f2 100644 --- a/src/Core/System/DockerEntrypoint.php +++ b/src/Core/System/DockerEntrypoint.php @@ -123,7 +123,7 @@ private function changeWwwUserID(): void $cut = Util::which('cut'); $chown = Util::which('chown'); $chgrp = Util::which('chgrp'); - $currentUserId = trim(shell_exec("$grep '^$userID:' < /etc/shadow | $cut -d ':' -f 3")); + $currentUserId = trim(shell_exec("$grep '^$userID:' < /etc/shadow | $cut -d ':' -f 3")??''); if ($currentUserId !== '' && !empty($newUserId) && $currentUserId !== $newUserId) { SystemMessages::sysLogMsg(__METHOD__, " - Old $userID user id: $currentUserId; New $userID user id: $newUserId", LOG_DEBUG); $commands[] = "$sed -i 's/$userID:x:$currentUserId:/$userID:x:$newUserId:/g' /etc/shadow*"; @@ -137,7 +137,7 @@ private function changeWwwUserID(): void } } - $currentGroupId = trim(shell_exec("$grep '^$userID:' < /etc/group | $cut -d ':' -f 3")); + $currentGroupId = trim(shell_exec("$grep '^$userID:' < /etc/group | $cut -d ':' -f 3")??''); if ($currentGroupId !== '' && !empty($newGroupId) && $currentGroupId !== $newGroupId) { SystemMessages::sysLogMsg(__METHOD__, " - Old $userID group id: $currentGroupId; New $userID group id: $newGroupId", LOG_DEBUG); $commands[] = "$sed -i 's/$userID:x:$currentGroupId:/$userID:x:$newGroupId:/g' /etc/group"; diff --git a/src/Core/System/System.php b/src/Core/System/System.php index a0dee309f..04d46513f 100644 --- a/src/Core/System/System.php +++ b/src/Core/System/System.php @@ -219,7 +219,7 @@ public static function sslRehash(): void $cutPath = Util::which('cut'); // Get OpenSSL directory and cert file - $openSslDir = trim(shell_exec("$openSslPath version -d | $cutPath -d '\"' -f 2")); + $openSslDir = trim(shell_exec("$openSslPath version -d | $cutPath -d '\"' -f 2")??''); $certFile = "$openSslDir/certs/ca-certificates.crt"; $tmpFile = tempnam('/tmp', 'cert-'); $rawData = file_get_contents($certFile); @@ -229,7 +229,7 @@ public static function sslRehash(): void continue; } file_put_contents($tmpFile, $cert); - $hash = trim(shell_exec("$openSslPath x509 -subject_hash -noout -in '$tmpFile'")); + $hash = trim(shell_exec("$openSslPath x509 -subject_hash -noout -in '$tmpFile'")??''); rename($tmpFile, "$openSslDir/certs/$hash.0"); } if (file_exists($tmpFile)) { diff --git a/src/Core/System/SystemConfiguration.php b/src/Core/System/SystemConfiguration.php index 5f6835df5..77f9a1277 100644 --- a/src/Core/System/SystemConfiguration.php +++ b/src/Core/System/SystemConfiguration.php @@ -67,7 +67,7 @@ public function tryRestoreConf():void $sort = Util::which('sort'); $find = Util::which('find'); $cut = Util::which('cut'); - $lastBackUp = trim(shell_exec("$find $tmpMountDir/dev/*$backupDir -type f -printf '%T@ %p\\n' | $sort -n | $tail -1 | $cut -f2- -d' '")); + $lastBackUp = trim(shell_exec("$find $tmpMountDir/dev/*$backupDir -type f -printf '%T@ %p\\n' | $sort -n | $tail -1 | $cut -f2- -d' '")??''); if (!empty($lastBackUp)) { $rm = Util::which('rm'); $gzip = Util::which('gzip'); diff --git a/src/Core/System/SystemMessages.php b/src/Core/System/SystemMessages.php index 5c92ba6b4..fff911cc3 100644 --- a/src/Core/System/SystemMessages.php +++ b/src/Core/System/SystemMessages.php @@ -141,7 +141,7 @@ public static function echoResult(string $message, string $result = self::RESULT */ public static function getCountCols(): string { - $len = 1 * trim(shell_exec('tput cols')); + $len = 1 * trim(shell_exec('tput cols')??''); // If the count of columns is zero, set it to a default value of 80 if ($len === 0) { diff --git a/src/PBXCoreREST/Lib/System/UpgradeFromImageAction.php b/src/PBXCoreREST/Lib/System/UpgradeFromImageAction.php index 2883664eb..20bded126 100644 --- a/src/PBXCoreREST/Lib/System/UpgradeFromImageAction.php +++ b/src/PBXCoreREST/Lib/System/UpgradeFromImageAction.php @@ -153,7 +153,7 @@ private static function getStorageUID(): string $awk = Util::which('awk'); $storageDeviceFile = self::STORAGE_DEVICE; $cmd = "$grep $($cat $storageDeviceFile) < /etc/fstab | $awk -F'[= ]' '{ print \$2}'"; - return trim(shell_exec($cmd)); + return trim(shell_exec($cmd)??''); } /** @@ -166,7 +166,7 @@ private static function getCfUID(): string $grep = Util::which('grep'); $awk = Util::which('awk'); $cmd = "$grep '/cf' < /etc/fstab | $awk -F'[= ]' '{ print \$2}'"; - return trim(shell_exec($cmd)); + return trim(shell_exec($cmd)??''); } /**