From 264945a1f77598572971750db89b0ee7cdf69524 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 13 Oct 2013 13:43:16 +0200 Subject: [PATCH 1/3] adding a single comma at the end of the options list confuse the module it start to duplicate line, because this create a empty option in the list, and so the module add a new line along the previous one. See >>> ' a,b, '.strip().split(',') ['a', 'b', ''] --- library/system/authorized_key | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/system/authorized_key b/library/system/authorized_key index 26494267d64..269cb728493 100644 --- a/library/system/authorized_key +++ b/library/system/authorized_key @@ -185,6 +185,9 @@ def parseoptions(options): if options: options_list = options.strip().split(",") for option in options_list: + # happen when there is comma at the end + if option == '': + continue if option.find("=") != -1: (arg,val) = option.split("=", 1) else: From 7672e9fef88f416e8b4a16c40d30b17dfa598249 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 13 Oct 2013 13:47:23 +0200 Subject: [PATCH 2/3] sort the option_key to have a constant predictable line --- library/system/authorized_key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/system/authorized_key b/library/system/authorized_key index 269cb728493..322d2c4348d 100644 --- a/library/system/authorized_key +++ b/library/system/authorized_key @@ -254,7 +254,7 @@ def writekeys(module, filename, keys): option_str = "" if options: option_strings = [] - for option_key in options.keys(): + for option_key in sorted(options.keys()): if options[option_key]: option_strings.append("%s=%s" % (option_key, options[option_key])) else: From 951a91723de1f19a93d37e6c1d4d3e2b28f9ae20 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 13 Oct 2013 13:48:19 +0200 Subject: [PATCH 3/3] make sure that options are quoted, as people can add a shell script there with a comma that would produce invalid configuration upon being wrote again --- library/system/authorized_key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/system/authorized_key b/library/system/authorized_key index 322d2c4348d..a60d17c9a0b 100644 --- a/library/system/authorized_key +++ b/library/system/authorized_key @@ -256,7 +256,7 @@ def writekeys(module, filename, keys): option_strings = [] for option_key in sorted(options.keys()): if options[option_key]: - option_strings.append("%s=%s" % (option_key, options[option_key])) + option_strings.append("%s=\"%s\"" % (option_key, options[option_key])) else: option_strings.append("%s " % option_key)