device: Return more specific error if we failed cleaning up the storage

This commit is contained in:
Marco Trevisan (Treviño)
2020-12-17 01:37:54 +01:00
parent 3fa0f232ef
commit e0a643f3b9
3 changed files with 20 additions and 9 deletions

View File

@ -1919,10 +1919,13 @@ delete_enrolled_fingers (FprintDevice *rdev,
{
if ((r = store.print_data_delete (priv->dev, finger, user)) != 0)
{
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_INTERNAL,
"Impossible to delete fingerprint reference "
"got error: %d", r);
return FALSE;
if (user_has_print_enrolled (rdev, user, finger))
{
g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_PRINTS_NOT_DELETED,
"Impossible to delete fingerprint reference "
"got error: %d", r);
return FALSE;
}
}
}
else
@ -1936,10 +1939,13 @@ delete_enrolled_fingers (FprintDevice *rdev,
if (local_error)
continue;
g_set_error (&local_error, FPRINT_ERROR, FPRINT_ERROR_INTERNAL,
"Impossible to delete fingerprint reference "
"got error: %d", r);
/* Do not return yet, at least try to remove the remaining prints */
if (user_has_print_enrolled (rdev, user, i))
{
g_set_error (&local_error, FPRINT_ERROR, FPRINT_ERROR_PRINTS_NOT_DELETED,
"Impossible to delete fingerprint reference "
"got error: %d", r);
/* Do not return yet, at least try to remove the remaining prints */
}
}
}

View File

@ -8,6 +8,7 @@
<!ENTITY ERROR_NO_ENROLLED_PRINTS "net.reactivated.Fprint.Error.NoEnrolledPrints">
<!ENTITY ERROR_NO_ACTION_IN_PROGRESS "net.reactivated.Fprint.Error.NoActionInProgress">
<!ENTITY ERROR_INVALID_FINGERNAME "net.reactivated.Fprint.Error.InvalidFingername">
<!ENTITY ERROR_PRINTS_NOT_DELETED "net.reactivated.Fprint.Error.PrintsNotDeleted">
]>
<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
@ -314,6 +315,7 @@
<doc:errors>
<doc:error name="&ERROR_PERMISSION_DENIED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
<doc:error name="&ERROR_PRINTS_NOT_DELETED;">if the fingerprint is not deleted from fprintd storage</doc:error>
</doc:errors>
</doc:doc>
</method>
@ -330,6 +332,7 @@
<doc:errors>
<doc:error name="&ERROR_PERMISSION_DENIED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
<doc:error name="&ERROR_PRINTS_NOT_DELETED;">if the fingerprint is not deleted from fprintd storage</doc:error>
</doc:errors>
</doc:doc>
</method>
@ -356,7 +359,7 @@
<doc:error name="&ERROR_CLAIM_DEVICE;">if the device was not claimed</doc:error>
<doc:error name="&ERROR_INVALID_FINGERNAME;">if the finger name passed is invalid</doc:error>
<doc:error name="&ERROR_NO_ENROLLED_PRINTS;">if the chosen user doesn't have the requsted fingerprint enrolled</doc:error>
<doc:error name="&ERROR_INTERNAL;">if there was an internal error</doc:error>
<doc:error name="&ERROR_PRINTS_NOT_DELETED;">if the fingerprint is not deleted from fprintd storage</doc:error>
</doc:errors>
</doc:doc>
</method>

View File

@ -51,6 +51,8 @@ typedef enum {
FPRINT_ERROR_INVALID_FINGERNAME, /*< nick=net.reactivated.Fprint.Error.InvalidFingername >*/
/* device does not exist */
FPRINT_ERROR_NO_SUCH_DEVICE, /*< nick=net.reactivated.Fprint.Error.NoSuchDevice >*/
/* Prints cannot be deleted from the fprintd storage */
FPRINT_ERROR_PRINTS_NOT_DELETED, /*< nick=net.reactivated.Fprint.Error.PrintsNotDeleted >*/
} FprintError;
/* Enum of possible permissions, orders and nick matter here: