Commit graph

669 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
87ae9dbad3 utils/verify: Terminate with EXIT_FAILURE when enrollment failed 2021-03-03 20:17:19 +01:00
Marco Trevisan (Treviño)
97496d1b82 utils/enroll: Terminate with EXIT_FAILURE when enrollment failed 2021-03-03 20:17:14 +01:00
Marco Trevisan (Treviño)
0580690610 utils/enroll: Fix typo on error 2021-03-03 20:17:05 +01:00
Marco Trevisan (Treviño)
7aa7818633 utils/delete: Use proper error string on deletion 2021-03-03 20:16:49 +01:00
Marco Trevisan (Treviño)
2b46553938 device: Do not set the device in verification state if we've errored
During VerifyStart we may return early if there are no enrolled prints.
In such case we don't require the verification to be stopped if we're
using identification, but in the verification case we may leave the
device into the verification state.

So ensure we only set the device current state only when we're about to
start it.

Add tests ensuring those cases
2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
0baad39950 device: Do not list invalid prints as enrolled
The user may have some invalid prints saved (like the ones enrolled with
fprintd 1) in the storage, this lead to list such prints as enrolled but
they're actually not valid.

So load the prints to ensure that those are of the valid type instead of
just discovering them.

We may make just store.discover_prints to be aware of this, but this
would break some assumptions we do in tests, so better to go this way.
2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
c622e9831b tests/fprintd: Add utility functions to check if prints are stored 2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
b5b389a831 device: Add utility function to load all user prints
We may want to be able to load the user prints to check whether they
are usable, so add an utility function for this.

And use it also in load_all_prints().
2021-03-03 20:15:54 +01:00
Benjamin Berg
3e0c69fec9 device: Add helper routine to load all prints
It might make sense to push this into the storage layer. But, overall,
it is OK to live here, and if we do make changes on the storage layer we
probably want to change more than just this.
2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
7413c9c334 meson: Consider the 'pam' option in the summary
We may show that we build it even when it's disabled but available in
the system
2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
baf36c1412 tests/fprintd: Add better tests for ListEnrolledFingers in unclaimed state 2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
0b6649dc6c tests/fprintd: Add option to claim device for user on enroll_image 2021-03-03 20:15:54 +01:00
Marco Trevisan (Treviño)
ff73a4ee53 pam_fprintd: Consistently return PAM_AUTHINFO_UNAVAIL when device has no prints
Loading saved prints may lead to an error if they were stored long time
ago and so they're using a wrong format.

In such case we list the prints as available even though they are really
not, so the PAM module won't return PAM_AUTHINFO_UNAVAIL as in the
no-prints case but PAM_USER_UNKNOWN.

This will lead some auth systems (such as gdm) to keep retrying using
PAM fprintd module, even if it's not really available.
2021-03-03 20:00:56 +01:00
Benjamin Berg
c76e25514c tests: Update output checker
This pulls in some changes done in gnome-settings-daemon to be able to
force close the FD at the end of the test.
2021-03-03 19:57:42 +01:00
Marco Trevisan (Treviño)
6800d655d3 pam_fprintd.pod: Adapt documentation on max-tries to match code 2021-02-22 22:02:44 +01:00
Marco Trevisan (Treviño)
2d0df19efa pam: Allow values bigger than 9 to be used as max tries match 2021-02-22 22:02:44 +01:00
Marco Trevisan (Treviño)
a489c11163 device: Fail with any non-zero return value on storage print_data_save()
When saving the prints we use g_file_set_contents under the hood and in
case return its error code that is a positive value.

So in such case we don't fail if we have a write failure at the end of
the enrollment.

While we could ensure in file storage to always return a negative value,
it's always better to ensure that is has to be 0 when we didn't get an
error.
2021-02-22 22:02:40 +01:00
Marco Trevisan (Treviño)
30491bb86c device: Check if the device is open if we didn't fail in claiming it
When claiming a device for delete operation we'd not get an error in
case we can claim it but it's not already claimed, so in such case we
should explicitly check that the device has been opened.
2021-02-22 21:56:53 +01:00
Marco Trevisan (Treviño)
5f8ce3634f device: Stop any further EnrollStop/VerifyStop request once we got one
In case we get concurrent requests on EnrollStart/EnrollStop we'd just
continue with the operation, making the first processed request to start
the process and the second to hang (in code before the introduction of
stoppable_action_stop()) or to crash (in the current code).

So in such case we should always check that we're not handling already
the request, by checking priv->current_cancel_invocation value.

Add tests to verify the race.
2021-02-22 21:56:19 +01:00
Marco Trevisan (Treviño)
1c58394fd4 device: Add an unique function to check if we can stop the current action 2021-02-22 21:51:17 +01:00
Marco Trevisan (Treviño)
339a73c43e device: Move duplicated code for stopping a stoppable action into a function
We can handle this in a generic way for all the cancellable cases.
2021-02-22 21:51:10 +01:00
Marco Trevisan (Treviño)
05555a55f2 device: Always use stoppable_action_completed to terminate actions
Avoid having repeated code for doing the same, nothing changes as before
we were doing the same only in case we had not a cancellable set.
2021-02-22 21:51:05 +01:00
Benjamin Berg
584933aad7 pam_fprintd: Fix a few issues found by static analysis
Just dead stores and an ignored return value that we really do not care
about.
2021-01-22 13:16:19 +00:00
Benjamin Berg
eadf4fced8 tests: Add test to verify deletion
This enrolls a few prints, deletes them. Then checks that all the new
prints have been deleted, but all the garbage prints still exist.
2021-01-20 23:25:52 +01:00
Benjamin Berg
27a76c9b79 tests: Add test to check order of garbage collection 2021-01-20 23:25:52 +01:00
Benjamin Berg
9301693c83 tests: Allow use of other virtual devices 2021-01-20 23:25:52 +01:00
Benjamin Berg
00fbf19079 device: Prefer older prints when garbage collecting
This makes garbage collection a bit more predictable overall. Note that
we'll first delete prints that we do not know the age of.

If we cannot sort them by age, then randomize the order so that we don't
end up deleting in the order that the device returned the prints.
2021-01-20 23:25:52 +01:00
Jan Alexander Steffens (heftig)
6fd1aa51cd data: Use the correct mode for the state dir
The code (in file_storage.c) expects mode 0700. However, systemd
defaults to 0755. This causes strange behavior.

https://bugs.archlinux.org/task/68932
2021-01-19 22:18:55 +00:00
Benjamin Berg
0e428d34ec tests: Make tests executable
This makes it easier to use them in out-of-tree tests.
2021-01-13 14:47:00 +01:00
Benjamin Berg
da60bddb3e Release 1.90.9 2021-01-13 13:23:24 +01:00
Benjamin Berg
506d99e90c tests: Check that two consecutive runs work 2021-01-11 12:59:06 +00:00
Benjamin Berg
e7f47e28d7 tests: Add finger and connection sharing for virtual image
This allows testing some more conditions (e.g. forcing VerifyStop to run
into a cancellation).
2021-01-11 12:59:06 +00:00
Benjamin Berg
938c1aac5a device: Add common stoppable_action_completed function
The stoppable actions (Verify/Enroll) have the same logic during
completion. Create a common function to share this logic instead of
copying it in each of the handlers.

Fixes: #97
2021-01-11 12:59:06 +00:00
Marco Trevisan (Treviño)
fd02922608 pam: Pick the device with more enrolled finger prints
When multiple devices are available PAM module will just pick the first
one, even if it has not enrolled fingers.

Since this can't be user configured (yet) we can be a bit smarter and
select the device that has more fingerprints configured for the user.
2021-01-05 12:16:09 +00:00
Marco Trevisan (Treviño)
195f7eaf5f tests/fprintd: Check that fingers deletion will remove user print
But will keep state dir where it is
2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
48ea3b89c9 file_storage: Cleanup the user storage path when removing prints
Try to remove user and devices directories if they are empty.
2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
4cfa6b5b37 file_storage: Remove debug leftovers and add actual debug statements 2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
c685f0d34c file_storage: Don't return an error if the print doesn't exist
We may just try to remove something isn't there so it's not an actual
error from our POV.
2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
eece834231 file_storage: Do not remove the finger path two times
Return the actual operation error instead
2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
3faaa81257 file_storage: Do not ignore STATE_DIRECTORY if it's set to an actual path 2021-01-05 13:07:19 +01:00
Marco Trevisan (Treviño)
b9cdb58a1a device: Load the current finger print and not always the first print
In the garbage collection code we always ended up to load the first
enrolled print, and this may lead to removing from device storage prints
that are actually in use.
2021-01-05 12:57:55 +01:00
Torstein Husebø
ab8dcfaa61 treewide: fix typos 2021-01-04 11:04:13 +01:00
Benjamin Berg
25a97c8276 tests: Add disconnect tests for enroll/verify/identify
We test both the scenario where VerifyStop/EnrollStop is not called
while the operation is still ongoing or when the operation is already
finished.
2021-01-04 11:00:18 +01:00
Benjamin Berg
8057e49d31 tests: Allow claiming in secondary bus helper
This saves an extra step when creating tests that disconnect.
2021-01-04 11:00:18 +01:00
Benjamin Berg
f75e800d5c tests: Allow enrolling from different device
This simplfies disconnect tests as we can do the enroll from the client
that will disconnect later on.
2021-01-04 11:00:18 +01:00
Benjamin Berg
6ae4f5e939 tests: Add get_secondary_bus_and_device helper
It returns a new bus object and the device on that bus. This allows
testing what happens if a client disconnects from the bus.
2021-01-04 11:00:18 +01:00
Benjamin Berg
7c9a04c2ae device: Fix race when client vanishes from bus
We have a condition where a client vanishing instead of cleaning up the
operation using VerifyStop would cause fprintd to hang. This only
happens if the underlying enroll/verify/identify operation has already
finished when the client vanishes.

Fix this by correctly interpreting current_cancellable as a flag for
these operations.

Fixes: #97
2021-01-04 11:00:18 +01:00
boger. wang
7b7aa6e99d device: Fix typos 2021-01-04 09:49:24 +08:00
Marco Trevisan (Treviño)
b624f8c8c7 manager: Do not use unnecessary volatile qualifier on GQuark
As per new GLib in CI image fprintd doesn't build anymore, since
g_once_init_enter now warns about using a volatile value, as this has
never been supposed to be the case, despite its signature [1].

Related to: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

[1] https://gitlab.gnome.org/GNOME/glib/-/issues/600
2020-12-19 22:34:12 +01:00
Marco Trevisan (Treviño)
3e81179eca device: Add auto-cleanup function to unset the current action
This is useful in the functions where we have to unset the device's
current action but we may use early-return to handle multiple conditions
such as in open, close and delete functions.
The latest also currently is a bit buggy as it won't reset the state on
some failures.
2020-12-17 16:33:58 +01:00