MCPcopy Create free account
hub / github.com/saltstack/salt / _check_avail

Function _check_avail

salt/modules/cmdmod.py:250–274  ·  view source on GitHub ↗

Check to see if the given command can be run

(cmd)

Source from the content-addressed store, hash-verified

248
249
250def _check_avail(cmd):
251 """
252 Check to see if the given command can be run
253 """
254 if isinstance(cmd, list):
255 cmd = " ".join([str(x) if not isinstance(x, str) else x for x in cmd])
256 bret = True
257 wret = False
258 if __salt__["config.get"]("cmd_blacklist_glob"):
259 blist = __salt__["config.get"]("cmd_blacklist_glob", [])
260 for comp in blist:
261 if fnmatch.fnmatch(cmd, comp):
262 # BAD! you are blacklisted
263 bret = False
264 if __salt__["config.get"]("cmd_whitelist_glob", []):
265 blist = __salt__["config.get"]("cmd_whitelist_glob", [])
266 for comp in blist:
267 if fnmatch.fnmatch(cmd, comp):
268 # GOOD! You are whitelisted
269 wret = True
270 break
271 else:
272 # If no whitelist set then alls good!
273 wret = True
274 return bret and wret
275
276
277def _prep_powershell_cmd(win_shell, cmd, encoded_cmd):

Callers 1

_runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected