merge/pull Check for untrusted good GPG signatures
PATCH v2 3/4 merge/pull Check for untrusted good GPG signatures
When --verify-signatures is specified, abort the merge in case a good GPG signature from an untrusted key is encountered.
Signed-off-by Sebastian Götte <[email protected]>
--- builtin/merge.c | 2 ++ commit.c | 1 + commit.h | 4 ++-- gpg-interface.h | 2 +- t/lib-gpg/pubring.gpg | Bin 1164 -> 2359 bytes t/lib-gpg/random_seed | Bin 600 -> 600 bytes t/lib-gpg/secring.gpg | Bin 1237 -> 3734 bytes t/lib-gpg/trustdb.gpg | Bin 1280 -> 1360 bytes t/t7612-merge-verify-signatures.sh | 9 +++++++++ 9 files changed, 15 insertions(+), 3 deletions(-)
builtin/merge.c +2 -0
@@ -1251,6 +1251,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)if (verbosity >=0 )printf (_ ("Commit %s has a good GPG signature by %s\n" ), hex, signature.signer);break ; +case 'U' : +die (_ ("Commmit %s has a good GPG signature allegedly by %s, albeit from an untrusted key." ), hex, signature.signer);case 'B' :die (_ ("Commmit %s has a bad GPG signature allegedly by %s." ), hex, signature.signer);default :/* 'N' */
commit.c +1 -0
@@ -1027,6 +1027,7 @@ static struct {char result;const char *check; } signature_check[] = { + { 'U', ": WARNING: This key is not certified with a trusted signature!" }, { 'G', ": Good signature from " }, { 'B', ": BAD signature from " }, };
commit.h +2 -2
@@ -233,8 +233,8 @@ extern void print_commit_list(struct commit_list *list,/* * Check the signature of the given commit. The result of the check is stored in -* sig->check_result, 'G' for a good signature, 'B' for a bad signature and 'N' -* for no signature at all. +* sig->check_result, 'G' for a good signature, 'U' for a good signature from an +* untrusted signer, 'B' for a bad signature and 'N' for no signature at all. * This may allocate memory for sig->gpg_output and sig->signer. */ extern void check_commit_signature (const struct commit * commit,struct signature *sig);
gpg-interface.h +1 -1
@@ -3,7 +3,7 @@struct signature {char *gpg_output; -char check_result;/* 0 (not checked), N (checked but no further result), G (good) or B (bad) */ +char check_result;/* 0 (not checked), N (checked but no further result), U (untrusted, good), G (good) or B (bad) */ char *signer; };
t/lib-gpg/pubring.gpg binary +0 -0
t/lib-gpg/random_seed binary +0 -0
t/lib-gpg/secring.gpg binary +0 -0
t/lib-gpg/trustdb.gpg binary +0 -0
t/t7612-merge-verify-signatures.sh +9 -0
@@ -27,6 +27,10 @@ test_expect_success GPG 'create signed commits' ' git hash-object -w -t commit forged >forged.commit && git checkout initial && + git checkout -b side-untrusted && + echo 3 >baz && git add baz && + test_tick && git commit -SB7227189 -m "untrusted on side" + git checkout master '
@@ -40,6 +44,11 @@ test_expect_success GPG 'merge commit with bad signature with verification' ' grep "has a bad GPG signature" mergeerror ' +test_expect_success GPG 'merge commit with untrusted signature with verification' ' + test_must_fail git merge --ff-only --verify-signatures side-untrusted 2> mergeerror && + grep "from an untrusted key" mergeerror +' + test_expect_success GPG 'merge signed commit with verification' ' git merge -v --ff-only --verify-signatures side-signed > mergeoutput && grep "has a good GPG signature" mergeoutput
Signature · 1 line
1.8.1.5