mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +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 os
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -72,8 +73,12 @@ def is_enabled():
|
||||
|
||||
salt '*' jail.is_enabled <jail name>
|
||||
'''
|
||||
cmd = 'service -e | grep jail'
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
cmd = 'service -e'
|
||||
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():
|
||||
@ -176,8 +181,12 @@ def status(jail):
|
||||
|
||||
salt '*' jail.status <jail name>
|
||||
'''
|
||||
cmd = 'jls | grep {0}'.format(jail)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
cmd = 'jls'
|
||||
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():
|
||||
|
Loading…
Reference in New Issue
Block a user