From a32bfc749bc7dec10ed87076503f20f5c1da5226 Mon Sep 17 00:00:00 2001 From: Serge Pokhodyaev Date: Sun, 18 Feb 2018 20:24:22 +0300 Subject: [PATCH] don't overwrite homedir --- libagent/gpg/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libagent/gpg/__init__.py b/libagent/gpg/__init__.py index 351b7da..7513f18 100644 --- a/libagent/gpg/__init__.py +++ b/libagent/gpg/__init__.py @@ -126,7 +126,10 @@ def run_init(device_type, args): homedir = os.path.expanduser('~/.gnupg/{}'.format(device_name)) log.info('GPG home directory: %s', homedir) - check_call(['rm', '-rf', homedir]) + if os.path.exists(homedir): + log.error('GPG home directory exists, remove it manually if required') + exit(1) + check_call(['mkdir', '-p', homedir]) check_call(['chmod', '700', homedir])