mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix syslog logic checks for file://
, tcp://
and udp://
. Fixes #7754.
This commit is contained in:
parent
387f097959
commit
e72b4a3492
10 changed files with 338 additions and 24 deletions
|
@ -76,9 +76,9 @@ class Master(parsers.MasterOptionParser):
|
|||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
logfile = self.config['log_file']
|
||||
if logfile is not None and not logfile.startswith('tcp://') \
|
||||
and not logfile.startswith('udp://') \
|
||||
and not logfile.startswith('file://'):
|
||||
if logfile is not None and not logfile.startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files([logfile], self.config['user'])
|
||||
except OSError as err:
|
||||
|
@ -171,9 +171,9 @@ class Minion(parsers.MinionOptionParser):
|
|||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
logfile = self.config['log_file']
|
||||
if logfile is not None and not logfile.startswith('tcp://') \
|
||||
and not logfile.startswith('udp://') \
|
||||
and not logfile.startswith('file://'):
|
||||
if logfile is not None and not logfile.startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files([logfile], self.config['user'])
|
||||
except OSError as err:
|
||||
|
@ -256,9 +256,9 @@ class Syndic(parsers.SyndicOptionParser):
|
|||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
logfile = self.config['log_file']
|
||||
if logfile is not None and not logfile.startswith('tcp://') \
|
||||
and not logfile.startswith('udp://') \
|
||||
and not logfile.startswith('file://'):
|
||||
if logfile is not None and not logfile.startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files([logfile], self.config['user'])
|
||||
except OSError as err:
|
||||
|
|
|
@ -39,9 +39,9 @@ class SaltCMD(parsers.SaltCMDOptionParser):
|
|||
self.parse_args()
|
||||
|
||||
if self.config['verify_env']:
|
||||
if not (self.config['log_file'].startswith('tcp://') or
|
||||
self.config['log_file'].startswith('udp://') or
|
||||
self.config['log_file'].startswith('file://')):
|
||||
if not self.config['log_file'].startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files(
|
||||
[self.config['log_file']],
|
||||
|
@ -194,9 +194,9 @@ class SaltCP(parsers.SaltCPOptionParser):
|
|||
self.parse_args()
|
||||
|
||||
if self.config['verify_env']:
|
||||
if (not self.config['log_file'].startswith('tcp://') or
|
||||
not self.config['log_file'].startswith('udp://') or
|
||||
not self.config['log_file'].startswith('file://')):
|
||||
if not self.config['log_file'].startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files(
|
||||
[self.config['log_file']],
|
||||
|
@ -237,9 +237,9 @@ class SaltKey(parsers.SaltKeyOptionParser):
|
|||
permissive=self.config['permissive_pki_access'],
|
||||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
if (not self.config['key_logfile'].startswith('tcp://') or
|
||||
not self.config['key_logfile'].startswith('udp://') or
|
||||
not self.config['key_logfile'].startswith('file://')):
|
||||
if not self.config['log_file'].startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files(
|
||||
[self.config['key_logfile']],
|
||||
|
@ -273,9 +273,9 @@ class SaltCall(parsers.SaltCallOptionParser):
|
|||
permissive=self.config['permissive_pki_access'],
|
||||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
if (not self.config['log_file'].startswith('tcp://') or
|
||||
not self.config['log_file'].startswith('udp://') or
|
||||
not self.config['log_file'].startswith('file://')):
|
||||
if not self.config['log_file'].startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files(
|
||||
[self.config['log_file']],
|
||||
|
@ -322,9 +322,9 @@ class SaltRun(parsers.SaltRunOptionParser):
|
|||
permissive=self.config['permissive_pki_access'],
|
||||
pki_dir=self.config['pki_dir'],
|
||||
)
|
||||
if (not self.config['log_file'].startswith('tcp://') or
|
||||
not self.config['log_file'].startswith('udp://') or
|
||||
not self.config['log_file'].startswith('file://')):
|
||||
if not self.config['log_file'].startswith(('tcp://',
|
||||
'udp://',
|
||||
'file://')):
|
||||
# Logfile is not using Syslog, verify
|
||||
verify_files(
|
||||
[self.config['log_file']],
|
||||
|
|
|
@ -200,6 +200,36 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
if os.path.isfile(this_minion_key):
|
||||
os.unlink(this_minion_key)
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
minion_config = yaml.load(
|
||||
open(self.get_config_file_path('minion'), 'r').read()
|
||||
)
|
||||
minion_config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
open(os.path.join(config_dir, 'minion'), 'w').write(
|
||||
yaml.dump(minion_config, default_flow_style=False)
|
||||
)
|
||||
self.run_script(
|
||||
'salt-call',
|
||||
'--config-dir {0} cmd.run "echo foo"'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=15
|
||||
)
|
||||
try:
|
||||
self.assertIn('local:', ret)
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import os
|
||||
import yaml
|
||||
import pipes
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
@ -107,6 +108,38 @@ class CopyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
data = yaml.load('\n'.join(ret))
|
||||
self.assertTrue(data[minion])
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
os.unlink(self.get_config_file_path(config_file_name))
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} \'*\' test.ping'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=15
|
||||
)
|
||||
try:
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
|
@ -138,6 +139,37 @@ class KeyTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
finally:
|
||||
shutil.rmtree(tempdir)
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} -L'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=15
|
||||
)
|
||||
try:
|
||||
self.assertIn('minion', '\n'.join(ret))
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import signal
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
@ -21,6 +27,48 @@ class MasterTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
|
||||
_call_binary_ = 'salt-master'
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
pid_path = os.path.join(config_dir, '{0}.pid'.format(config_file_name))
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['root_dir'] = config_dir
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
config['ret_port'] = config['ret_port'] + 10
|
||||
config['publish_port'] = config['publish_port'] + 10
|
||||
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} --pid-file {1} -l debug'.format(
|
||||
config_dir,
|
||||
pid_path
|
||||
),
|
||||
timeout=5,
|
||||
catch_stderr=True
|
||||
)
|
||||
|
||||
# Now kill it if still running
|
||||
if os.path.exists(pid_path):
|
||||
os.kill(int(open(pid_path).read()), signal.SIGKILL)
|
||||
try:
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
@ -221,6 +224,37 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
data = self.run_salt('\'*\' sys.doc user')
|
||||
self.assertIn('user.add:', data)
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} minion test.ping'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=15
|
||||
)
|
||||
try:
|
||||
self.assertIn('minion', '\n'.join(ret))
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import signal
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
@ -21,6 +27,45 @@ class MinionTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
|
||||
_call_binary_ = 'salt-minion'
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'minion'
|
||||
pid_path = os.path.join(config_dir, '{0}.pid'.format(config_file_name))
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} --pid-file {1} -l debug'.format(
|
||||
config_dir,
|
||||
pid_path
|
||||
),
|
||||
timeout=5,
|
||||
catch_stderr=True
|
||||
)
|
||||
|
||||
# Now kill it if still running
|
||||
if os.path.exists(pid_path):
|
||||
os.kill(int(open(pid_path).read()), signal.SIGKILL)
|
||||
try:
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
Tests for the salt-run command
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
@ -39,6 +44,37 @@ class RunTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
data = '\n'.join(data)
|
||||
self.assertNotIn('jobs.SaltException:', data)
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
config = yaml.load(
|
||||
open(self.get_config_file_path(config_file_name), 'r').read()
|
||||
)
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} -d'.format(
|
||||
config_dir
|
||||
),
|
||||
timeout=15
|
||||
)
|
||||
try:
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
|
@ -9,18 +9,74 @@
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import yaml
|
||||
import signal
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import salt libs
|
||||
import integration
|
||||
import salt.config
|
||||
|
||||
|
||||
class SyndicTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
||||
|
||||
_call_binary_ = 'salt-syndic'
|
||||
|
||||
def test_issue_7754(self):
|
||||
old_cwd = os.getcwd()
|
||||
config_dir = os.path.join(integration.TMP, 'issue-7754')
|
||||
if not os.path.isdir(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
os.chdir(config_dir)
|
||||
|
||||
config_file_name = 'master'
|
||||
pid_path = os.path.join(config_dir, '{0}.pid'.format(config_file_name))
|
||||
|
||||
shutil.copyfile(
|
||||
self.get_config_file_path('minion'),
|
||||
os.path.join(config_dir, 'minion')
|
||||
)
|
||||
config = salt.config.syndic_config(
|
||||
master_config_path=self.get_config_file_path('syndic'),
|
||||
minion_config_path=self.get_config_file_path('minion')
|
||||
)
|
||||
config.pop('include')
|
||||
config['root_dir'] = config_dir
|
||||
config['log_file'] = 'file:///dev/log/LOG_LOCAL3'
|
||||
config['ret_port'] = config['ret_port'] + 10
|
||||
config['publish_port'] = config['publish_port'] + 10
|
||||
|
||||
open(os.path.join(config_dir, config_file_name), 'w').write(
|
||||
yaml.dump(config, default_flow_style=False)
|
||||
)
|
||||
|
||||
self.run_script(
|
||||
self._call_binary_,
|
||||
'--config-dir {0} --pid-file {1} -l debug'.format(
|
||||
config_dir,
|
||||
pid_path
|
||||
),
|
||||
timeout=5,
|
||||
catch_stderr=True
|
||||
)
|
||||
|
||||
# Now kill it if still running
|
||||
if os.path.exists(pid_path):
|
||||
os.kill(int(open(pid_path).read()), signal.SIGKILL)
|
||||
try:
|
||||
self.assertFalse(os.path.isdir(os.path.join(config_dir, 'file:')))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
if os.path.isdir(config_dir):
|
||||
shutil.rmtree(config_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
|
|
Loading…
Add table
Reference in a new issue