diff options
author | James Tanner <tanner.jc@gmail.com> | 2013-11-25 22:13:42 -0500 |
---|---|---|
committer | James Tanner <tanner.jc@gmail.com> | 2013-11-25 22:13:42 -0500 |
commit | b93855431145339c395fb7f8839a83bc0b805814 (patch) | |
tree | ab0630b5acbe03b98725fdb2c03adff5674d95c0 | |
parent | d187066339aeab92ea4693bdb847e1e4589da427 (diff) | |
download | ansible-b93855431145339c395fb7f8839a83bc0b805814.tar.gz |
Fixes #5032 escape and safely split key options in authorized_keys module
-rw-r--r-- | library/system/authorized_key | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/library/system/authorized_key b/library/system/authorized_key index db0425d2a1..ac9df88cbf 100644 --- a/library/system/authorized_key +++ b/library/system/authorized_key @@ -177,7 +177,14 @@ def parseoptions(options): ''' options_dict = {} if options: - options_list = options.strip().split(",") + lex = shlex.shlex(options) + lex.quotes = ["'", '"'] + lex.whitespace_split = True + opt_parts = list(lex) + open("/tmp/awx.log", "a").write("opt_parts: %s\n" % opt_parts) + + #options_list = options.strip().split(",") + options_list = opt_parts for option in options_list: # happen when there is comma at the end if option == '': @@ -187,7 +194,8 @@ def parseoptions(options): else: arg = option val = None - options_dict[arg] = val + options_dict[arg] = val.replace('"', '').replace("'", "") + open("/tmp/awx.log", "a").write("options_dict: %s\n" % options_dict) return options_dict def parsekey(raw_key): |