> vim salt/utils/args.py
# ++
def valid_cmd_arg(args):
'''
Valid cmd arg
'''
# 禁用包含的命令,可自定义
ilLegCmds = ['init', 'shutdown']
for arg in args:
shell_cmd = arg.lower()
for cmd_one in shell_cmd.split(";"):
if ilLegCmds.count(cmd_one) > 0 :
return False
else:
for ilLegCmd in ilLegCmds:
if re.search(ilLegCmd, cmd_one):
return False
'''
for cmd_one_param in cmd_one.split():
if ilLegCmds.count(cmd_one_param) > 0 \
or ilLegCmds.count(cmd_one_param.strip('"')) > 0 \
or ilLegCmds.count(cmd_one_param.strip("'")) > 0:
return False
'''
return True
# end
> vim salt/client/__init__.py
def run_job(){
# ++ 函数入口处添加
if not salt.utils.args.valid_cmd_arg(arg):
raise SaltClientError(" Dangerous cmd '%s'" % (arg))
# end
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26250550/viewspace-2127461/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26250550/viewspace-2127461/