Check to see if the given command can be run
(cmd)
| 248 | |
| 249 | |
| 250 | def _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 | |
| 277 | def _prep_powershell_cmd(win_shell, cmd, encoded_cmd): |