1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-09 23:37:41 +02:00

Throw exception for invalid key structure, update messages

This commit is contained in:
billz 2025-03-15 00:58:53 -07:00
parent 3e0f1f16c1
commit c3a210907a

View File

@ -361,13 +361,14 @@ class PluginInstaller
* @param array $keys Array containing key_url, keyring, repo, and sources * @param array $keys Array containing key_url, keyring, repo, and sources
* @throws Exception on key installation failure * @throws Exception on key installation failure
*/ */
public function installRepositoryKeys(array $keys) public function installRepositoryKeys(array $keys): void
{ {
error_log("executing installRepositoryKeys()"); if (!is_array($keys)) {
throw new \Exception("Invalid repository key structure: array expected");
}
foreach ($keys as $keyData) { foreach ($keys as $keyData) {
if (!isset($keyData['key_url'], $keyData['keyring'], $keyData['repo'], $keyData['sources'])) { if (!isset($keyData['key_url'], $keyData['keyring'], $keyData['repo'], $keyData['sources'])) {
throw new \Exception("Invalid repository key structure"); throw new \Exception("Invalid repository key structure: " . json_encode($keyData));
} }
$cmd = sprintf( $cmd = sprintf(
'sudo %s keys %s %s %s %s', 'sudo %s keys %s %s %s %s',
@ -379,7 +380,7 @@ class PluginInstaller
); );
$return = shell_exec($cmd); $return = shell_exec($cmd);
if (strpos(strtolower($return), 'ok') === false) { if (strpos(strtolower($return), 'ok') === false) {
throw new \Exception("Failed to add repository and key for {$keyData['repo']}"); throw new \Exception("Failed to add repository and key");
} }
} }
} }