#1591·fiber

`fnn --restore` 无法覆盖现有的只读 Fiber 私密密钥文件

作者: sunchengzhu创建于 2026年7月29日更新于 2026年8月4日
  • Fiber source: develop @ 5db52a2486220222e8905beb3f17ee3ef35a9307, fnn Fiber v0.9.0-rc7 (5db52a2 2026-07-28)
  • System and storage: macOS 26.3, Apple Silicon (arm64), RocksDB
  • Execution user: UID 501 (non-root). A root process that can bypass normal file permission checks does not fail because of 0o400; therefore, containers or CI environments that run FNN as root may not reproduce the issue.

Discovery and reproduction

This issue was found by the backup/restore black-box regression tests for PR #1197.

  1. Start FNN and let it create <fiber_base_dir>/sk; the private key file has permissions 0o400.
  2. Call the Admin RPC backup method to create a complete backup containing db/, sk, and key.
  3. Stop the node, leave the existing key files unchanged, and restore the backup into the same node data directory:
bash
FIBER_SECRET_KEY_PASSWORD='password0' fnn -c <config.yml> -d <base_dir> \
  --restore <fiber_base_dir>/backups/<timestamp>

Observed:

INFO fnn: Starting manual restore process from: "<backup_path>"
Error: Exit because Failed to restore database: Database error:
Failed to restore fiber key: Permission denied (os error 13)

When the destination already contains an sk file with 0o400 permissions, all three in-place recovery scenarios fail at this step: restoring a backup of the current channel state, making a payment and then restoring an older backup, and relying on peer reconnection after restore to reestablish channel state. As a control, after deleting the destination key and sk, the same backup successfully restores both key files and preserves the Fiber node public key. This confirms that the backup is valid and that the failure is caused by overwriting the existing read-only sk. Expected: fnn --restore completes

内容来源: nervosnetwork/fiber