mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #18161 from cachedout/freebsdjail_quote
Use re to search for jails/services
This commit is contained in:
commit
fa43db5c79
@ -5,6 +5,7 @@ The jail module for FreeBSD
|
|||||||
|
|
||||||
# Import python libs
|
# Import python libs
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
# Import salt libs
|
# Import salt libs
|
||||||
import salt.utils
|
import salt.utils
|
||||||
@ -72,8 +73,12 @@ def is_enabled():
|
|||||||
|
|
||||||
salt '*' jail.is_enabled <jail name>
|
salt '*' jail.is_enabled <jail name>
|
||||||
'''
|
'''
|
||||||
cmd = 'service -e | grep jail'
|
cmd = 'service -e'
|
||||||
return not __salt__['cmd.retcode'](cmd)
|
services = __salt__['cmd.run'](cmd, python_shell=False)
|
||||||
|
for service in services.split('\\n'):
|
||||||
|
if re.search('jail', service):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_enabled():
|
def get_enabled():
|
||||||
@ -176,8 +181,12 @@ def status(jail):
|
|||||||
|
|
||||||
salt '*' jail.status <jail name>
|
salt '*' jail.status <jail name>
|
||||||
'''
|
'''
|
||||||
cmd = 'jls | grep {0}'.format(jail)
|
cmd = 'jls'
|
||||||
return not __salt__['cmd.retcode'](cmd)
|
found_jails = __salt__['cmd.run'](cmd, python_shell=False)
|
||||||
|
for found_jail in found_jails.split('\\n'):
|
||||||
|
if re.search(jail, found_jail):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def sysctl():
|
def sysctl():
|
||||||
|
Loading…
Reference in New Issue
Block a user