summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Tanner <tanner.jc@gmail.com>2013-11-22 16:36:31 -0500
committerJames Tanner <tanner.jc@gmail.com>2013-11-22 16:36:31 -0500
commit32986c4d645f3e968428b09b826b3e2e2a97adb5 (patch)
tree8897014cd5d5f0935b2675601d1054c065043ef9
parente54a574bb292973442694abd73c16254042fdb29 (diff)
downloadansible-32986c4d645f3e968428b09b826b3e2e2a97adb5.tar.gz
Fixes #5021 safely split hostkeys with quotes
-rw-r--r--library/system/authorized_key7
1 files changed, 6 insertions, 1 deletions
diff --git a/library/system/authorized_key b/library/system/authorized_key
index 5c40e7d97c..db0425d2a1 100644
--- a/library/system/authorized_key
+++ b/library/system/authorized_key
@@ -209,7 +209,12 @@ def parsekey(raw_key):
key_type = None # type of ssh key
type_index = None # index of keytype in key string|list
- key_parts = shlex.split(raw_key)
+ # split key safely
+ lex = shlex.shlex(raw_key)
+ lex.quotes = ["'", '"']
+ lex.whitespace_split = True
+ key_parts = list(lex)
+
for i in range(0, len(key_parts)):
if key_parts[i] in VALID_SSH2_KEY_TYPES:
type_index = i