fingerprint

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package fingerprint verifies the human's finger on the machine's reader through fprintd, for the console's approvals in desktop mode.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatch     = errors.New("fingerprint: no match")
	ErrTimeout     = errors.New("fingerprint: no finger within the deadline")
	ErrUnavailable = errors.New("fingerprint: reader or fprintd unavailable")
	ErrBusy        = errors.New("fingerprint: reader in use")
	// ErrWrongOwner: the fprintd name is held by a process of another uid
	// than expected. NewFprintd wraps it together with ErrUnavailable;
	// callers that treat "unavailable" as "no reader" must refuse on this
	// one first: a rogue service is not an absent reader.
	ErrWrongOwner  = errors.New("fingerprint: fprintd runs as an unexpected account")
	ErrNotEnrolled = errors.New("fingerprint: no finger enrolled for the console account")
)

Functions

This section is empty.

Types

type Fake

type Fake struct {
	// Results are returned by successive Verify calls; nil past the end.
	Results []error
	// EnrolledN and EnrolledErr answer Enrolled.
	EnrolledN   int
	EnrolledErr error
	// Calls counts Verify calls; Ready counts onReady calls.
	Calls, Ready int
	// Block makes Verify wait for ctx; the result is then ErrTimeout when
	// the deadline passed, ctx.Err() otherwise.
	Block bool
	// NeverReady returns the result without calling onReady (a reader that
	// was never claimed: busy, unavailable).
	NeverReady bool
}

Fake is a scripted Verifier for tests.

func (*Fake) Enrolled

func (f *Fake) Enrolled(context.Context) (int, error)

func (*Fake) Verify

func (f *Fake) Verify(ctx context.Context, onReady func()) error

type Fprintd

type Fprintd struct {
	// contains filtered or unexported fields
}

Fprintd verifies through the fprintd service on the system bus.

func NewFprintd

func NewFprintd(o Options) (*Fprintd, error)

NewFprintd connects, activates fprintd if needed and resolves the default device. ErrUnavailable wraps every failure: no bus, no fprintd, no reader, wrong owner.

func (*Fprintd) Close

func (f *Fprintd) Close() error

Close releases the bus connection.

func (*Fprintd) Enrolled

func (f *Fprintd) Enrolled(ctx context.Context) (int, error)

Enrolled is the number of prints enrolled for the console account.

func (*Fprintd) Verify

func (f *Fprintd) Verify(ctx context.Context, onReady func()) error

Verify claims the reader, starts a verification, calls onReady, and waits for the result. The reader is always released.

type Options

type Options struct {
	// Address overrides the system bus (tests). Empty: dbus.SystemBus.
	Address string
	// User is the account whose prints must match. Required.
	User string
	// OwnerUID is the uid the name owner must run as; -1 disables the check.
	OwnerUID int
}

Options configures NewFprintd. Zero values: the system bus, the name owner must run as uid 0. User is required: an empty User is an error.

type Verifier

type Verifier interface {
	// Verify blocks until a print enrolled for the console account matches,
	// ctx ends (ErrTimeout when its deadline passed, ctx.Err() otherwise),
	// or the reader fails (ErrNoMatch, ErrUnavailable, ErrBusy). onReady,
	// when not nil, runs once the reader is claimed: the caller prompts the
	// human then, never before, so that a finger is never offered to a
	// reader another process holds.
	Verify(ctx context.Context, onReady func()) error
	// Enrolled is the number of prints enrolled for the console account.
	Enrolled(ctx context.Context) (int, error)
}

Verifier is what the console asks for a fingerprint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL