Skip to main content

read_explicit_credential_file

Function read_explicit_credential_file 

Source
pub fn read_explicit_credential_file(
    field_label: &'static str,
    path: &str,
) -> Result<String>
Expand description

codex 0547 F1+F2 (P2) — explicit user-supplied credential / secret 文件 读取 helper. 用户显式(CLI flag 或 TOML/XML config) 传入路径但读取失败 时 fail-closed 返 Err. 让 daemon abort 而非 silent fallback.

范围: 只覆盖 user-supplied (explicit) credential 路径; auto-detect 路径 由 caller 自己选 fallback 行为. 当前调用点:

  • rsa_private_key: --rsa-private-key / [rsa_private_key] (F1)
  • login_pwd_file: --login-pwd-file / [login_pwd_file] (F2; 仍走老 resolve_login_password 7 层链, 但 explicit path 失败 = fatal)

fail-closed 触发:

  • 文件不存在 / 权限不够 / IO error → Err
  • 文件存在但 trim 后为空 → Err (用户传了路径但内容空 = 不一致, 常见 原因: systemd LoadCredential 失败 / Docker secret mount 漏挂 / file truncated)

返回: Ok(content_after_trim_trailing_whitespace), 失败 Err.

调用方对 Err 的标准处理是直接 ? propagate 让 daemon abort.