Skip to content

Commit f7d4a25

Browse files
TheBlueMattpetertodd
authored andcommitted
Make verify-commits POSIX-compliant
1 parent 7771aa5 commit f7d4a25

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

contrib/verify-commits/gpg.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/sh
2-
INPUT=$(</dev/stdin)
2+
INPUT=$(cat /dev/stdin)
33
VALID=false
44
REVSIG=false
5-
IFS=$'\n'
5+
IFS='
6+
'
67
for LINE in $(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null); do
78
case "$LINE" in
89
"[GNUPG:] VALIDSIG "*)
@@ -13,10 +14,9 @@ for LINE in $(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null); do
1314
"[GNUPG:] REVKEYSIG "*)
1415
[ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
1516
while read KEY; do
16-
case "$LINE" in "[GNUPG:] REVKEYSIG ${KEY:24:40} "*)
17+
case "$LINE" in "[GNUPG:] REVKEYSIG ${KEY#????????????????????????} "*)
1718
REVSIG=true
18-
GOODREVSIG="[GNUPG:] GOODSIG ${KEY:24:40} "
19-
;;
19+
GOODREVSIG="[GNUPG:] GOODSIG ${KEY#????????????????????????} "
2020
esac
2121
done < ./contrib/verify-commits/trusted-keys
2222
;;

contrib/verify-commits/verify-commits.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
#!/bin/sh
2+
# Not technically POSIX-compliant due to use of "local", but almost every
3+
# shell anyone uses today supports it, so its probably fine
24

35
DIR=$(dirname "$0")
46

57
echo "Please verify all commits in the following list are not evil:"
68
git log "$DIR"
79

810
VERIFIED_ROOT=$(cat "${DIR}/trusted-git-root")
9-
10-
IS_REVSIG_ALLOWED () {
11-
while read LINE; do
12-
[ "$LINE" = "$1" ] && return 0
13-
done < "${DIR}/allow-revsig-commits"
14-
return 1
15-
}
11+
REVSIG_ALLOWED=$(cat "${DIR}/allow-revsig-commits")
1612

1713
HAVE_FAILED=false
1814
IS_SIGNED () {
1915
if [ $1 = $VERIFIED_ROOT ]; then
2016
return 0;
2117
fi
22-
if IS_REVSIG_ALLOWED "$1"; then
18+
if [ "${REVSIG_ALLOWED#*$1}" != "$REVSIG_ALLOWED" ]; then
2319
export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG=1
2420
else
2521
export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG=0
2622
fi
2723
if ! git -c "gpg.program=${DIR}/gpg.sh" verify-commit $1 > /dev/null 2>&1; then
2824
return 1;
2925
fi
30-
local PARENTS=$(git show -s --format=format:%P $1)
26+
local PARENTS
27+
PARENTS=$(git show -s --format=format:%P $1)
3128
for PARENT in $PARENTS; do
3229
if IS_SIGNED $PARENT > /dev/null; then
3330
return 0;

0 commit comments

Comments
 (0)