From 36f7f7a478228a64d3d51a4901a264c8f55f90bb Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Tue, 29 Oct 2019 16:26:42 +0100 Subject: [PATCH] cpp: Add support for multiple keysigs in edit * lang/cpp/src/gpgsignkeyeditinteractor.cpp (GpgSignKeyEditInteractor::setDupeOk): New. (makeTable): Add new tansitions. (SignKeyState): Add DUPE_OK Status. (GpgSignKeyEditInteractor::action): Handle DUPE_OK. (GpgSignKeyEditInteractor::Private::Private): Carry flag. -- When extended-edit is enabled this can be used to answer the "dupe_ok" query from the edit-key with yes. This is for: GnuPG-Bug-Id: T4734 --- NEWS | 7 +++++++ lang/cpp/src/gpgsignkeyeditinteractor.cpp | 15 ++++++++++++++- lang/cpp/src/gpgsignkeyeditinteractor.h | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 03641ace..5a95184a 100644 --- a/NEWS +++ b/NEWS @@ -3,8 +3,15 @@ Noteworthy changes in version 1.14.0 (unreleased) * New context flag "extended-edit" to enable expert key edit. [#4734] + * cpp: Add convenience API to obtain remarks. [#4734] + + * cpp: The sign key edit-interactor now supports multiple signatures + from the same key. [#4734] + * Interface changes relative to the 1.13.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + cpp: UserID::remark NEW. + cpp: GpgSignKeyEditInteractor::setDupeOk NEW. Noteworthy changes in version 1.13.1 (2019-06-13) diff --git a/lang/cpp/src/gpgsignkeyeditinteractor.cpp b/lang/cpp/src/gpgsignkeyeditinteractor.cpp index 295802db..d43d2f90 100644 --- a/lang/cpp/src/gpgsignkeyeditinteractor.cpp +++ b/lang/cpp/src/gpgsignkeyeditinteractor.cpp @@ -64,6 +64,7 @@ public: std::vector userIDs; std::vector::const_iterator currentId, nextId; unsigned int checkLevel; + bool dupeOk; const char *command() const { @@ -126,7 +127,8 @@ GpgSignKeyEditInteractor::Private::Private() userIDs(), currentId(), nextId(), - checkLevel(0) + checkLevel(0), + dupeOk(false) { } @@ -159,6 +161,7 @@ enum SignKeyState { SET_TRUST_REGEXP, CONFIRM, CONFIRM2, + DUPE_OK, QUIT, SAVE, ERROR = EditInteractor::ErrorState @@ -193,6 +196,7 @@ static GpgSignKeyEditInteractor_Private::TransitionMap makeTable() addEntry(SET_CHECK_LEVEL, GET_BOOL, "sign_uid.okay", CONFIRM); addEntry(SET_EXPIRE, GET_BOOL, "sign_uid.class", SET_CHECK_LEVEL); addEntry(CONFIRM, GET_BOOL, "sign_uid.local_promote_okay", CONFIRM); + addEntry(DUPE_OK, GET_BOOL, "sign_uid.okay", CONFIRM); addEntry(CONFIRM, GET_BOOL, "sign_uid.okay", CONFIRM); addEntry(CONFIRM2, GET_BOOL, "sign_uid.okay", CONFIRM); addEntry(CONFIRM, GET_LINE, "keyedit.prompt", COMMAND); @@ -205,6 +209,7 @@ static GpgSignKeyEditInteractor_Private::TransitionMap makeTable() addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "sign_uid.expire", SET_EXPIRE); addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "sign_uid.class", SET_CHECK_LEVEL); addEntry(UIDS_LIST_SEPARATELY_DONE, GET_BOOL, "sign_uid.okay", CONFIRM); + addEntry(UIDS_LIST_SEPARATELY_DONE, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK); addEntry(CONFIRM, GET_LINE, "keyedit.prompt", QUIT); addEntry(ERROR, GET_LINE, "keyedit.prompt", QUIT); addEntry(QUIT, GET_BOOL, "keyedit.save.okay", SAVE); @@ -236,6 +241,8 @@ const char *GpgSignKeyEditInteractor::action(Error &err) const return nullptr; case SET_CHECK_LEVEL: return check_level_strings[d->checkLevel]; + case DUPE_OK: + return answer(d->dupeOk); case CONFIRM2: case CONFIRM: return answer(true); @@ -326,3 +333,9 @@ void GpgSignKeyEditInteractor::setSigningOptions(int options) assert(!d->started); d->options = options; } + +void GpgSignKeyEditInteractor::setDupeOk(bool value) +{ + assert(!d->started); + d->dupeOk = value; +} diff --git a/lang/cpp/src/gpgsignkeyeditinteractor.h b/lang/cpp/src/gpgsignkeyeditinteractor.h index 34b1f064..bb5320a2 100644 --- a/lang/cpp/src/gpgsignkeyeditinteractor.h +++ b/lang/cpp/src/gpgsignkeyeditinteractor.h @@ -52,6 +52,11 @@ public: void setUserIDsToSign(const std::vector &userIDsToSign); void setSigningOptions(int options); + /* Set this if it is ok to overwrite an existing signature. In that + * case the context has to have the flag "extended-edit" set to 1 through + * Context::setFlag before calling edit.*/ + void setDupeOk(bool value); + private: const char *action(Error &err) const override; unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;