Add a verify_env option to the master and minion configs

This commit is contained in:
Thomas S Hatch 2012-08-13 15:44:16 -06:00
parent 1d7c812023
commit 34eaf1f26c
3 changed files with 50 additions and 43 deletions

View File

@ -31,17 +31,18 @@ class Master(parsers.MasterOptionParser):
self.parse_args()
try:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
], self.config['user'],
permissive=self.config['permissive_pki_access'])
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
], self.config['user'],
permissive=self.config['permissive_pki_access'])
except OSError, err:
sys.exit(err.errno)
@ -76,14 +77,15 @@ class Minion(parsers.MinionOptionParser):
self.parse_args()
try:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
os.path.dirname(self.config['log_file']),
], self.config['user'],
permissive=self.config['permissive_pki_access'])
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
os.path.dirname(self.config['log_file']),
], self.config['user'],
permissive=self.config['permissive_pki_access'])
except OSError, err:
sys.exit(err.errno)
@ -117,13 +119,14 @@ class Syndic(parsers.SyndicOptionParser):
'''
self.parse_args()
try:
verify_env([
self.config['pki_dir'], self.config['cachedir'],
os.path.dirname(self.config['log_file']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
self.config['pki_dir'], self.config['cachedir'],
os.path.dirname(self.config['log_file']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
except OSError, err:
sys.exit(err.errno)

View File

@ -162,15 +162,16 @@ class SaltKey(parsers.SaltKeyOptionParser):
'''
self.parse_args()
verify_env([
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
os.path.dirname(self.config['key_logfile']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
os.path.dirname(self.config['key_logfile']),
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
self.setup_logfile_logger()
@ -189,14 +190,15 @@ class SaltCall(parsers.SaltCallOptionParser):
'''
self.parse_args()
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
os.path.dirname(self.config['log_file'])
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
os.path.dirname(self.config['log_file'])
],
self.config['user'],
permissive=self.config['permissive_pki_access']
)
caller = salt.cli.caller.Caller(self.config)

View File

@ -193,6 +193,7 @@ def minion_config(path):
'state_verbose': False,
'acceptance_wait_time': 10,
'dns_check': True,
'verify_env': True,
'grains': {},
'permissive_pki_access': False,
'default_include': 'minion.d/*.conf',
@ -284,6 +285,7 @@ def master_config(path):
'nodegroups': {},
'cython_enable': False,
'key_logfile': '/var/log/salt/key',
'verify_env': True,
'permissive_pki_access': False,
'default_include': 'master.d/*.conf',
}