From cf6da59a581cb580a68653c0031720f9fb9bfdc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 20 Feb 2025 21:40:35 +0100 Subject: [PATCH 1/2] fingerprint-strings: Synchronize with upstream Update the strings to match upstream values and handle new errors Get new file from upstream [1]. [1] https://gitlab.freedesktop.org/libfprint/fprintd/-/blob/HEAD/pam/fingerprint-strings.h --- panels/system/users/fingerprint-strings.h | 338 ++++++++++++++-------- 1 file changed, 210 insertions(+), 128 deletions(-) diff --git a/panels/system/users/fingerprint-strings.h b/panels/system/users/fingerprint-strings.h index e65491deaf..3b487b6f66 100644 --- a/panels/system/users/fingerprint-strings.h +++ b/panels/system/users/fingerprint-strings.h @@ -1,7 +1,7 @@ /* * Helper functions to translate statuses and actions to strings * Copyright (C) 2008 Bastien Nocera - * + * * Experimental code. This will be moved out of fprintd into it's own * package once the system has matured. * @@ -9,111 +9,150 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +/* This file should be kept in sync with: + * https://gitlab.freedesktop.org/libfprint/fprintd/-/blob/HEAD/pam/fingerprint-strings.h + */ + #pragma once -struct { - const char *dbus_name; - const char *place_str_generic; - const char *place_str_specific; - const char *swipe_str_generic; - const char *swipe_str_specific; +#include +#include + +#define GNUC_UNUSED __attribute__((__unused__)) + +static bool +str_equal (const char *a, const char *b) +{ + if (a == NULL && b == NULL) + return true; + if (a == NULL || b == NULL) + return false; + return strcmp (a, b) == 0; +} + +struct +{ + const char *dbus_name; + const char *place_str_generic; + const char *place_str_specific; + const char *swipe_str_generic; + const char *swipe_str_specific; } fingers[] = { - { "any", - N_("Place your finger on the fingerprint reader"), - N_("Place your finger on %s"), - N_("Swipe your finger across the fingerprint reader"), - N_("Swipe your finger across %s") }, - { "left-thumb", - N_("Place your left thumb on the fingerprint reader"), - N_("Place your left thumb on %s"), - N_("Swipe your left thumb across the fingerprint reader"), - N_("Swipe your left thumb across %s") }, - { "left-index-finger", - N_("Place your left index finger on the fingerprint reader"), - N_("Place your left index finger on %s"), - N_("Swipe your left index finger across the fingerprint reader"), - N_("Swipe your left index finger across %s") }, - { "left-middle-finger", - N_("Place your left middle finger on the fingerprint reader"), - N_("Place your left middle finger on %s"), - N_("Swipe your left middle finger across the fingerprint reader"), - N_("Swipe your left middle finger across %s") }, - { "left-ring-finger", - N_("Place your left ring finger on the fingerprint reader"), - N_("Place your left ring finger on %s"), - N_("Swipe your left ring finger across the fingerprint reader"), - N_("Swipe your left ring finger across %s") }, - { "left-little-finger", - N_("Place your left little finger on the fingerprint reader"), - N_("Place your left little finger on %s"), - N_("Swipe your left little finger across the fingerprint reader"), - N_("Swipe your left little finger across %s") }, - { "right-thumb", - N_("Place your right thumb on the fingerprint reader"), - N_("Place your right thumb on %s"), - N_("Swipe your right thumb across the fingerprint reader"), - N_("Swipe your right thumb across %s") }, - { "right-index-finger", - N_("Place your right index finger on the fingerprint reader"), - N_("Place your right index finger on %s"), - N_("Swipe your right index finger across the fingerprint reader"), - N_("Swipe your right index finger across %s") }, - { "right-middle-finger", - N_("Place your right middle finger on the fingerprint reader"), - N_("Place your right middle finger on %s"), - N_("Swipe your right middle finger across the fingerprint reader"), - N_("Swipe your right middle finger across %s") }, - { "right-ring-finger", - N_("Place your right ring finger on the fingerprint reader"), - N_("Place your right ring finger on %s"), - N_("Swipe your right ring finger across the fingerprint reader"), - N_("Swipe your right ring finger across %s") }, - { "right-little-finger", - N_("Place your right little finger on the fingerprint reader"), - N_("Place your right little finger on %s"), - N_("Swipe your right little finger across the fingerprint reader"), - N_("Swipe your right little finger across %s") }, - { NULL, NULL, NULL, NULL, NULL } + { "any", + N_("Place your finger on the fingerprint reader"), + N_("Place your finger on %s"), + N_("Swipe your finger across the fingerprint reader"), + N_("Swipe your finger across %s") }, + { "left-thumb", + N_("Place your left thumb on the fingerprint reader"), + N_("Place your left thumb on %s"), + N_("Swipe your left thumb across the fingerprint reader"), + N_("Swipe your left thumb across %s") }, + { "left-index-finger", + N_("Place your left index finger on the fingerprint reader"), + N_("Place your left index finger on %s"), + N_("Swipe your left index finger across the fingerprint reader"), + N_("Swipe your left index finger across %s") }, + { "left-middle-finger", + N_("Place your left middle finger on the fingerprint reader"), + N_("Place your left middle finger on %s"), + N_("Swipe your left middle finger across the fingerprint reader"), + N_("Swipe your left middle finger across %s") }, + { "left-ring-finger", + N_("Place your left ring finger on the fingerprint reader"), + N_("Place your left ring finger on %s"), + N_("Swipe your left ring finger across the fingerprint reader"), + N_("Swipe your left ring finger across %s") }, + { "left-little-finger", + N_("Place your left little finger on the fingerprint reader"), + N_("Place your left little finger on %s"), + N_("Swipe your left little finger across the fingerprint reader"), + N_("Swipe your left little finger across %s") }, + { "right-thumb", + N_("Place your right thumb on the fingerprint reader"), + N_("Place your right thumb on %s"), + N_("Swipe your right thumb across the fingerprint reader"), + N_("Swipe your right thumb across %s") }, + { "right-index-finger", + N_("Place your right index finger on the fingerprint reader"), + N_("Place your right index finger on %s"), + N_("Swipe your right index finger across the fingerprint reader"), + N_("Swipe your right index finger across %s") }, + { "right-middle-finger", + N_("Place your right middle finger on the fingerprint reader"), + N_("Place your right middle finger on %s"), + N_("Swipe your right middle finger across the fingerprint reader"), + N_("Swipe your right middle finger across %s") }, + { "right-ring-finger", + N_("Place your right ring finger on the fingerprint reader"), + N_("Place your right ring finger on %s"), + N_("Swipe your right ring finger across the fingerprint reader"), + N_("Swipe your right ring finger across %s") }, + { "right-little-finger", + N_("Place your right little finger on the fingerprint reader"), + N_("Place your right little finger on %s"), + N_("Swipe your right little finger across the fingerprint reader"), + N_("Swipe your right little finger across %s") }, + { NULL, NULL, NULL, NULL, NULL } }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" -G_GNUC_UNUSED static char *finger_str_to_msg(const char *finger_name, const char *driver_name, gboolean is_swipe) +GNUC_UNUSED static char * +finger_str_to_msg (const char *finger_name, const char *driver_name, bool is_swipe) { - int i; - - if (finger_name == NULL) - return NULL; - - for (i = 0; fingers[i].dbus_name != NULL; i++) { - if (g_str_equal (fingers[i].dbus_name, finger_name)) { - if (is_swipe == FALSE) { - if (driver_name) - return g_strdup_printf (TR (fingers[i].place_str_specific), driver_name); - else - return g_strdup (TR (fingers[i].place_str_generic)); - } else { - if (driver_name) - return g_strdup_printf (TR (fingers[i].swipe_str_specific), driver_name); - else - return g_strdup (TR (fingers[i].swipe_str_generic)); - } - } - } - - return NULL; + int i; + + if (finger_name == NULL) + return NULL; + + for (i = 0; fingers[i].dbus_name != NULL; i++) + { + if (!str_equal (fingers[i].dbus_name, finger_name)) + continue; + if (is_swipe == false) + { + if (driver_name) + { + char *s; + int ret; + ret = asprintf (&s, TR (fingers[i].place_str_specific), driver_name); + return ret >= 0 ? s : NULL; + } + else + { + return strdup (TR (fingers[i].place_str_generic)); + } + } + else + { + if (driver_name) + { + char *s; + int ret; + ret = asprintf (&s, TR (fingers[i].swipe_str_specific), driver_name); + return ret >= 0 ? s : NULL; + } + else + { + return strdup (TR (fingers[i].swipe_str_generic)); + } + } + } + + return NULL; } #pragma GCC diagnostic pop @@ -121,52 +160,95 @@ G_GNUC_UNUSED static char *finger_str_to_msg(const char *finger_name, const char /* Cases not handled: * verify-no-match * verify-match - * verify-unknown-error */ -G_GNUC_UNUSED static const char *verify_result_str_to_msg(const char *result, gboolean is_swipe) +GNUC_UNUSED static const char * +verify_result_str_to_msg (const char *result, bool is_swipe) { - if (result == NULL) - return NULL; - - if (strcmp (result, "verify-retry-scan") == 0) { - if (is_swipe == FALSE) - return TR (N_("Place your finger on the reader again")); - else - return TR (N_("Swipe your finger again")); - } - if (strcmp (result, "verify-swipe-too-short") == 0) - return TR (N_("Swipe was too short, try again")); - if (strcmp (result, "verify-finger-not-centered") == 0) - return TR (N_("Your finger was not centered, try swiping your finger again")); - if (strcmp (result, "verify-remove-and-retry") == 0) - return TR (N_("Remove your finger, and try swiping your finger again")); - - return NULL; + if (result == NULL) + return NULL; + + if (strcmp (result, "verify-retry-scan") == 0) + { + if (is_swipe == false) + return TR (N_("Place your finger on the reader again")); + else + return TR (N_("Swipe your finger again")); + } + if (strcmp (result, "verify-swipe-too-short") == 0) + return TR (N_("Swipe was too short, try again")); + if (strcmp (result, "verify-finger-not-centered") == 0) + { + if (is_swipe) + return TR (N_("Your finger was not centered, try swiping your finger again")); + else + return TR (N_("Your finger was not centered, try touching the sensor again")); + } + if (strcmp (result, "verify-remove-and-retry") == 0) + { + if (is_swipe) + return TR (N_("Remove your finger, and try swiping your finger again")); + else + return TR (N_("Remove your finger, and try touching the sensor again")); + } + if (strcmp (result, "verify-too-fast") == 0) + { + if (is_swipe) + return TR (N_("Swipe was too fast, try again")); + else + return TR (N_("Finger scan was too fast, try again")); + } + + if (strcmp (result, "verify-unknown-error") == 0) + return TR (N_("An unexpected error happened during finger verification")); + + return NULL; } /* Cases not handled: * enroll-completed - * enroll-failed - * enroll-unknown-error */ -G_GNUC_UNUSED static const char *enroll_result_str_to_msg(const char *result, gboolean is_swipe) +GNUC_UNUSED static const char * +enroll_result_str_to_msg (const char *result, bool is_swipe) { - if (result == NULL) - return NULL; - - if (strcmp (result, "enroll-retry-scan") == 0 || strcmp (result, "enroll-stage-passed") == 0) { - if (is_swipe == FALSE) - return TR (N_("Place your finger on the reader again")); - else - return TR (N_("Swipe your finger again")); - } - if (strcmp (result, "enroll-swipe-too-short") == 0) - return TR (N_("Swipe was too short, try again")); - if (strcmp (result, "enroll-finger-not-centered") == 0) - return TR (N_("Your finger was not centered, try swiping your finger again")); - if (strcmp (result, "enroll-remove-and-retry") == 0) - return TR (N_("Remove your finger, and try swiping your finger again")); - - return NULL; -} + if (result == NULL) + return NULL; + + if (strcmp (result, "enroll-retry-scan") == 0 || strcmp (result, "enroll-stage-passed") == 0) + { + if (is_swipe == false) + return TR (N_("Place your finger on the reader again")); + else + return TR (N_("Swipe your finger again")); + } + if (strcmp (result, "enroll-swipe-too-short") == 0) + return TR (N_("Swipe was too short, try again")); + if (strcmp (result, "enroll-finger-not-centered") == 0) + { + if (is_swipe) + return TR (N_("Your finger was not centered, try swiping your finger again")); + else + return TR (N_("Your finger was not centered, try touching the sensor again")); + } + if (strcmp (result, "enroll-remove-and-retry") == 0) + { + if (is_swipe) + return TR (N_("Remove your finger, and try swiping your finger again")); + else + return TR (N_("Remove your finger, and try touching the sensor again")); + } + if (strcmp (result, "enroll-too-fast") == 0) + { + if (is_swipe) + return TR (N_("Swipe was too fast, try again")); + else + return TR (N_("Finger scan was too fast, try again")); + } + if (strcmp (result, "enroll-duplicate") == 0) + return TR (N_("The fingerprint has been already enrolled. Try using another finger.")); + if (strcmp (result, "enroll-failed") == 0 || + strcmp (result, "enroll-unknown-error") == 0) + return TR (N_("An unexpected error happened during finger enrollment")); + + return NULL; +} -- GitLab From 88e63471a1015febe082c53a2c78ae2d1a6e5cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 20 Feb 2025 21:41:12 +0100 Subject: [PATCH 2/2] users/data: Update fprintd protocol files --- .../data/net.reactivated.Fprint.Device.xml | 90 +++++++++++++++++-- .../data/net.reactivated.Fprint.Manager.xml | 2 - 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/panels/system/users/data/net.reactivated.Fprint.Device.xml b/panels/system/users/data/net.reactivated.Fprint.Device.xml index 786d89c3df..809ab539be 100644 --- a/panels/system/users/data/net.reactivated.Fprint.Device.xml +++ b/panels/system/users/data/net.reactivated.Fprint.Device.xml @@ -8,12 +8,12 @@ + + ]> - value="fprint_device" /> - PolicyKit integration @@ -181,6 +181,12 @@ The user should remove their finger from the reader and retry scanning their finger, the verification is still ongoing. + + verify-too-fast + + The user's swipe or touch was too fast. The user should retry scanning their finger, the verification is still ongoing. + + verify-disconnected @@ -232,6 +238,12 @@ The user's swipe was too short. The user should retry scanning their finger, the enrollment is still ongoing. + + enroll-too-fast + + The user's swipe or touch was too short. The user should retry scanning their finger, the enrollment is still ongoing. + + enroll-finger-not-centered @@ -249,11 +261,21 @@ No further prints can be enrolled on this device, Device.EnrollStop should now be called. - Delete other prints from the device first to continue + Delete other prints from the device first to continue (e.g. from other users). Note that old prints or prints from other operating systems may be deleted automatically to resolve this error without any notification. + + enroll-duplicate + + The print has already been enrolled, Device.EnrollStop should now be called. + + The user should enroll a different finger, or delete the print that has been enrolled already. + This print may be enrolled for a different user. + Note that an old duplicate (e.g. from a previous install) will be automatically garbage collected and should not cause any issues. + + enroll-disconnected @@ -281,7 +303,6 @@ An array of strings representing the enrolled fingerprints. See Fingerprint names. - @@ -302,7 +323,6 @@ The username for whom to delete the enrolled fingerprints. See Usernames. - @@ -311,12 +331,14 @@ This call only exists for compatibility reasons, you should instead claim the device using Device.Claim and then call - DeleteEnrolledFingers2. + DeleteEnrolledFingers2 or + DeleteEnrolledFinger. if the caller lacks the appropriate PolicyKit authorization + if the fingerprint is not deleted from fprintd storage @@ -333,6 +355,34 @@ if the caller lacks the appropriate PolicyKit authorization + if the fingerprint is not deleted from fprintd storage + + + + + + + + + + A string representing the finger to delete. See + Fingerprint names. + Note that "any" is not a valid finger name for this method. + + + + + + Delete the enrolled fingerprint for the user currently claiming the device with Device.Claim. + + + + + if the caller lacks the appropriate PolicyKit authorization + if the device was not claimed + if the finger name passed is invalid + if the chosen user doesn't have the requsted fingerprint enrolled + if the fingerprint is not deleted from fprintd storage @@ -343,7 +393,6 @@ The username for whom to claim the device. See Usernames. - @@ -382,7 +431,6 @@ A string representing the finger to verify. See Fingerprint names. - @@ -475,7 +523,6 @@ Fingerprint names. Note that "any" is not a valid finger name for this method. - @@ -490,6 +537,7 @@ if the device was not claimed if the device was already being used if the finger name passed is invalid + if the finger has been already enrolled by the user if there was an internal error @@ -580,6 +628,30 @@ + + + + + + + Whether the finger is on sensor. + + + + + + + + + + + + Whether the sensor is waiting for the finger. + + + + + diff --git a/panels/system/users/data/net.reactivated.Fprint.Manager.xml b/panels/system/users/data/net.reactivated.Fprint.Manager.xml index f4a38c7003..2d0ba28655 100644 --- a/panels/system/users/data/net.reactivated.Fprint.Manager.xml +++ b/panels/system/users/data/net.reactivated.Fprint.Manager.xml @@ -5,8 +5,6 @@ ]> - -- GitLab