Commit Graph

667 Commits

Author SHA1 Message Date
804aff3c30 tests/fprintd: Use a class to compare permissions easily 2021-01-25 18:18:40 +01:00
f87cb27163 device: Fix debug statement string ordering and be more consistent
We were inverting the values in the `Authorization granted` message, so
be consistent in the ordering we show the message.
2021-01-25 18:18:40 +01:00
457cbd46cd 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-01-25 18:18:39 +01:00
32b70c0edc device: Add an unique function to check if we can stop the current action 2021-01-25 18:18:13 +01:00
ff798edc51 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-01-22 22:06:07 +01:00
56436fb8b1 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-01-22 22:06:01 +01:00
dbf01399ad device: Throw an error if we failed to delete a device storage print
Although this error is not fatal as the local print reference has been
properly removed.
2021-01-22 15:19:21 +01:00
0f29cfc0c7 tests/fprintd: Check the storage errors are emitted if we fail delete prints 2021-01-22 15:19:21 +01:00
e0a643f3b9 device: Return more specific error if we failed cleaning up the storage 2021-01-22 15:19:21 +01:00
3fa0f232ef tests/fprintd: Ensure DeleteEnrolledFingers2 works for multiple fingers 2021-01-22 15:19:21 +01:00
3c91ac9a3f tests/fprintd: Add utility functions to check if prints are stored 2021-01-22 15:19:20 +01:00
3fe268f6f2 tests/fprintd: Move permissions checks to a single function 2021-01-22 15:18:39 +01:00
76c6e9e030 device: Return errors on deletion of prints from storage 2021-01-22 15:17:57 +01:00
5dde80c136 device: Expose an error if we are not able to remove a print from storage
This is case we should notify, as in such case the print will still
usable.
2021-01-22 15:17:57 +01:00
0203c8aed8 tests: Add more tests to verify AlreadyInUse error on deletion methods 2021-01-22 15:17:57 +01:00
7d87f5e664 device: Set an error if trying to delete a print that is not enrolled 2021-01-22 15:17:57 +01:00
fd72c0b81b device: Support deleting a single fingerprint for user
Add a method to delete only a Fingerprint for a device, this is required
by they g-c-c UI design and at the same time it reflects the libfprint
API, where so far only a fingerprint at time can be deleted.
2021-01-22 15:17:57 +01:00
1835d99265 device: Expose finger status as DBus properties
libfprint v1.90.4 introduced a new finger status API to expose to the UI
the finger status on sensor.

Add two new properties to the Device interface that represent the
possible values.

Add new tests.
2021-01-22 14:10:04 +00:00
30eaaf2def device: Take advantage of the DBus skeleton properties caching
The device DBus skeleton interface already implements caching for the
properties and can smartly handle their update sending (batched) dbus
events on changes.

Even if the default properties are only read only and we don't care, we
are going to introduce properties that will change values, and so having
the skeleton to handle this for us is quite convenient.

Given that we don't really need to override those properties, we can
just set them at start and leave the skeleton cache to handle the rest.

In case we'd ever need to override them, however the skeleton also
provides a way to override all the properties and to get a reference of
the number of properties it defines, ensuring to keep the order they are
defined.
This would allow us to get back the parent's properties IDs and to use
this to implement ours properties getters/setters using the parent one
as fallback.
2021-01-22 14:10:04 +00:00
657f58fd64 pam: Handle sigint by using a signalfd
It makes sense to allow interrupting fingerprint authentication, but PAM
does not provide a way to define an interruptable operation.

We can work around this somewhat though by at least reacting to SIGINT
in an interactive terminal. Obviously, we shouldn't override the signal
handler, because that would be too intrusive. But creating a signalfd is
easy enough and doesn't affect the rest of the process state as much.
2021-01-22 13:23:36 +00:00
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
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
27a76c9b79 tests: Add test to check order of garbage collection 2021-01-20 23:25:52 +01:00
9301693c83 tests: Allow use of other virtual devices 2021-01-20 23:25:52 +01:00
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
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
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
da60bddb3e Release 1.90.9 v1.90.9 2021-01-13 13:23:24 +01:00
506d99e90c tests: Check that two consecutive runs work 2021-01-11 12:59:06 +00:00
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
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
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
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
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
4cfa6b5b37 file_storage: Remove debug leftovers and add actual debug statements 2021-01-05 13:07:19 +01:00
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
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
3faaa81257 file_storage: Do not ignore STATE_DIRECTORY if it's set to an actual path 2021-01-05 13:07:19 +01:00
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
ab8dcfaa61 treewide: fix typos 2021-01-04 11:04:13 +01:00
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
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
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
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
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
7b7aa6e99d device: Fix typos 2021-01-04 09:49:24 +08:00
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
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
c6647ba875 tests: Add test that enforces a verify/identify operation restart
In the usual test we cancel the operation immediately by calling
VerifyStop. This (often) tests the case where we don't end up restarting
the Verify operation internally.

We can easily force fprintd to have restarted already internally, so add
a test that does so by sleeping a bit. This should give us a slightly
higher branch coverage in the verify_cb/identify_cb tests.
2020-12-16 14:44:23 +01:00
988ee01f66 tests: Add retry test for PAM 2020-12-16 14:12:37 +01:00