SOURCES: kdepim-kmail-gpgme_passphrase_cb.patch (NEW) - Fixes kmai...
matkor
matkor at pld-linux.org
Sun Sep 2 18:00:07 CEST 2007
Author: matkor Date: Sun Sep 2 16:00:07 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- Fixes kmail failing to decrypt selfencrypted mails withoug gpg agent:
gpgme_op_decrypt_verify() returned this error code: 117440523
See http://www.nabble.com/KMail-and-"encrypt-to-self"-issue-t4247507.html
---- Files affected:
SOURCES:
kdepim-kmail-gpgme_passphrase_cb.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/kdepim-kmail-gpgme_passphrase_cb.patch
diff -u /dev/null SOURCES/kdepim-kmail-gpgme_passphrase_cb.patch:1.1
--- /dev/null Sun Sep 2 18:00:07 2007
+++ SOURCES/kdepim-kmail-gpgme_passphrase_cb.patch Sun Sep 2 18:00:02 2007
@@ -0,0 +1,97 @@
+--- kdepim-3.5.7/certmanager/lib/cryptplug.cpp.kmail-gpgme_passphrase_cb 2007-09-02 15:52:10.000000000 +0200
++++ kdepim-3.5.7/certmanager/lib/cryptplug.cpp 2007-09-02 15:56:56.000000000 +0200
+@@ -4,9 +4,9 @@
+ GPGMEPLUG - an GPGME based cryptography plug-in following
+ the common CRYPTPLUG specification.
+
+- Copyright (C) 2001 by Klarälvdalens Datakonsult AB
++ Copyright (C) 2001 by Klar�vdalens Datakonsult AB
+ Copyright (C) 2002 g10 Code GmbH
+- Copyright (C) 2004 Klarälvdalens Datakonsult AB
++ Copyright (C) 2004 Klar�vdalens Datakonsult AB
+
+ GPGMEPLUG is free software; you can redistribute it and/or modify
+ it under the terms of GNU General Public License as published by
+@@ -34,6 +34,10 @@
+ #include <gpgmepp/data.h>
+ #include <gpgmepp/importresult.h>
+
++#include "ui/passphrasedialog.h"
++#include <klocale.h>
++#include <kstandarddirs.h>
++
+ /*! \file gpgmeplug.c
+ \brief GPGME implementation of CRYPTPLUG following the
+ specification located in common API header cryptplug.h.
+@@ -263,6 +267,45 @@
+ return p;
+ }
+
++gpgme_error_t passphrase_cb(void *HOOK, const char *UID_HINT,
++ const char *PASSPHRASE_INFO,
++ int PREV_WAS_BAD, int FD) {
++
++ QString msg = PREV_WAS_BAD ?
++ i18n( "You need a passphrase to unlock the secret key for user:<br/> %1 (retry)" ) :
++ i18n( "You need a passphrase to unlock the secret key for user:<br/> %1" );
++ msg = msg.arg( QString::fromUtf8( UID_HINT ) ) + "<br/><br/>";
++ msg.prepend( "<qt>" );
++ msg += i18n( "This dialog will reappear every time the passphrase is needed. For a more secure solution that also allows caching the passphrase, use gpg-agent." ) + "<br/>";
++ const QString gpgAgent = KStandardDirs::findExe( "gpg-agent" );
++ if ( !gpgAgent.isEmpty() ) {
++ msg += i18n( "gpg-agent was found in %1, but does not appear to be running." )
++ .arg( gpgAgent );
++ } else {
++ msg += i18n( "gpg-agent is part of gnupg-%1, which you can download from %2" )
++ .arg( "1.9" )
++ .arg( "http://www.gnupg.org/download" ); // add #gnupg2 if you can make this a real link
++ }
++ msg += "<br/>";
++ msg += i18n( "For information on how to set up gpg-agent, see %1" )
++ .arg( "http://kmail.kde.org/kmail-pgpmime-howto.html" );
++ msg += "<br/><br/>";
++ msg += i18n( "Enter passphrase:" );
++ Kleo::PassphraseDialog dlg( msg, i18n("Passphrase Dialog") );
++ if ( dlg.exec() != QDialog::Accepted ) {
++ return GPG_ERR_CANCELED;
++ }
++
++ if (dlg.passphrase()) {
++ write(FD, dlg.passphrase(), strlen(dlg.passphrase()));
++ write(FD, "\n", 1);
++ return GPG_ERR_NO_ERROR;
++ }
++ else {
++ return GPG_ERR_BAD_PASSPHRASE;
++ }
++}
++
+
+ CryptPlug::CryptPlug() {
+ }
+@@ -350,7 +393,11 @@
+ 1 );
+
+ gpgme_data_new( &gPlaintext );
+-
++ if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP)
++ gpgme_set_passphrase_cb(ctx, passphrase_cb, NULL);
++ else
++ gpgme_set_passphrase_cb(ctx, NULL, NULL);
++
+ err = gpgme_op_decrypt( ctx, gCiphertext, gPlaintext );
+ if( err ) {
+ fprintf( stderr, "\ngpgme_op_decrypt() returned this error code: %i\n\n", err );
+@@ -1072,6 +1119,12 @@
+
+ gpgme_data_new( &gPlaintext );
+
++ if (gpgme_get_protocol(ctx) == GPGME_PROTOCOL_OpenPGP)
++ gpgme_set_passphrase_cb(ctx, passphrase_cb, NULL);
++ else
++ gpgme_set_passphrase_cb(ctx, NULL, NULL);
++
++
+ err = gpgme_op_decrypt_verify( ctx, gCiphertext, gPlaintext );
+ gpgme_data_release( gCiphertext );
+
================================================================
More information about the pld-cvs-commit
mailing list