Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] emerge-webrsync: use gkeys to verify gpg signatures (bug 597918)
Date: Thu, 27 Oct 2016 17:17:14
Message-Id: 1477588602-8902-1-git-send-email-zmedico@gentoo.org
1 Use gkeys to verify gpg signatures by default. Refresh the gentoo
2 snapshot signing key before signature verification, in order to ensure
3 that the latest revocation data is available. Add an --insecure option
4 which disables gpg signature verification. Warn about man-in-the-middle
5 attacks when the --insecure option is used. Deprecate the pre-existing
6 webrsync-gpg feature since it requires manual gpg configuration.
7
8 X-Gentoo-Bug: 597918
9 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=597918
10 ---
11 bin/emerge-webrsync | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
12 man/make.conf.5 | 6 ++++--
13 2 files changed, 51 insertions(+), 6 deletions(-)
14
15 diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
16 index 9961ad8..84609e0 100755
17 --- a/bin/emerge-webrsync
18 +++ b/bin/emerge-webrsync
19 @@ -66,13 +66,24 @@ fi
20 do_verbose=0
21 do_debug=0
22 keep=false
23 +insecure=false
24 +
25 +insecure_bypass_msg() {
26 + wecho "The --insecure option can be used to bypass this step."
27 + insecure_warning_msg
28 +}
29 +
30 +insecure_warning_msg() {
31 + wecho "The --insecure option prevents detection of"
32 + wecho "man-in-the-middle attacks!"
33 +}
34
35 if has webrsync-gpg ${FEATURES} ; then
36 - WEBSYNC_VERIFY_SIGNATURE=1
37 + VERIFY_SIGNATURE_LEGACY_MODE=1
38 else
39 - WEBSYNC_VERIFY_SIGNATURE=0
40 + VERIFY_SIGNATURE_LEGACY_MODE=0
41 fi
42 -if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
43 +if [ ${VERIFY_SIGNATURE_LEGACY_MODE} != 0 -a -z "${PORTAGE_GPG_DIR}" ]; then
44 eecho "please set PORTAGE_GPG_DIR in make.conf"
45 exit 1
46 fi
47 @@ -176,7 +187,7 @@ check_file_signature() {
48 local file="$2"
49 local r=1
50
51 - if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then
52 + if [ ${VERIFY_SIGNATURE_LEGACY_MODE} != 0 ]; then
53
54 __vecho "Checking signature ..."
55
56 @@ -186,6 +197,17 @@ check_file_signature() {
57 eecho "cannot check signature: gpg binary not found"
58 exit 1
59 fi
60 + elif ! ${insecure}; then
61 + __vecho "Checking signature ..."
62 +
63 + # gkeys requires that the signature file be in the same directory
64 + # as the snapshot
65 + if [[ ${signature} != ${file}.gpgsig ]]; then
66 + # this should not happen
67 + eecho "assertion failed: ${signature} != ${file}.gpgsig"
68 + exit 1
69 + fi
70 + gkeys verify -C gentoo -n snapshot -F "${file}" && r=0
71 else
72 r=0
73 fi
74 @@ -445,6 +467,7 @@ usage() {
75
76 Options:
77 --revert=yyyymmdd Revert to snapshot
78 + --insecure Disable gpg signature verification
79 -k, --keep Keep snapshots in DISTDIR (don't delete)
80 -q, --quiet Only output errors
81 -v, --verbose Enable verbose output
82 @@ -467,6 +490,7 @@ main() {
83 local v=${arg#*=}
84 case ${arg} in
85 -h|--help) usage ;;
86 + --insecure) insecure=true ;;
87 -k|--keep) keep=true ;;
88 -q|--quiet) PORTAGE_QUIET=1 ;;
89 -v|--verbose) do_verbose=1 ;;
90 @@ -512,6 +536,25 @@ main() {
91 exit 1
92 fi
93
94 + if ${insecure}; then
95 + insecure_warning_msg
96 + elif [[ ${VERIFY_SIGNATURE_LEGACY_MODE} == 1 ]]; then
97 + wecho "FEATURES=webrsync-gpg is deprecated."
98 + wecho "By default, the new gkeys verification mode will be used"
99 + wecho "when FEATURES=webrsync-gpg is not enabled."
100 + else
101 + if ! type -P gkeys >/dev/null; then
102 + eecho "gkeys: command not found"
103 + eecho "Please try again after installing gkeys: emerge app-crypt/gkeys"
104 + insecure_bypass_msg
105 + exit 1
106 + elif ! gkeys refresh-key -C gentoo -n snapshot; then
107 + eecho "gkeys refresh-key failed"
108 + insecure_bypass_msg
109 + exit 1
110 + fi
111 + fi
112 +
113 [[ ${do_debug} -eq 1 ]] && set -x
114
115 if [[ -n ${revert_date} ]] ; then
116 diff --git a/man/make.conf.5 b/man/make.conf.5
117 index aea189e..5b809ed 100644
118 --- a/man/make.conf.5
119 +++ b/man/make.conf.5
120 @@ -1,4 +1,4 @@
121 -.TH "MAKE.CONF" "5" "Feb 2016" "Portage VERSION" "Portage"
122 +.TH "MAKE.CONF" "5" "Oct 2016" "Portage VERSION" "Portage"
123 .SH "NAME"
124 make.conf \- custom settings for Portage
125 .SH "SYNOPSIS"
126 @@ -663,7 +663,9 @@ Portage would have to waste time validating ownership for each and every sync
127 operation.
128 .TP
129 .B webrsync-gpg
130 -Enable GPG verification when using \fIemerge\-webrsync\fR.
131 +Enable legacy GPG verification mode when using \fIemerge\-webrsync\fR.
132 +This feature is deprecated. By default, the new \fBgkeys\fR(1) verification
133 +mode will be used when this feature is not enabled.
134 .TP
135 .B xattr
136 Preserve extended attributes (filesystem-stored metadata) when installing
137 --
138 2.7.4

Replies