From eedaaf70167f5dd7d8438235139b57527d3a961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 14 Sep 2022 10:41:38 +0200 Subject: [PATCH] cpp: Reject signing expired keys * lang/cpp/src/gpgsignkeyeditinteractor.cpp (enum SignKeyState): Add new state REJECT_SIGN_EXPIRED. (makeTable): Add entries for new state to transition map. (GpgSignKeyEditInteractor::action): Handle new state. -- With this change the edit interactor aborts the key signing operation with a "key expired" error instead of with a "general error". GnuPG-bug-id: 6155 --- lang/cpp/src/gpgsignkeyeditinteractor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lang/cpp/src/gpgsignkeyeditinteractor.cpp b/lang/cpp/src/gpgsignkeyeditinteractor.cpp index 4b5d2749..1c8af148 100644 --- a/lang/cpp/src/gpgsignkeyeditinteractor.cpp +++ b/lang/cpp/src/gpgsignkeyeditinteractor.cpp @@ -170,6 +170,7 @@ enum SignKeyState { CONFIRM2, DUPE_OK, DUPE_OK2, + REJECT_SIGN_EXPIRED, QUIT, SAVE, ERROR = EditInteractor::ErrorState @@ -193,6 +194,7 @@ static GpgSignKeyEditInteractor_Private::TransitionMap makeTable() #define addEntry( s1, status, str, s2 ) tab[std::make_tuple( s1, status, str)] = s2 addEntry(START, GET_LINE, "keyedit.prompt", COMMAND); addEntry(COMMAND, GET_BOOL, "keyedit.sign_all.okay", UIDS_ANSWER_SIGN_ALL); + addEntry(COMMAND, GET_BOOL, "sign_uid.expired_okay", REJECT_SIGN_EXPIRED); addEntry(COMMAND, GET_BOOL, "sign_uid.okay", CONFIRM); addEntry(COMMAND, GET_BOOL, "sign_uid.local_promote_okay", CONFIRM2); addEntry(COMMAND, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK); @@ -228,6 +230,7 @@ static GpgSignKeyEditInteractor_Private::TransitionMap makeTable() addEntry(DUPE_OK, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK2); addEntry(DUPE_OK2, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK); addEntry(CONFIRM, GET_LINE, "keyedit.prompt", QUIT); + addEntry(REJECT_SIGN_EXPIRED, GET_LINE, "keyedit.prompt", QUIT); addEntry(ERROR, GET_LINE, "keyedit.prompt", QUIT); addEntry(QUIT, GET_BOOL, "keyedit.save.okay", SAVE); #undef addEntry @@ -263,6 +266,9 @@ const char *GpgSignKeyEditInteractor::action(Error &err) const case CONFIRM2: case CONFIRM: return answer(true); + case REJECT_SIGN_EXPIRED: + err = Error::fromCode(GPG_ERR_KEY_EXPIRED); + return answer(false); case QUIT: return "quit"; case SAVE: