Commit graph

510 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
e7f3b94081 device: Propagate the error during deletion on bus
If a device with storage memory fails during deletion phase, we just ignore
it silently from the dbus-client POV, while we should instead propagate the
error to the client.
2020-11-06 10:17:28 +00:00
Marco Trevisan (Treviño)
edf95d554d device: Return errors if we fail open/close during delete
When using Delete() method with a device with storage, we need to claim it,
however in case of failure we never return a DBus error, but instead we
ignore from the client point of view.
2020-11-06 10:17:28 +00:00
Marco Trevisan (Treviño)
b2cae5cccf tests/fprintd: Check that identification with multiple images works 2020-11-06 11:06:25 +01:00
Marco Trevisan (Treviño)
3419901f65 build: Don't add the utils tests under the daemon suite 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
c85ca09e35 tests/fprintd-utils: Ensure that we exit with error if we have no device 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
ecc02cb588 utils: Uniform the no-devices error messages removing duplicated checks
Use error messages to be consistent, and avoid checking for a returned
value when dbus-glib function to fetch it returned false, as it's
implicit that we had a failure.

Otherwise if didn't fail we are sure that we got the requested value.
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
091f373109 tests/fprintd-utils: Check the tools return values in some tests 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
f6eb3b3ea5 verify: Pass the "any" finger parameter to the daemon
fprintd supports "any" finger parameter for the VerifyStart call, and it's
up to the daemon to pick the first known if the device doesn't support
identification.

So remove the check to verify utility and add a test to verify this is
respected.
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
d7ca9e6095 tests/fprintd-utils: Verify happens on first finger if device has no identification
Ensure that this is true when using the utility
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
6797928884 dbusmock/fprintd: Add ability to add a device with Identification support
Devices which have identification support "any" finger and do not fallback
to a single-finger check.
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
d6c70be822 dbusmock/fprintd: Add ability to remove devices 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
d33a7c7e9d tests/fprintd-utils: Check that all fingers are listed 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
94d3a18dcd tests/fprintd-utils: Check that verify returns an error if no finger is set 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
5635383c96 tests/fprintd-utils: Check that fprintd-verify requests the expected finger 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
ac98b881be dbusmock/fprintd: Make possible to retrieve the finger selected for verification
So that we can ensure that the client requested the one we expect
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
629f7fcc11 dbusmock/fprintd: Reset the current action on release
So it happens in the real daemon
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
5a703baa20 verify: Fail if we try to verify a non-enrolled finger
Since we list the fingers available fail early in case it's not found
2020-11-04 21:06:10 +01:00
Marco Trevisan (Treviño)
6641cb6da8 tests/fprintd-utils: Verify that we can match all the enrolled fingers 2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
870b48637a tests/fprintd-utils: Verify errors if the device is already claimed 2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
4b0cde81fd tests/fprintd-utils: Add utility function to stop the utility process
This avoids addCleanup ordering errors and also errors when we may try to
print an invalid stdout pipe (like when we have processed it all), as python
might fail with something like:

 ======================================================================
 ERROR: test_fprintd_multiple_verify_fails (__main__.TestFprintdUtilsVerify)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "~/GNOME/fprintd/tests/test_fprintd_utils.py", line 102, in <lambda>
     self.addCleanup(lambda: print(process.stdout.read()))
   File "/usr/lib/python3.8/codecs.py", line 321, in decode
     data = self.buffer + input
 TypeError: can't concat NoneType to bytes
2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
59b3d2af8d tests/fprintd-utils: Call addCleanup actions in reverse order
unittest addCleanup calls are called in reverse order, so we need to reverse
the order of the calls as well, otherwise we won't correctly terminate the
subprocess children
2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
93bcac946e tests/fprintd-utils: Move verification tests to a single class
We can factorize various checks, so let's simplify test code
2020-11-04 21:04:19 +01:00
Marco Trevisan (Treviño)
a5063dc0e4 tests/fprintd-utils: Setup the device on setUp()
No need to repeat the action in every unit test, but move the tests to a
different class to easily allow adding another class with tests with no
such initialization
2020-11-04 20:20:29 +01:00
Marco Trevisan (Treviño)
5fbc38c938 tests/fprintd-utils: Run super setUp/tearDown functions 2020-11-04 20:04:21 +01:00
Benjamin Berg
c42e627ddd pam: Always return translated string from helper
This means that the different functions in the header match as all
functions will return the translted string instead of only one of them.
2020-10-13 09:29:44 +00:00
Bastien Nocera
2fd86624e5 data: Add additional fprintd lockdown 2020-10-13 09:28:39 +00:00
Benjamin Berg
6dc699ae6f tests: Fix test not failing on error
An assertion that is raised within a callback will not be swallowed by
the C code that called the function. To ensure that errors will be
noticable, pass the result back to the surrounding scope and check it
there.
2020-10-02 17:54:20 +02:00
Benjamin Berg
e075d37590 tests: Check that a verify operation can be immediately restarted
This excercises the path where we early-report a result and the
VerifyStop call must wait for the operation to complete intenernally.

Note that this test cannot fail right now due to the FpImageDevice
internal code still trying to hide the deactivation delay internally.

See libfprint!174
2020-10-01 12:19:35 +00:00
Marco Trevisan (Treviño)
18d6a86e9d device: Use early match for reporting verify status
libfprint 1.90.1 supports early match result report which allows to inform
the clients as soon as the driver detected a match/no-match without having
to wait the whole device driver deactivation.

Use this feature in fprintd, by emitting the "VerifyStatus" signal as soon
as we've an usable result we can inform the client about.

As per this, ignore any possible error we may get afterwards, due to device
issues or late user cancellation, as the point of the verification action
(i.e. getting a match/no-match) can be considered accomplished.

Fixes https://gitlab.freedesktop.org/libfprint/fprintd/issues/35
2020-10-01 12:19:35 +00:00
Benjamin Berg
14051cac76 device: Fix race condition when clients vanish
If a client vanishes while we are opening or closing then fprintd would
uncoditionally try to close the device immediately. This should not be
done, it instead needs to wait for the open/close to complete.

Add open/close to the current action enum and keep track of the fact
that they are ongoing. Also check, whether the device has been closed in
the meantime (after the nested mainloop is done).

Fixes: #65
2020-10-01 10:39:05 +00:00
Bastien Nocera
4e47222962 Revert "ci: Work-around meson coverage bug"
This reverts commit c07a63da99.
2020-08-18 12:07:59 +02:00
Bastien Nocera
c07a63da99 ci: Work-around meson coverage bug
See https://github.com/mesonbuild/meson/issues/7437
2020-08-17 16:41:07 +02:00
Bastien Nocera
812a3552a6 build: Fix custom_target meson warning
WARNING: custom_target 'utils_marshal' has more than one output! Using the first one.
2020-08-17 16:14:25 +02:00
Bastien Nocera
ff06a301f0 build: Bump libfprint req 2020-08-17 15:21:27 +02:00
Bastien Nocera
19353c971c build: Add some linefeeds to generated XML files 2020-08-17 15:21:27 +02:00
Benjamin Berg
290e56023f tests: Test more branches in pam verify signal handler 2020-08-17 15:11:08 +02:00
Benjamin Berg
efe92a7c33 pam: Increase severity to error for unknown verify results 2020-05-27 14:15:15 +02:00
Benjamin Berg
a7cf0ae3b2 pam: Fix double free after verification error
The data->result was free'ed both in the loop (before breaking) and
afterwards. As the first case did not set the pointer to NULL, this
could result in a double free.

Fix this by simply removing the free that is in the loop and relying on
the cleanup later on.
2020-05-27 13:38:37 +02:00
Marco Trevisan (Treviño)
ba60533f71 device: Remove unused disconnected flag
We were saving the state of a disconnected device because we used a
workaround to figure it out, but now libfprint would provide us a proper
GError in such case, and so we'd handle it without the need of saving the
state, given it's never used anyways.
2020-05-11 15:11:53 +00:00
Bastien Nocera
fcd2d65490 tests: Add PAM test for hardware failure
This error is supposed to help replicate the problems encountered in:
https://gitlab.freedesktop.org/libfprint/fprintd/-/issues/59
2020-04-07 10:47:35 +02:00
Marco Trevisan (Treviño)
6dd010f05c ci: Add a job running tests built with address sanitizer 2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
714f499ab6 tests: Double the timeouts when testing with address sanitizer 2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
d72c802415 tests/fprintd: Ensure that the daemon doesn't crash or abort
An application terminating because of a signal like SIGSEGV, SIGABRT and
friends, will exit with a signal number that is 128 + $SIGNAL_NUMBER, so
let's ensure that the daemon has not been terminated because of a such error

This makes even more sense with address sanitizer builds, as the daemon
would exit with abort.
2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
184e1bd4d0 build: Support running tests with address sanitizer
Make possible to run tests with address sanitizer to quickly check for
memory errors, although we have to disable the error exit code in case of
leaks because we have some which are due to something else down in the stack
(and LSAN suppression files doesn't allow to define the stack to ignore
as we can in valgrind).

However, we'd abort in case of memory errors anyways, so this still helps
to prevent major problems, while still logging the leaks.

In order to run pam module tests with ASAN we need to manually pass the
library to LD_PRELOAD, as we do for the wrapper.
2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
f401f399a8 pam: Get preloaded libraries paths using compiler
In order to run pam module tests we need to pass the libraries via
LD_PRELOAD, this supports a list of library paths, so use the compiler in
order to find their full paths (with soname) and check their presence.

In order to support linker scripts we need to introduce a workaround.
See meson issue https://github.com/mesonbuild/meson/issues/6880
2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
3dd0018f23 build: Set default CFLAGS using meson's c_args
Meson supports checking for default arguments natively without having to
do this for each one, so just use this feature.

Not doing this will become a warning as per meson 0.52.0 [1].

[1] https://github.com/mesonbuild/meson/pull/5627
2020-03-31 14:26:38 +02:00
Marco Trevisan (Treviño)
90298134a2 tests/fprintd: Add checks for delete enrolled fingers permissions
The test doesn't need any assertion because we're calling DeleteEnrolledFingers
and in case it fails a net.reactivated.Fprint.Error.PermissionDenied error
would be thrown, and thus an exception would be raised at python level, making
the test to fail.
2020-03-27 20:45:59 +01:00
Bastien Nocera
8ff4360750 tests: Add test for STATE_DIRECTORY being multiple paths 2020-03-27 17:05:13 +01:00
Bastien Nocera
fd733e55be file_storage: Handle STATE_DIRECTORY containing multiple paths
As per systemd's documentation:
If multiple directories are set, then in the environment variable the
paths are concatenated with colon (":").

Handle that case by splitting the paths if there's a ":" in the
variable.

Closes: #50
2020-03-27 17:05:06 +01:00
Bastien Nocera
6a1fffae82 tests/fprintd: Fix claim_from_other_client_is_released_when_vanished on CI
test_claim_from_other_client_is_released_when_vanished would fail on
the CI but work on a local system because we wouldn't want long enough
for the "vanished" code path to be taken into account. Add a small
timeout to make sure it works on the CI as well.
2020-03-27 16:57:16 +01:00