Skip to content

Commit

Permalink
p11-kit tool: make "no matching object/token" error user friendly
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Sep 26, 2023
1 parent 2d697bf commit 202c1c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion p11-kit/add-profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ add_profile (const char *token_str,
p11_kit_iter_begin (iter, modules);
rv = p11_kit_iter_next (iter);
if (rv != CKR_OK) {
p11_message (_("failed to find the token: %s"), p11_kit_strerror (rv));
if (rv == CKR_CANCEL)
p11_message (_("no matching token"));
else
p11_message (_("failed to find token: %s"), p11_kit_strerror (rv));
goto cleanup;
}

Expand Down
5 changes: 4 additions & 1 deletion p11-kit/delete-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ delete_object (const char *token_str)
p11_kit_iter_begin (iter, modules);
rv = p11_kit_iter_next (iter);
if (rv != CKR_OK) {
p11_message (_("failed to find the object: %s"), p11_kit_strerror (rv));
if (rv == CKR_CANCEL)
p11_message (_("no matching object"));
else
p11_message (_("failed to find object: %s"), p11_kit_strerror (rv));
goto cleanup;
}

Expand Down
5 changes: 4 additions & 1 deletion p11-kit/generate-keypair.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ generate_keypair (const char *token_str,
p11_kit_iter_begin (iter, modules);
rv = p11_kit_iter_next (iter);
if (rv != CKR_OK) {
p11_message (_("failed to find the token: %s"), p11_kit_strerror (rv));
if (rv == CKR_CANCEL)
p11_message (_("no matching token"));
else
p11_message (_("failed to find token: %s"), p11_kit_strerror (rv));
goto cleanup;
}

Expand Down

0 comments on commit 202c1c1

Please sign in to comment.