*BSDでfprintを使って指紋認証デバイスを使う方法

最近(2009年頃)の ThinkPad などでは、指紋認証デバイスがくっついていて、 Windows へのログイン時の認証が楽にできるようになっています。 *BSD でも、fprint を使用することで、指紋認証デバイスを利用できるようになります。 FreeBSD と NetBSD での fprint の設定方法を解説します。

注意: fprint がサポートしていないデバイスのリストに該当するデバイスの場合には使えないことがあります。指紋認証用 USB デバイスのベンダー ID、プロダクト ID を確認して下さい。

設定手順

fprint のインストール
↓
指紋登録
↓
PAM の設定

fprint のインストール

FreeBSD

パッケージのインストール

security/pam_fprint パッケージをインストールします。
# cd /usr/ports/security/pam_fprint
# make install

(中略)

=========================================================================
In order to enroll new finger prints, you must have r/w access to the
usb device node(s) of your finger print reader (i.e., /dev/{ugen, usb*})
(tested with UPEK finger print reader as found in Lenovo T61).

It is recommended to use devfs.rules(5) and a dedicated group to manage
access to your finger print reader.

You can use `usbdevs -v' to see if your sensor is accessible.

Example configuration:
- /etc/rc.conf:
devfs_system_ruleset="localrules"

- /etc/devfs.rules:
[localrules=10]
add path 'ugen0*' mode 0660 group operator
add path 'usb0*' mode 0660 group operator

# /etc/rc.d/devfs restart

Read `pam_fprint_enroll --help' to learn about enrolling fingers.

The security/fprint_demo port contains the graphical `fprint_demo'
application that allows you to manage your finger prints in a comfortable
way.

After enrolling fingerprints for your user(s), you can enable finger
print authentication by adding the following line to the corresponding
PAM configuration file(s) (see the PAM documentation and the pam_fprint
web site for more information).

auth            sufficient      /usr/local/lib/pam_fprint.so

/etc/pam.d/system is used for system-wide defaults,
/etc/pam.d/{gdm, kde} are used by the GDM/KDM login managers.
=========================================================================
# make clean
指紋登録をやりやすくするために、GUIの管理ツールもインストールします。
# cd /usr/ports/security/fprint_demo
# make install
# make clean

指紋登録の準備

デフォルトでは、一般ユーザーは ugen* デバイスの読み書きをすることができません。 そのため、devfs を使って一般ユーザーに ugen* デバイスの読み書き権限を与えないと、指紋の登録作業ができません。

まず、/etc/devfs.conf に以下の設定を追加します。

# 一般ユーザーが operator グループに属している場合の設定
[localrules=10]
add path 'ugen*' mode 0660 group operator
add path 'usb*' mode 0660 group operator
次に、 /etc/rc.conf に以下の設定を加えます。
devfs_system_ruleset="localrules"
devfs の設定を読み込み直して、指紋登録ができるようにします。
# /etc/rc.d/devfs restart

NetBSD

パッケージのインストール

security/pam-fprint パッケージをインストールします。
# cd /usr/pkgsrc/security/pam-fprint
# make install

(中略)

===========================================================================
$NetBSD: MESSAGE,v 1.1.1.1 2009/02/26 21:52:00 plunky Exp $

Read `pam_fprint_enroll --help' to learn about enrolling fingers. The
fingerprint data is stored in the users home directory under the .fprint
directory, and the program must have read/write access to the USB devices.

After enrolling fingerprints for your user(s), you can enable finger
print authentication by adding the following line to the corresponding
PAM configuration file(s) in /etc/pam.d

auth            sufficient      /usr/pkg/lib/security/pam_fprint.so

Note that using a fingerprint to authenticate is not particularly
secure, see the pam_fprint web site for more information.
===========================================================================
# make clean-depends clean
指紋登録をやりやすくするために、GUIの管理ツールもインストールします。
# cd /usr/pkgsrc/security/fprint-demo
# make install
# make clean-depends clean

指紋登録の準備

一般ユーザーが指紋登録を行う前に、/dev/usb? と /dev/ugen* をユーザーが 読み書きできるようにする必要があります。
(一般ユーザーが wheel グループに属している場合)
% sudo chmod g+rw /dev/usb? /dev/ugen*
指紋認証デバイスは以下のように認識されているはずです。
% dmesg | grep ugen
ugen0 at uhub0 port 2
ugen0: STMicroelectronics Biometric Coprocessor, rev 1.00/0.01, addr 3
もし、 指紋認証デバイスが /dev/ugen1 として認識される場合には、下記のように ugen1 のデバイスファイルを作成しておかないと、指紋認証ができなくなります。
% su
# cd /dev
# ./MAKEDEV ugen1

指紋登録

fprint のインストールが完了したら、指紋登録作業を行います。

CLIでの指紋登録

security/pam-fprint に付属する pam_fprint_enroll コマンドを使用して 指紋登録を行います。
(しかし、私の環境ではうまく登録できません...)
% pam_fprint_enroll --help
Usage: pam_fprint_enroll options
	-h	--help			Display this usage information.
	-f	--enroll-finger index	Enroll finger with index.

	Valid indexes are:
	1 - Left Thumb
	2 - Left Index Finger
	3 - Left Middle Finger
	4 - Left Ring Finger
	5 - Left Little Finger
	6 - Right Thumb
	7 - Right Index Finger
	8 - Right Middle Finger
	9 - Right Ring Finger
	10 - Right Little Finger
% pam_fprint_enroll -f 7
This program will enroll your finger, unconditionally overwriting
any selected print that was enrolled previously. If you want to
continue, press enter, otherwise hit Ctrl+C
(Enter を入力)

Found device claimed by UPEK TouchStrip driver
Opened device. It's now time to enroll your finger.

You will need to successfully scan your Right Index Finger 3 times
to complete the process.

Scan your finger now.
(指を読み取らせるけど、うまくいかない)

GUIでの指紋登録

GUIで登録を行う場合には、fprint_demo コマンドを使います。 一般ユーザーでこのプログラムを実行する時に、/dev/ugen* を 読み取り可能にしておかないと、指紋認証デバイスが認識されません。
% fprint_demo

fprint_demo の画面

読み取らせたい指の"Enroll"ボタンをクリックし、3度指紋を読み取らせると 指紋が登録されます。

fprint_demo の指紋登録ダイアログ

このとき、最後に読み取らせた指がログイン時にチェック対象となります。
login: yamajun
Scan right index finger on UPEK TouchStrip

PAMの設定

ここからの設定作業では設定に失敗した時のために、他のホストから SSH でログインできるようにしておくと安全に作業できます。

FreeBSD

security/pam_fprint をインストールした時の指示に従って、以下の列を /etc/pam.d/login の auth が並んでいる部分の先頭に追加します。
auth            sufficient      /usr/local/lib/pam_fprint.so

NetBSD

security/pam-fprint をインストールした時の指示に従って /etc/pam.d/login の auth が並んでいる部分の先頭に pam_fprint.so の設定を追加します。
# auth
# ↓ここに挿入
auth            sufficient      /usr/pkg/lib/security/pam_fprint.so
auth            sufficient      pam_self.so             no_warn
auth            required        pam_nologin.so          no_warn
auth            include         system