-
Notifications
You must be signed in to change notification settings - Fork 4
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
support passphrase callback #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import ( | |
"runtime" | ||
"time" | ||
"unsafe" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
var Version string | ||
|
@@ -546,6 +548,18 @@ func (c *Context) Encrypt(recipients []*Key, flags EncryptFlag, plaintext, ciphe | |
return handleError(err) | ||
} | ||
|
||
func (c *Context) SetPassphrase(passphrase string) { | ||
logrus.Debugf("Setting GPGME passphrase callback", passphrase) | ||
callback := C.gpgme_passphrase_cb_t(C.passphrase_cb) | ||
cPass := C.CString(passphrase) | ||
C.gpgme_set_pinentry_mode(c.ctx, C.GPGME_PINENTRY_MODE_LOOPBACK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won’t compile with the GPGME 1.3.2 version this repo is currently targeting. We should almost certainly just give up on that version, and move on, sure. If I’m reading https://access.redhat.com/downloads/content/package-browser correctly, neither of the changes in this repo are necessary for RHEL ≥ 8. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I.e., to be a bit more explicit, if I’m not mistaken about the supported versions, we can just revert c/image to use the upstream proglottis/gpgme package, and deprecate/abandon this fork. |
||
C.gpgme_set_passphrase_cb(c.ctx, callback, unsafe.Pointer(cPass)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all unsafe WRT CGo rules, per proglottis#23 . There already is a To the extent actually using |
||
} | ||
|
||
func (c *Context) ClearPassphrase() { | ||
C.gpgme_set_passphrase_cb(c.ctx, nil, nil) | ||
} | ||
|
||
func (c *Context) Sign(signers []*Key, plain, sig *Data, mode SigMode) error { | ||
C.gpgme_signers_clear(c.ctx) | ||
runtime.KeepAlive(c) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The callback should probably fail if
last_was_bad
instead of trying again.