|
5 | 5 |
|
6 | 6 | export LC_ALL=C
|
7 | 7 | INPUT=$(cat /dev/stdin)
|
8 |
| -VALID=false |
9 |
| -REVSIG=false |
10 |
| -IFS=' |
11 |
| -' |
12 | 8 | if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
|
13 |
| - GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)" |
| 9 | + printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null |
| 10 | + exit $? |
14 | 11 | else
|
15 | 12 | # Note how we've disabled SHA1 with the --weak-digest option, disabling
|
16 | 13 | # signatures - including selfsigs - that use SHA1. While you might think that
|
|
20 | 17 | # an attacker could construct a pull-req that results in a commit object that
|
21 | 18 | # they've created a collision for. Not the most likely attack, but preventing
|
22 | 19 | # it is pretty easy so we do so as a "belt-and-suspenders" measure.
|
23 |
| - GPG_RES="" |
24 | 20 | for LINE in $(gpg --version); do
|
25 | 21 | case "$LINE" in
|
26 | 22 | "gpg (GnuPG) 1.4.1"*|"gpg (GnuPG) 2.0."*)
|
27 | 23 | echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev/stderr
|
28 |
| - GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)" |
| 24 | + printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null |
| 25 | + exit $? |
29 | 26 | ;;
|
30 | 27 | # We assume if you're running 2.1+, you're probably running 2.1.10+
|
31 | 28 | # gpg will fail otherwise
|
32 | 29 | # We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
|
33 | 30 | # gpg will fail otherwise
|
34 | 31 | esac
|
35 | 32 | done
|
36 |
| - [ "$GPG_RES" = "" ] && GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)" |
37 |
| -fi |
38 |
| -for LINE in $GPG_RES; do |
39 |
| - case "$LINE" in |
40 |
| - "[GNUPG:] VALIDSIG "*) |
41 |
| - while read KEY; do |
42 |
| - [ "${LINE#?GNUPG:? VALIDSIG * * * * * * * * * }" = "$KEY" ] && VALID=true |
43 |
| - done < ./contrib/verify-commits/trusted-keys |
44 |
| - ;; |
45 |
| - "[GNUPG:] REVKEYSIG "*) |
46 |
| - [ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1 |
47 |
| - REVSIG=true |
48 |
| - GOODREVSIG="[GNUPG:] GOODSIG ${LINE#* * *}" |
49 |
| - ;; |
50 |
| - "[GNUPG:] EXPKEYSIG "*) |
51 |
| - [ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1 |
52 |
| - REVSIG=true |
53 |
| - GOODREVSIG="[GNUPG:] GOODSIG ${LINE#* * *}" |
54 |
| - ;; |
55 |
| - esac |
56 |
| -done |
57 |
| -if ! $VALID; then |
58 |
| - exit 1 |
59 |
| -fi |
60 |
| -if $VALID && $REVSIG; then |
61 |
| - printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null | grep "^\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)" |
62 |
| - echo "$GOODREVSIG" |
63 |
| -else |
64 |
| - printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null |
| 33 | + printf '%s\n' "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null |
| 34 | + exit $? |
65 | 35 | fi
|
0 commit comments