Select the secret key from the list of public keys
This commit is contained in:
parent
b705f385e8
commit
5a05d7eef7
1 changed files with 25 additions and 0 deletions
|
|
@ -156,6 +156,30 @@ class WeboobRepos(ReplApplication):
|
||||||
shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name))
|
shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name))
|
||||||
|
|
||||||
if r.signed:
|
if r.signed:
|
||||||
|
# Find out which keys are allowed to sign
|
||||||
|
fingerprints = [line.strip(':').split(':')[-1]
|
||||||
|
for line
|
||||||
|
in subprocess.check_output([gpg,
|
||||||
|
'--with-fingerprint', '--with-colons',
|
||||||
|
'--list-public-keys',
|
||||||
|
'--no-default-keyring',
|
||||||
|
'--keyring', os.path.realpath(krname)]).splitlines()
|
||||||
|
if line.startswith('fpr:')]
|
||||||
|
# Find out the first secret key we have that is allowed to sign
|
||||||
|
secret_fingerprint = None
|
||||||
|
for fingerprint in fingerprints:
|
||||||
|
try:
|
||||||
|
subprocess.check_output([gpg,
|
||||||
|
'--list-secret-keys', fingerprint],
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
secret_fingerprint = fingerprint
|
||||||
|
break
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
pass
|
||||||
|
if secret_fingerprint is None:
|
||||||
|
raise Exception('No suitable secret key found')
|
||||||
|
|
||||||
|
# Check if all files have an up to date signature
|
||||||
for filename in sigfiles:
|
for filename in sigfiles:
|
||||||
filepath = os.path.realpath(os.path.join(repo_path, filename))
|
filepath = os.path.realpath(os.path.join(repo_path, filename))
|
||||||
sigpath = filepath+'.sig'
|
sigpath = filepath+'.sig'
|
||||||
|
|
@ -168,6 +192,7 @@ class WeboobRepos(ReplApplication):
|
||||||
os.remove(sigpath)
|
os.remove(sigpath)
|
||||||
subprocess.check_call([gpg,
|
subprocess.check_call([gpg,
|
||||||
'--quiet',
|
'--quiet',
|
||||||
|
'--local-user', secret_fingerprint,
|
||||||
'--detach-sign',
|
'--detach-sign',
|
||||||
'--output', sigpath,
|
'--output', sigpath,
|
||||||
'--sign', filepath])
|
'--sign', filepath])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue