Initialize passphrase cache at UI c-tor

This commit is contained in:
Roman Zeyde
2020-04-29 21:59:17 +03:00
parent 8c22e5030b
commit 52d840cbbb
3 changed files with 2 additions and 7 deletions

View File

@@ -28,7 +28,8 @@ class UI:
default_pinentry) default_pinentry)
self.options_getter = create_default_options_getter() self.options_getter = create_default_options_getter()
self.device_name = device_type.__name__ self.device_name = device_type.__name__
self.cached_passphrase_ack = None self.cached_passphrase_ack = util.ExpiringCache(
seconds=float(config.get('cache_expiry_seconds', 'inf')))
def get_pin(self, _code=None): def get_pin(self, _code=None):
"""Ask the user for (scrambled) PIN.""" """Ask the user for (scrambled) PIN."""

View File

@@ -249,8 +249,6 @@ def run_agent(device_type):
pubkey_bytes = keyring.export_public_keys(env=env) pubkey_bytes = keyring.export_public_keys(env=env)
device_type.ui = device.ui.UI(device_type=device_type, device_type.ui = device.ui.UI(device_type=device_type,
config=vars(args)) config=vars(args))
device_type.ui.cached_passphrase_ack = util.ExpiringCache(
seconds=float(args.cache_expiry_seconds))
handler = agent.Handler(device=device_type(), handler = agent.Handler(device=device_type(),
pubkey_bytes=pubkey_bytes) pubkey_bytes=pubkey_bytes)
@@ -318,7 +316,5 @@ def main(device_type):
args = parser.parse_args() args = parser.parse_args()
device_type.ui = device.ui.UI(device_type=device_type, config=vars(args)) device_type.ui = device.ui.UI(device_type=device_type, config=vars(args))
device_type.ui.cached_passphrase_ack = util.ExpiringCache(
seconds=float(args.cache_expiry_seconds))
return args.func(device_type=device_type, args=args) return args.func(device_type=device_type, args=args)

View File

@@ -274,8 +274,6 @@ def main(device_type):
# override default PIN/passphrase entry tools (relevant for TREZOR/Keepkey): # override default PIN/passphrase entry tools (relevant for TREZOR/Keepkey):
device_type.ui = device.ui.UI(device_type=device_type, config=vars(args)) device_type.ui = device.ui.UI(device_type=device_type, config=vars(args))
device_type.ui.cached_passphrase_ack = util.ExpiringCache(
args.cache_expiry_seconds)
conn = JustInTimeConnection( conn = JustInTimeConnection(
conn_factory=lambda: client.Client(device_type()), conn_factory=lambda: client.Client(device_type()),