fix(service): repair initial owner identity and extend readiness wait

This commit is contained in:
wonfen
2026-09-21 17:32:48 +08:00
parent b469bee352
commit 81ce247ecc
3 changed files with 10 additions and 10 deletions
+2
View File
@@ -5,6 +5,8 @@
- 回退 2.5.4 引入的 DNS 覆写保护,修复重启后开关自动关闭
- 优化文件错误日志,显示具体文件路径和失败原因
- 修复 DNS 覆写:空内容报错、初始值覆盖已有设置、已填写字段残留原配置、空字段在高级编辑器中缺失
- 修复首次以管理员身份启动后,系统服务因数据目录所有权不符而拒绝启动内核的问题
</details>
+3 -6
View File
@@ -392,13 +392,10 @@ mod windows_owner {
}
pub(super) fn repair_root_owner(root: &Path) -> Result<()> {
// Elevated Windows processes can create directories owned by Administrators.
std::fs::create_dir_all(root).context("failed to create the application data root before owner repair")?;
// The Service canonicalizes before checking, so resolve junctions to the same object.
let root = match std::fs::canonicalize(root) {
Ok(path) => path,
// Nothing to repair: this process creates the root and owns it by construction.
Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),
Err(error) => return Err(error).context("failed to canonicalize the application data root"),
};
let root = std::fs::canonicalize(root).context("failed to canonicalize the application data root")?;
let root = root.as_path();
let sid = current_sid()?;
+5 -4
View File
@@ -1963,12 +1963,13 @@ async fn recover_after_owner_loss_while_locked(reason: OwnerRecoveryReason) {
#[tracing::instrument(skip_all, level = "info", fields(attempts = tracing::field::Empty, interval_ms = tracing::field::Empty, outcome = tracing::field::Empty))]
async fn wait_for_service_ipc() -> Result<()> {
const CONTEXT: &str = "service IPC did not become available";
let config = ServiceManager::config();
const READY_ATTEMPTS: usize = 61;
const READY_INTERVAL: Duration = Duration::from_millis(500);
let span = tracing::Span::current();
span.record("attempts", config.max_retries);
span.record("interval_ms", config.retry_delay.as_millis() as u64);
span.record("attempts", READY_ATTEMPTS);
span.record("interval_ms", READY_INTERVAL.as_millis() as u64);
match RUN_STATE.await_ready(config.max_retries, config.retry_delay).await {
match RUN_STATE.await_ready(READY_ATTEMPTS, READY_INTERVAL).await {
Ok(_) => {
tracing::Span::current().record("outcome", "ready");
Ok(())