Skip to content

fix(wizard): 出厂默认账号(pi/无密码或 raspberry)才进 OOBE,改名或改密码视为已配置 - #151

Merged
eggfly merged 3 commits into
masterfrom
fix/factory-default-password-oobe
Aug 18, 2026
Merged

fix(wizard): 出厂默认账号(pi/无密码或 raspberry)才进 OOBE,改名或改密码视为已配置#151
eggfly merged 3 commits into
masterfrom
fix/factory-default-password-oobe

Conversation

@eggfly

@eggfly eggfly commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

问题

8-17 的 #147 用"有没有密码"判断设备是否被 Imager 配置过,但 pi-gen 在每个镜像里烙死了 FIRST_USER_PASS=raspberry,导致裸刷出厂镜像也被判成"已配置",OOBE 永远不出现(只剩键盘引导),WiFi/时区无人配置。

判定规则(出厂标记存在时)

用户名 密码 进引导?
pi
pi raspberry(内置默认)
pi 用户自设 不进
已改名 任何情况 不进

设置里的"重新运行引导"(re-arm 标记)不受影响,永远进。

实现

  • 按 crypt(5) 手册的标准认证方式:把 shadow 里的哈希整串当 setting 传给 crypt_r("raspberry", hash),输出逐字节相同即匹配。同一 trixie 生成与校验,算法必然支持;libxcrypt 失败时返回 * failure token,手册保证永不等于 setting,故任何错误都安全地判成"已配置"。
  • first_boot_policy 拆出 factory_username / factory_credentials 两个纯信号,policy 保持可单测。
  • LaunchWizard 链接 libcrypt.so.1(镜像自带,无新增依赖)。

验证

  • Docker(build-env):launch_wizard_core_tests 全绿,覆盖上表所有分支
  • Docker(cardputer-build-nocam):ARM64 交叉编译链接通过,readelf -d 确认 NEEDED libcrypt.so.1
  • trixie arm64 容器实测 crypt_r:yescrypt 哈希正确密码 MATCH、错误密码 NO-MATCH、锁定账户 NO-MATCH

效果

已流出的 8-17 镜像只需升级 launcher deb 即可修复,无需重新出镜像;产测依赖的 pi/raspberry SSH 登录保持可用。

Made with Cursor

eggfly and others added 3 commits August 18, 2026 15:14
pi-gen bakes FIRST_USER_PASS=raspberry into every image, so the
password-presence check added for bug #227 also fired on factory-fresh
devices and skipped the OOBE entirely, leaving Wi-Fi and timezone
unconfigured.

Verify the stored hash against the baked pi/raspberry default via
crypt_r(3) (the stored hash doubles as the setting string, per crypt(5)),
and treat a match as an unconfigured account. Imager-provisioned devices
store a user-chosen password (or a renamed user), never match, and keep
skipping the wizard. crypt failures return a "*" token that can never
compare equal, so errors safely count as configured.

Links LaunchWizard against libcrypt (libcrypt.so.1, already in the
image) and covers the new policy branch in the unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
A renamed UID 1000 user can only come from Imager/userconf provisioning,
so skip the OOBE even when no password was set (e.g. SSH-keys-only
customisation). The factory marker now triggers the wizard only in exact
factory state: default username with no password or the baked default.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@eggfly
eggfly merged commit 98e9229 into master Aug 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant