In test mode, dynamically load libraries in well known locations that can
allow to override the libfprint behavior.
It would still be possible to potentially inject code by replicating the
distro build directory and adding a library there, but if one is able to
access there, they would already be able to access any path.
Plus the env variable check is still there, so again they would need to
be able to change the fprintd environment
Rather than just do it in production if set, make it more difficult to
potentially inject the test mode.
So rely on a weak definition of fpi_device_emulation_mode_enabled() that
can be only set externally
Drivers may do some adjustments in test mode, initially we wanted to
reduce this to the minimum but the usage of `FP_DEVICE_EMULATION`
exploded, so move this instead into a properly defined variable that:
- Uses GLib compiler optimizations
- Is read just once per process
- Cannot be misused
As per commit bad930503c the test data is way bigger than it used to
be, so the test duration is longer.
Thus increase the timeout not to have failures
DT_RUNPATH is intentionally searched after $LD_LIBRARY_PATH.
-Wl,--disable-new-dtags switches to the old DT_RPATH tag, which is searched
before $LD_LIBRARY_PATH. So the embedded paths in the build binary will now
win over whatever is in the environment.
Not breaking builds.
Use bounded uid strings for template-info handling.
- stop printing fixed-size device buffers with raw %s
- use g_strndup(..., TEMPLATE_UID_SIZE) before logging tpl_info.uid
- compare delete target uid against the bounded copy
- log handshake response as bytes instead of %s
This avoids over-read/invalid-UTF8 issues when unknown/corrupted entries
contain non-NUL or 0xff-filled uid data.
The Elan 04f3:0c58 sensor returns 0xaf during capture which indicates
finger removed or sensor busy. Also 0x00 can occur meaning not ready.
These responses should trigger a retry instead of failing.
To avoid changing behavior for other Elan devices, limit the new retry
logic to the 0x0c58 device type and add a small 10ms delay between
retries.
Additionally, increase calibration attempts from 10 to 30 for 0x0c58
as this sensor needs more time to complete calibration.
Source: https://gitlab.freedesktop.org/libfprint/libfprint/-/work_items/763
Signed-off-by: lichenggang <lichenggang@uniontech.com>
Co-Authored-By: Marco Trevisan (Treviño) <mail@3v1n0.net>