[fix] secure Linux credential cache permissions

This commit is contained in:
dijunkun
2026-10-21 02:08:31 +08:00
parent 1aa23126d2
commit cf98775754
3 changed files with 185 additions and 4 deletions
+13 -1
View File
@@ -9,6 +9,7 @@
#include <mutex>
#include <shared_mutex>
#include <string>
#include <system_error>
#include <thread>
#include <vector>
@@ -96,7 +97,18 @@ int GuiRuntime::CreateConnectionPeer() {
signal_server_port = config_center_->GetSignalServerPort();
std::string current_self_hosted_ip = config_center_->GetSignalServerHost();
const bool use_cached_id = settings_.LoadCachedSelfHostedIdentity();
bool use_cached_id = false;
#if defined(__linux__) && !defined(__OHOS__)
try {
use_cached_id = settings_.LoadCachedSelfHostedIdentity();
} catch (const std::system_error&) {
// Keep the cached identity and avoid requesting a replacement identity
// when its file is temporarily inaccessible. SettingsManager logs why.
return -1;
}
#else
use_cached_id = settings_.LoadCachedSelfHostedIdentity();
#endif
if (!use_cached_id) {
LOG_INFO(
"secure_cache_v2.enc not found, will use empty id to get new id from "