diff options
author | Martin Pihlak | 2011-03-18 11:47:58 +0000 |
---|---|---|
committer | Martin Pihlak | 2011-03-18 11:47:58 +0000 |
commit | f88ecf719ba0343fbd6de231ae5448cee3bb356a (patch) | |
tree | 595d2c35b164abe63c46a6fda15acf6d06ead14e /python/walmgr.py | |
parent | afcaec42bd68a1939a75a45722c992998a5dccc9 (diff) |
fix --ssh-add-key with missing authorized_keys file
Diffstat (limited to 'python/walmgr.py')
-rwxr-xr-x | python/walmgr.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/python/walmgr.py b/python/walmgr.py index 3ee61de1..94f2b0e0 100755 --- a/python/walmgr.py +++ b/python/walmgr.py @@ -999,11 +999,14 @@ config_backup = %(config_backup)s self.log.debug("Reading public key from %s" % self.options.ssh_add_key) master_pubkey = open(self.options.ssh_add_key).read() - for key in open(auth_file): - if key == master_pubkey: - self.log.info("Key already present in %s, skipping" % auth_file) - break - else: + key_present = False + if os.path.isfile(auth_file): + for key in open(auth_file): + if key == master_pubkey: + self.log.info("Key already present in %s, skipping" % auth_file) + key_present = True + + if not key_present: self.log.info("Adding %s to %s" % (self.options.ssh_add_key, auth_file)) if not self.not_really: af = open(auth_file, "a") |