cpp: Return actual error if revocation fails
* lang/cpp/src/editinteractor.cpp, lang/cpp/src/editinteractor.h (EditInteractor::parseStatusError): New. * lang/cpp/src/gpgrevokekeyeditinteractor.cpp (GpgRevokeKeyEditInteractor::Private::nextState): Handle status error. -- With this change the interactor returns a proper error like "Bad Passphrase" or "Empty Passphrase" instead of an unspecific "General Error" if a status error occurred. GnuPG-bug-id: 5904
This commit is contained in:
parent
c965b45bcd
commit
db532eca8e
@ -29,6 +29,7 @@
|
|||||||
#include "editinteractor.h"
|
#include "editinteractor.h"
|
||||||
#include "callbacks.h"
|
#include "callbacks.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
@ -256,6 +257,20 @@ void EditInteractor::setDebugChannel(std::FILE *debug)
|
|||||||
d->debug = debug;
|
d->debug = debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GpgME::Error EditInteractor::parseStatusError(const char *args)
|
||||||
|
{
|
||||||
|
Error err;
|
||||||
|
|
||||||
|
const auto fields = split(args, ' ');
|
||||||
|
if (fields.size() >= 2) {
|
||||||
|
err = Error{static_cast<unsigned int>(std::stoul(fields[1]))};
|
||||||
|
} else {
|
||||||
|
err = Error::fromCode(GPG_ERR_GENERAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *const status_strings[] = {
|
static const char *const status_strings[] = {
|
||||||
"EOF",
|
"EOF",
|
||||||
/* mkstatus processing starts here */
|
/* mkstatus processing starts here */
|
||||||
|
@ -60,6 +60,9 @@ public:
|
|||||||
|
|
||||||
void setDebugChannel(std::FILE *file);
|
void setDebugChannel(std::FILE *file);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Error parseStatusError(const char *args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
Private *const d;
|
Private *const d;
|
||||||
|
@ -116,6 +116,10 @@ unsigned int GpgRevokeKeyEditInteractor::Private::nextState(unsigned int status,
|
|||||||
return q->state();
|
return q->state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status == GPGME_STATUS_ERROR) {
|
||||||
|
err = q->parseStatusError(args);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
switch (const auto state = q->state()) {
|
switch (const auto state = q->state()) {
|
||||||
case START:
|
case START:
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
if (status == GPGME_STATUS_GET_LINE &&
|
||||||
|
Loading…
Reference in New Issue
Block a user