Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to delete secret key without confirmation dialog #193

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

manu3569
Copy link
Contributor

@manu3569 manu3569 commented Oct 1, 2024

Add Option to Delete GPG Key Without Confirmation Dialog

Summary

This PR introduces the ability to delete GPG keys without prompting for confirmation. This is achieved by leveraging the new gpgme_op_delete_ext function introduced in GPGME 1.9.1. Additionally, this update introduces two flags:

  • DELETE_ALLOW_SECRET: Allows deletion of secret keys alongside public ones.
  • DELETE_FORCE: Forces the deletion of keys without the confirmation dialog.

Changes

  • New Method: gpgme_op_delete_ext:

    • Introduced in the C extension (gpgme_n.c) to allow deletion of GPG keys using additional flags.
    • Uses the GPGME gpgme_op_delete_ext function which allows the passing of flags (GPGME_DELETE_ALLOW_SECRET, GPGME_DELETE_FORCE).
  • Constants:

    • Added constants for GPGME_DELETE_ALLOW_SECRET and GPGME_DELETE_FORCE to expose these new flags to the Ruby interface.
  • Ruby Methods:

    • Updated GPGME::Ctx#delete_key and GPGME::Key#delete! methods to accept an additional force parameter, which suppresses the confirmation dialog when deleting keys. They default to false to ensure a non-breaking change.

Usage Example:

# Delete a secret key with forced deletion (no confirmation prompt)
key.delete!(true, true)

Compatibility:

  • This update requires GPGME version 1.9.1 or later due to the usage of the gpgme_op_delete_ext method.

Let me know if you'd like to add or modify anything! Any pointers regarding writing a test to detect the dialog?

Copy link
Owner

@ueno ueno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

@ueno ueno merged commit 6c22a5b into ueno:master Oct 2, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants