core/tools: cleanly shut down keyctl-proxy after signing

pull/785/head
matejcik 5 years ago committed by Pavol Rusnak
parent e9c68d7397
commit ccacada37c
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -90,6 +90,9 @@ def process_remote_signers(fw, addrs: List[str]) -> Tuple[int, List[bytes]]:
sigs.append(sig)
click.echo("OK")
for _, proxy in proxies:
proxy.finish()
# compute global signature
return sigmask, cosi.combine_sig(global_R, sigs)

@ -57,7 +57,10 @@ def make_commit(name, index, digest):
@Pyro4.expose
class KeyctlProxy:
def __init__(self, image_type, digest: bytes, commit: Tuple[bytes, bytes]) -> None:
def __init__(
self, daemon, image_type, digest: bytes, commit: Tuple[bytes, bytes]
) -> None:
self.daemon = daemon
self.name = image_type.NAME
self.address_n = parse_path(PATH.format(image_type.BIP32_INDEX))
self.digest = digest
@ -88,6 +91,11 @@ class KeyctlProxy:
traceback.print_exc()
click.echo("Trying again ...")
@Pyro4.oneway
def finish(self):
click.echo("Done! \\(^o^)/")
self.daemon.shutdown()
@click.command()
@click.option(
@ -125,7 +133,7 @@ def cli(ipaddr, fw_file, fw_or_type, digest):
break
daemon = Pyro4.Daemon(host=ipaddr, port=PORT)
proxy = KeyctlProxy(fw_or_type, digest, (pubkey, R))
proxy = KeyctlProxy(daemon, fw_or_type, digest, (pubkey, R))
uri = daemon.register(proxy, "keyctl")
click.echo(f"keyctl-proxy running at URI: {uri}")
click.echo("Press Ctrl+C to abort.")

Loading…
Cancel
Save