summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorDaniel McGregor <daniel.mcgregor@vecima.com>2021-10-12 22:04:56 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 22:52:31 +0100
commit652fdf8719ba5cf2c486bf3d19904b5140dbd0d1 (patch)
tree9c45fddc25bd58a5cfbb56c1592a96d84abce705 /meta/lib
parent9a7bc68135c8eb2ca2acda36f5cd5d21edd574d6 (diff)
downloadpoky-652fdf8719ba5cf2c486bf3d19904b5140dbd0d1.tar.gz
sstate: Allow validation of sstate singatures against list of keys
Allow a user to validate sstate objects against a list of keys, instead of just any known key in the user's keychain. (From OE-Core rev: 52ba0c5e6e2e3d5d01dc3f01404f0ab1bb29b3b5) Signed-off-by: Daniel McGregor <daniel.mcgregor@vecima.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/gpg_sign.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 492f096eaa..1bce6cb792 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -109,16 +109,33 @@ class LocalSigner(object):
109 bb.fatal("Could not get gpg version: %s" % e) 109 bb.fatal("Could not get gpg version: %s" % e)
110 110
111 111
112 def verify(self, sig_file): 112 def verify(self, sig_file, valid_sigs = ''):
113 """Verify signature""" 113 """Verify signature"""
114 cmd = self.gpg_cmd + ["--verify", "--no-permission-warning"] 114 cmd = self.gpg_cmd + ["--verify", "--no-permission-warning", "--status-fd", "1"]
115 if self.gpg_path: 115 if self.gpg_path:
116 cmd += ["--homedir", self.gpg_path] 116 cmd += ["--homedir", self.gpg_path]
117 117
118 cmd += [sig_file] 118 cmd += [sig_file]
119 status = subprocess.call(cmd) 119 status = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
120 ret = False if status else True 120 # Valid if any key matches if unspecified
121 return ret 121 if not valid_sigs:
122 ret = False if status.returncode else True
123 return ret
124
125 import re
126 goodsigs = []
127 sigre = re.compile(r'^\[GNUPG:\] GOODSIG (\S+)\s(.*)$')
128 for l in status.stdout.decode("utf-8").splitlines():
129 s = sigre.match(l)
130 if s:
131 goodsigs += [s.group(1)]
132
133 for sig in valid_sigs.split():
134 if sig in goodsigs:
135 return True
136 if len(goodsigs):
137 bb.warn('No accepted signatures found. Good signatures found: %s.' % ' '.join(goodsigs))
138 return False
122 139
123 140
124def get_signer(d, backend): 141def get_signer(d, backend):