Commit graph

120 commits

Author SHA1 Message Date
Siteshwar Vashisht
619ac0e8d1 pam: check for a memory allocation failure
... identified through GCC analyzer:

```
Error: GCC_ANALYZER_WARNING (CWE-476): [#def5]
fprintd-v1.94.5/redhat-linux-build/../pam/pam_fprintd.c:768:3: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘data’
/usr/include/security/pam_modules.h:34:5: enter_function: entry to ‘pam_sm_authenticate’
fprintd-v1.94.5/redhat-linux-build/../pam/pam_fprintd.c:843:6: branch_false: following ‘false’ branch...
fprintd-v1.94.5/redhat-linux-build/../pam/pam_fprintd.c:846:7: branch_false: ...to here
fprintd-v1.94.5/redhat-linux-build/../pam/pam_fprintd.c:846:6: branch_false: following ‘false’ branch...
 branch_false: ...to here
fprintd-v1.94.5/redhat-linux-build/../pam/pam_fprintd.c:915:10: call_function: calling ‘do_auth’ from ‘pam_sm_authenticate’
  766|
  767|     data = calloc (1, sizeof (verify_data));
  768|->   data->max_tries = max_tries;
  769|     data->pamh = pamh;
  770|
```

Resolves: https://openscanhub.fedoraproject.org/task/51967/log/fprintd-1.94.5-1.fc43/scan-results.html#def5

Signed-off-by: Siteshwar Vashisht <svashisht@redhat.com>
2025-05-26 15:08:06 +02:00
Marco Trevisan (Treviño)
cb0616412f pam/fingerprint-strings: finger/fingerprint replacement 2025-04-02 11:49:12 +02:00
Benjamin Chris
e9b967d4dc Fix the issue unlimited or long timeout of pam module not working #147 2025-02-20 21:16:54 +01:00
Marco Trevisan (Treviño)
5f73ca1e3f build: Do not use deprecated hacks in newer meson 2025-02-20 20:09:47 +00:00
Johannes Hostert
b79ac14b0f Reduce minimum timeout to 1 second 2025-02-20 19:58:58 +00:00
Marco Trevisan (Treviño)
8010adea9c pam/fingerprint-strings: Add translatable strings for generic errors 2025-02-20 20:33:40 +01:00
Marco Trevisan (Treviño)
e41241a737 pam/fingerprint-strings: Add error message for duplicated enroll 2025-02-20 20:15:17 +01:00
Marco Trevisan (Treviño)
e9bfb77426 pam/fingerprint-strings: Add proper variants for touching devices 2025-02-20 20:15:17 +01:00
Marco Trevisan (Treviño)
afb1011e44 device: Add enroll-too-fast error 2025-02-20 20:15:17 +01:00
Marco Trevisan (Treviño)
244be2511f device: Generalize verify-too-fast error
It's not just related to swipe devices, so let's make it more generic
2025-02-20 20:15:17 +01:00
MrNerdHair
b64a4f7fbd Handle new FP_DEVICE_RETRY_TOO_FAST error code 2025-02-13 23:55:33 +00:00
Brett T. Warden
daef1b0659 Use prefix to determine pam_modules_dir 2024-09-03 08:47:34 -07:00
Marco Trevisan (Treviño)
d371f35e3a build: Check for openpam headers usability
Ensure that openpam headers can be used, we might even just checked for
the openpam_version.h header, but this respects more the real world
scenario
2024-08-30 17:45:55 +02:00
Marco Trevisan (Treviño)
b9e55394e9 pam: Cleanup non-linux codepaths 2024-08-30 13:40:03 +02:00
Daniel Schaefer
8d4e3e6fb7 pam: Allow build with OpenPAM instead of linux-pam
Signed-off-by: Daniel Schaefer <dhs@frame.work>
2024-08-30 14:59:17 +08:00
Marco Trevisan (Treviño)
fbea20a5a9 pam: Use simpler defined value when basu is in use 2024-08-30 05:46:00 +02:00
Daniel Schaefer
4a8ca4208d pam: Allow build with basu instead of libsystemd
Signed-off-by: Daniel Schaefer <dhs@frame.work>
2024-08-30 05:45:35 +02:00
Daniel Schaefer
223bd3a711 freebsd: Find libintl
On GNU/Linux it's included in libc, on the BSDs it's not.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
2024-08-30 03:13:39 +00:00
Daniel Schaefer
31a596dc97 pam: Include time.h for clock_gettime
Signed-off-by: Daniel Schaefer <dhs@frame.work>
2024-08-30 03:13:39 +00:00
Daniel Schaefer
4b00e5642a pam: Use signalfd only on Linux
Other operating systems don't have signalfd.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
2024-08-30 03:05:59 +00:00
Hugo Osvaldo Barrera
679ff2a20c Fix some bad indentation 2023-02-13 17:23:47 +01:00
Marco Trevisan (Treviño)
81f52522a6 pam_fprintd: Support setting infinite max_tries
This can be handled by the module loader (i.e. GDM), so a particular
pam configuration may be interested in disabling the max-tries check at
all.
2022-02-24 16:11:13 +00:00
Marco Trevisan (Treviño)
fbd56d6662 pam_fprintd: Support disabling the module timeout
This can be handled by the module loader (i.e. GDM) and in any case we
may want to have setups where fprintd is always active waiting for a
fingerprint, as modern devices support this with no problems.
2022-02-24 16:11:13 +00:00
Benjamin Berg
bb23b7e9d0 pam: Immediately return verify-match/verify-no-match
In the verify-match case, this means disconnecting from the bus rather
than stopping the verification. This is the only way to make sure that
the result is immediately reported and we do not wait for the device to
be idle again (which generally means waiting for finger removal).

In the verify-no-match case we simply send the string first before the
operation is stopped. An exceeded retry limit is only reported after
VerifyStop has finished.
2021-08-02 13:00:43 +02:00
Benjamin Berg
9ec1747b84 Revert "pam_fprintd: Just return a PAM_AUTH_ERROR on unknown errors"
This reverts commit ecf6b7c323.

The idea of the commit was to make device failures less fatal to the
system. Unfortunately, we can fail quickly in this case, and returning
PAM_AUTH_ERR means that the user might run into a retry limit due to
this.

Go back to reporting PAM_AUTHINFO_UNAVAIL, it appears as the lesser evil
right now. Ideally we want to a way to tell the upper stack to retry
authentication whenever there is a good opportunity, but to not consider
it as an authentication failure.
2021-07-01 12:59:11 +02:00
Thibault HEINRICH
00629fc374 pam: Mark no-match error message as translatable 2021-06-25 16:07:53 +00:00
Marco Trevisan (Treviño)
ecf6b7c323 pam_fprintd: Just return a PAM_AUTH_ERROR on unknown errors
If something under the hood failed with a generic device error we'd just
mark the PAM module not available, this is probably too much as it may
just be due to a device temporary error.

So make it stop but allow the loading system to retry with it
2021-03-02 17:15:14 +01:00
Marco Trevisan (Treviño)
df6ebefef7 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-02 17:15:14 +01:00
Marco Trevisan (Treviño)
556f8928a6 pam: Allow values bigger than 9 to be used as max tries match 2021-02-01 18:07:52 +01:00
Benjamin Berg
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
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
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
Benjamin Berg
1fc10f15ee pam: Stop authorization if we couldn't parse signals
This really should never ever happen. If it does, don't continue but
stop instead.
2020-12-11 10:34:51 +01:00
Benjamin Berg
c24badfd68 pam: Move NameOwnerChanged registration after initialization
We must ignore NameOwnerChanged that happen due to automatic startup.
The easy way to do so is to just register it only when we get to the
point that a name owner change has security implications.

While add it, change it to always log at a warning level.

Fixes: #94
2020-12-11 10:34:51 +01:00
Marco Trevisan (Treviño)
944493e472 pam_fprintd: Protect usage of strdup for NULL values
It's not smart as g_strdup, so need to ensure we don't use it for NULL
strings.

This is a regression caused by commit bf223662
2020-12-08 21:14:01 +01:00
Marco Trevisan (Treviño)
f73429f062 fprintd: Reindent the source code following uncrustify rules 2020-12-07 18:41:45 +01:00
Marco Trevisan (Treviño)
4a80bfacec fingerprint-strings: Make the finger_str_to_msg loop clearer
Just continue earlier instead of using a long if check
2020-12-07 18:41:45 +01:00
Benjamin Berg
043fcaafec pam_fprintd: Guard against NULL pointer returned by finger_str_to_msg
Otherwise the PAM module will crash trying to send an info message about
the selected print.
2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
bf2236620e pam_fprintd: Implement auto-pointers and use early-return more around
Implement simple auto-pointers for the types we use in pam_fprintd with
a basic implementation based on GLib one so that we can have the same
features without having neither an header-dependency on it.
2020-12-07 15:27:14 +01:00
Benjamin Berg
c5877bbc12 pam: Stop authentication with PAM_AUTHINFO_UNAVAIL on name owner change
If fprintd disappears or is replaced, then we might be getting signals
from another daemon/verifcation session.

As such we must give up at that point.

Related: #47
2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
a76af6ce71 pam_fprintd: Clear the data value before setting it if set 2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
47751548b2 pam_fprintd: Ignore any verify signal if we didn't complete VerifyStart
In case fprintd is emitting a verify signal for another request that is
still going on while we're about to start a new verification, we'd just
accept such signal, so potentially allowing a log-in because another
concurrent request succeeded.

To avoid this, use async call to VerifyStart and open a verify window
(during which we accept the verification related signals) that is kept
open just once the VerifyStart call has been completed and before
stopping the verification again. As that's the only moment in which we
can be sure that we've control of the daemon events for such device.

Thanks to Benjamin to find out the race.

Fixes: #47
2020-12-07 15:27:14 +01:00
Benjamin Berg
f4eaacd0ec pam: Return a fixed string about protocol error if there is no message
This can only happen if fprintd is not adhering to the protocol.
2020-12-07 15:27:14 +01:00
Benjamin Berg
e301779c20 Fix integer signedness mismatches 2020-12-01 09:00:55 +00:00
Benjamin Berg
ebfcbdd13e pam: Use %d with errno instead of %m
Otherwise GCC warns sometimes, and it is easy enough to replace the use
of %m.
2020-12-01 09:00:55 +00: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
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
Bastien Nocera
b90b21f26b build: Make pam module installation dir configurable
And avoid treating "libdir" as an absolute path, the documentation
clearly states that it is "relative to the prefix".

Based on patch by Timothy Gu <timothygu99@gmail.com>
2020-02-10 14:49:11 +01:00
Bastien Nocera
b02825620a Revert "build: Ensure that gcov symbols are exposed when needed"
This reverts commit 526b2e8c53.

Commit 0994cc31 was enough to implement the coverage support.
2020-02-05 17:09:19 +01:00