improved debugging + health endpoint
This commit is contained in:
16
db_init.php
16
db_init.php
@ -194,7 +194,21 @@ function qdb_open(bool $writable = false): array {
|
||||
if ($lockFp) { flock($lockFp, LOCK_UN); fclose($lockFp); }
|
||||
throw new Exception("Could not read stored DB");
|
||||
}
|
||||
$decrypted = aes256_cbc_decrypt_bytes($storedEnc, $masterKey);
|
||||
try {
|
||||
$decrypted = aes256_cbc_decrypt_bytes($storedEnc, $masterKey);
|
||||
} catch (Throwable $e) {
|
||||
error_log(sprintf(
|
||||
'qdb_open decrypt failed: path=%s realpath=%s enc_bytes=%d key_sha=%s sapi=%s env_readable=%s common=%s',
|
||||
$dbPath,
|
||||
realpath($dbPath) ?: 'none',
|
||||
strlen($storedEnc),
|
||||
hash('sha256', $masterKey),
|
||||
PHP_SAPI,
|
||||
is_readable(__DIR__ . '/.env') ? 'yes' : 'no',
|
||||
realpath(__DIR__ . '/common.php') ?: __DIR__ . '/common.php'
|
||||
));
|
||||
throw $e;
|
||||
}
|
||||
if (file_put_contents($tmpDb, $decrypted) === false) {
|
||||
if ($lockFp) { flock($lockFp, LOCK_UN); fclose($lockFp); }
|
||||
throw new Exception("Could not write temp DB");
|
||||
|
||||
Reference in New Issue
Block a user