mirror of https://github.com/jumpserver/jumpserver
修复sudo 命令 小写all 引起的推送失败(map)
parent
7bfb1d19fe
commit
c6823be302
|
@ -68,6 +68,12 @@ def gen_keys(key="", key_path_dir=""):
|
||||||
return key_path_dir
|
return key_path_dir
|
||||||
|
|
||||||
|
|
||||||
|
def trans_all(str):
|
||||||
|
if str.strip().lower() == "all":
|
||||||
|
return str.upper()
|
||||||
|
else:
|
||||||
|
return str
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print gen_keys()
|
print gen_keys()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from jasset.models import Asset, AssetGroup
|
||||||
from jperm.models import PermRole, PermRule, PermSudo, PermPush
|
from jperm.models import PermRole, PermRule, PermSudo, PermPush
|
||||||
from jumpserver.models import Setting
|
from jumpserver.models import Setting
|
||||||
|
|
||||||
from jperm.utils import gen_keys
|
from jperm.utils import gen_keys, trans_all
|
||||||
from jperm.ansible_api import MyTask
|
from jperm.ansible_api import MyTask
|
||||||
from jperm.perm_api import get_role_info, get_role_push_host
|
from jperm.perm_api import get_role_info, get_role_push_host
|
||||||
from jumpserver.api import my_render, get_object, CRYPTOR
|
from jumpserver.api import my_render, get_object, CRYPTOR
|
||||||
|
@ -619,12 +619,9 @@ def perm_sudo_add(request):
|
||||||
raise ServerError(u"sudo name 和 commands是必填项!")
|
raise ServerError(u"sudo name 和 commands是必填项!")
|
||||||
|
|
||||||
pattern = re.compile(r'[\n,\r]')
|
pattern = re.compile(r'[\n,\r]')
|
||||||
deal_commands = list_drop_str(pattern.split(commands), u'')
|
deal_space_commands = list_drop_str(pattern.split(commands), u'')
|
||||||
for command in deal_commands:
|
deal_all_commands = map(trans_all, deal_space_commands)
|
||||||
if command.strip().lower() == "all":
|
commands = ', '.join(deal_all_commands)
|
||||||
deal_commands.remove(command)
|
|
||||||
deal_commands.append(command.upper())
|
|
||||||
commands = ', '.join(deal_commands)
|
|
||||||
logger.debug(u'添加sudo %s: %s' % (name, commands))
|
logger.debug(u'添加sudo %s: %s' % (name, commands))
|
||||||
|
|
||||||
if get_object(PermSudo, name=name):
|
if get_object(PermSudo, name=name):
|
||||||
|
@ -661,12 +658,9 @@ def perm_sudo_edit(request):
|
||||||
raise ServerError(u"sudo name 和 commands是必填项!")
|
raise ServerError(u"sudo name 和 commands是必填项!")
|
||||||
|
|
||||||
pattern = re.compile(r'[\n,\r]')
|
pattern = re.compile(r'[\n,\r]')
|
||||||
deal_commands = list_drop_str(pattern.split(commands), u'')
|
deal_space_commands = list_drop_str(pattern.split(commands), u'')
|
||||||
for command in deal_commands:
|
deal_all_commands = map(trans_all, deal_space_commands)
|
||||||
if command.strip().lower() == "all":
|
commands = ', '.join(deal_all_commands).strip()
|
||||||
deal_commands.remove(command)
|
|
||||||
deal_commands.append(command.upper())
|
|
||||||
commands = ', '.join(deal_commands).strip()
|
|
||||||
logger.debug(u'添加sudo %s: %s' % (name, commands))
|
logger.debug(u'添加sudo %s: %s' % (name, commands))
|
||||||
|
|
||||||
sudo.name = name.strip()
|
sudo.name = name.strip()
|
||||||
|
|
Loading…
Reference in New Issue