AGWA / git-crypt

Transparent file encryption in git
https://www.agwa.name/projects/git-crypt/
GNU General Public License v3.0
8.32k stars 479 forks source link

Allow GPG to fail one some keys #88

Closed cao closed 7 years ago

cao commented 8 years ago

If multiple GPG keys exist that could be used to decrypt the repository key, but GPG fails on one of them (e.g., the first one because it is stored on a SmartCard that is not plugged in), then no other keys are used to try to decrypt it, failing entirely instead of trying the additional GPG keys.

The code below is a quick fix on my part and is primarily meant to point to the bug. It depends on the optional feature that is part of C++17, but implemented in all major compilers already (tested with clang++ 3.8 and g++ 6.1.1). It is the canonical way to handle optional data (which a GPG error should be). Currently, it returns the last GPG error instead of the first or all of them. Returning the last error should be okay since the order in which keys are being returned by GPG does not appear to be sorted in any way.

AGWA commented 8 years ago

Thanks for the PR! I agree this is a problem and your patch is more-or-the-less the right way to solve it. However, C++17 is too bleeding edge. Could you rewrite your patch to use std::current_exception and std::rethrow_exception instead? See http://en.cppreference.com/w/cpp/error/exception_ptr

cao commented 8 years ago

Done! Switched to current_exception and rethrow_exception instead.

cao commented 7 years ago

Any news on possibly getting this merged? :-)

cao commented 7 years ago

Ping? :-)

expertcoder commented 7 years ago

I am looking for this same feature.

AGWA commented 7 years ago

Thank you @cao and very sorry about the delay.