Fixes #1715 Allow authorized_module accept multi. (#3573)

This will allow the authorized_module to accept options that can be
passed multiple times into ssh options. For instance permitopen.
This commit is contained in:
Allen Sanabria 2016-06-20 17:32:44 -04:00 committed by jctanner
parent ae5ccf29ed
commit 343c3ecfb9

View file

@ -169,7 +169,7 @@ class keydict(dict):
def __iter__(self):
return iter(self.itemlist)
def keys(self):
return self.itemlist
return list(set(self.itemlist))
def values(self):
return [self[key] for key in self]
def itervalues(self):
@ -254,7 +254,13 @@ def parseoptions(module, options):
for part in parts:
if "=" in part:
(key, value) = part.split("=", 1)
options_dict[key] = value
if options_dict.has_key(key):
if isinstance(options_dict[key], list):
options_dict[key].append(value)
else:
options_dict[key] = [options_dict[key], value]
else:
options_dict[key] = value
elif part != ",":
options_dict[part] = None
except:
@ -348,10 +354,13 @@ def writekeys(module, filename, keys):
option_strings = []
for option_key in options.keys():
if options[option_key]:
option_strings.append("%s=%s" % (option_key, options[option_key]))
if isinstance(options[option_key], list):
for value in options[option_key]:
option_strings.append("%s=%s" % (option_key, value))
else:
option_strings.append("%s=%s" % (option_key, options[option_key]))
else:
option_strings.append("%s" % option_key)
option_str = ",".join(option_strings)
option_str += " "
key_line = "%s%s %s %s\n" % (option_str, type, keyhash, comment)