From a8a7af4b7455f5eb5e2db796701e2b4351e6b610 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 31 May 2023 15:39:55 +0200 Subject: [PATCH] Handle missing identity file in rncp. Fixes #317. --- RNS/Identity.py | 2 +- RNS/Utilities/rncp.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RNS/Identity.py b/RNS/Identity.py index 763bc24..89b0457 100644 --- a/RNS/Identity.py +++ b/RNS/Identity.py @@ -452,7 +452,7 @@ class Identity: return False except Exception as e: RNS.log("Error while loading identity from "+str(path), RNS.LOG_ERROR) - RNS.log("The contained exception was: "+str(e)) + RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR) def get_salt(self): return self.hash diff --git a/RNS/Utilities/rncp.py b/RNS/Utilities/rncp.py index b4de93c..37077d2 100644 --- a/RNS/Utilities/rncp.py +++ b/RNS/Utilities/rncp.py @@ -226,7 +226,12 @@ def send(configdir, verbosity = 0, quietness = 0, destination = None, file = Non identity_path = RNS.Reticulum.identitypath+"/"+APP_NAME if os.path.isfile(identity_path): - identity = RNS.Identity.from_file(identity_path) + identity = RNS.Identity.from_file(identity_path) + if identity == None: + RNS.log("Could not load identity for rncp. The identity file at \""+str(identity_path)+"\" may be corrupt or unreadable.", RNS.LOG_ERROR) + exit(2) + else: + identity = None if identity == None: RNS.log("No valid saved identity found, creating new...", RNS.LOG_INFO)