Linux下使用咸鱼铝合金指纹识别器
安装驱动
上游 freedesktop 和 ubuntu 的 libfprint
都不支持我手上这个27C6:5584
指纹识别器,不过万幸 Github 上有一个名为 “Goodix Fingerprint Linux Development ” 的组织,致力于为 Linux 提供汇顶指纹芯片方案的驱动支持
汇顶 Linux 支持情况
下表是支持情况,来自该组织的 Discord
PID | 支持状态 |
---|---|
5042 | 🅾️ |
5110 | ✅ |
5117 | 🔄 |
5120 | ✅ |
5130 | ✅ |
5201 | 🅾️ |
521d | ✅ |
5301 | 🅾️ |
530c | ❎ |
532d | 🔄 |
5335 | 🔄 |
533c | ❎ |
5381 | 🅾️ |
5385 | 🔄 |
538c | ❎ |
538d | ✅ |
5395 | 🔄 |
550a | ❎ |
5503 | 🅾️ |
5584 | ✅ |
55a2 | 🔄 |
55a4 | ✅ |
55b4 | ✅ |
5740 | 🅾️ |
581a | 🅾️ |
3200 | 🆘 |
3288 | 🆘 |
5120 | 🔄 |
5187 | 🅾️ |
51a0 | 🔄 |
51b7 | 🅾️ |
🅾️:闭源驱动 / ✅:社区驱动(unstable)/ 🔄:目前可获取指纹图像,待进一步支持 libfprint / 🆘:不支持
在此,仅讨论PID为 55x4
的三个指纹识别器:55b4
、55a4
和我的5584
太长不看版:
Debian/ArchLinux 用户可以使用我重新打包的 libfprint
Debian 用户还需要安装libopencv-features2d406
软件包,Ubuntu 需要libopencv-features2d406t64
我将 Debian 包的版本号改为了1.99.9
,我对 ArchLinux 的包进行了 GPG 签名,请自行导入公钥
对于前两者,ArchLinux 用户可以直接安装 libfprint-goodixtls-55x4 包,无需更改代码,而对于 5584
则需要修改该仓库里的libfprint/drivers/goodixtls/goodix55x4.h
头文件,添加 5584
的 PID 和 VID:
static const FpIdEntry id_table[] = {
{.vid = 0x27c6, .pid = 0x55b4},
{.vid = 0x27c6, .pid = 0x55a4},
{.vid = 0x27c6, .pid = 0x5584},
{.vid = 0, .pid = 0, .driver_data = 0},
};
注意:目前并不支持同时在 Windows 和 Linux 下同时使用,因为 Windows 会更改指纹识别器的 PSK,详细请看 ArchWiki 的注释
刷写固件
三个型号的指纹识别器在使用前,都需要刷写固件:
# 切换root用户,因为后续刷写固件需要root权限
su
# 克隆仓库
git clone https://github.com/goodix-fp-linux-dev/goodix-fp-dump
# 创建venv,避免污染系统python库
cd goodix-fp-dump
python -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
55b4、55a4
对于 55b4
和 55a4
,请直接运行对应的 run_55XX.py
;
python3 run_55XX.py
5584
对于 5584
,自行创建一个 .py
文件并运行,其内容如下:
import driver_55x4
driver_55x4.main(0x5584)
当输出 mcu_switch_to_fdt_down(XXX, True)
的时候,此时按下指纹识别器,如一切正常则会输出
mcu_get_image()
image: 88 x 108, length: 9504
并在当前目录下生成 fingerprint.pgm
文件,该文件即刚才采集到的指纹,图片样式如下:
至此,指纹已基本可用。而 fprint
的使用方法及如何在系统内使用指纹,请查看 ArchWiki - fprint,里面有详细介绍
Bitwarden
Bitwarden 桌面版在合并了 #4586 Unix biometrics unlock via Polkit 之后,可以通过 polkit
使用系统身份验证,由 polkit
发起的身份验证,则可以通过配置 pam
实现指纹解锁
pam 规则
默认情况下,Archlinux 下的 polkit 并不会将启用自己的 pam 规则,需要自己手动启用:
sudo cp /usr/lib/pam.d/polkit-1 /etc/pam.d/
并修改:
# 在顶端添加如下内容
auth sufficient pam_fprintd.so
如果你想同时使用指纹或密码,请从 AUR 安装 pam-fprint-grosshack 包
对于一些不支持输入空密码的身份验证,如 Gnome 的 polkit 代理,也请安装该软件包并使用下面的规则
# auth sufficient pam_fprintd_grosshack.so
# auth sufficient pam_unix.so try_first_pass nullok
polkit 规则
目前,Bitwarden 并不会自动添加所需的 polkt 规则,需要手动将下面的内容添加到 /usr/share/polkit-1/actions/com.bitwarden.Bitwarden.policy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<action id="com.bitwarden.Bitwarden.unlock">
<description>Unlock Bitwarden</description>
<message>Authenticate to unlock Bitwarden</message>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self</allow_active>
</defaults>
</action>
</policyconfig>
Bitwarden 设置
仅讨论 KDE/Gnome
在使用 Bitwarden 提供的 使用系统身份验证解锁
功能前,请确保你的桌面环境已经为你启用了自己的 密码库
,否则 Bitwarden 的设置里不会有 使用系统身份验证解锁
选项
KDE 和 Gnome 下分别为 Kwallet & Gnome/keyring
KDE 的 Kwallet 有可能不会激活自己的 D-Bus 服务,需要手动干预
在启用 kwallet/gnome-keyring 之后,便可打开 Bitwarden,勾选 使用系统身份验证解锁
下次解锁密码库时,便可使用指纹解锁
“使用系统身份验证解锁” 不见了?
如果使用 KDE + kwallet ,且在终端启动 Bitwarden时,报错中提到了 Credential Storage Listener
:
› [Credential Storage Listener] setPassword failed Error: File backend error Portal communication failed Portal request failed: org.freedesktop.zbus.Error: Portal operation not allowed: Unable to open /proc/125191/root
falling back to get legacy Bitwarden XXXX_accessTokenKey
› SetAccessToken: storing encrypted access token in secure storage failed. Falling back to disk storage. Error: New Access token key unable to be retrieved from secure storage.
› [Credential Storage Listener] setPassword failed Error: File backend error Portal communication failed Portal request failed: org.freedesktop.zbus.Error: Portal operation not allowed: Unable to open /proc/125191/root
falling back to get legacy Bitwarden XXXX_refreshToken
› SetRefreshToken: storing refresh token in secure storage failed. Falling back to disk storage. Error: Refresh token failed to save to secure storage.
此问题是由 xdg-desktop-portal
和kwallet
引起的,貌似当前 KDE 的 xdg portal 支持有问题,请在启动 Bitwarden 时,自行添加环境变量,绕过 xdg,使 Bitwarden 直接访问 Kwallet:
GTK_USE_PORTAL=0
Copyright Notice: Unless otherwise stated, this article is an original work. Copyright belongs to VConet的杂物间. Licensed under CC BY-NC-SA 4.0. Please cite the source when reprinting!
Article URL: https://old.vconet.top/archives/goodix-fp-reader.html
TEST