From f894f0ecb82a93b3a1f9b5844b4bbbba72e4e0b2 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Sun, 1 Jul 2018 12:33:10 -0700 Subject: [PATCH 01/15] Setting the mode with setuid or setgid bits in addition to setting the owner and group will force the setuid & setgid bits to reset. This change ensures that we set the mode after setting the owner & group. --- salt/modules/file.py | 41 ++++++++++++++------------- tests/integration/states/test_file.py | 26 +++++++++++++++++ 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 160b04a689..799915dda4 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -4262,26 +4262,6 @@ def check_perms(name, ret, user, group, mode, follow_symlinks=False): perms['lgroup'] = cur['group'] perms['lmode'] = salt.utils.normalize_mode(cur['mode']) - # Mode changes if needed - if mode is not None: - # File is a symlink, ignore the mode setting - # if follow_symlinks is False - if os.path.islink(name) and not follow_symlinks: - pass - else: - mode = salt.utils.normalize_mode(mode) - if mode != perms['lmode']: - if __opts__['test'] is True: - ret['changes']['mode'] = mode - else: - set_mode(name, mode) - if mode != salt.utils.normalize_mode(get_mode(name)): - ret['result'] = False - ret['comment'].append( - 'Failed to change mode to {0}'.format(mode) - ) - else: - ret['changes']['mode'] = mode # user/group changes if needed, then check if it worked if user: if isinstance(user, int): @@ -4358,6 +4338,27 @@ def check_perms(name, ret, user, group, mode, follow_symlinks=False): elif 'cgroup' in perms and user != '': ret['changes']['group'] = group + # Mode changes if needed + if mode is not None: + # File is a symlink, ignore the mode setting + # if follow_symlinks is False + if os.path.islink(name) and not follow_symlinks: + pass + else: + mode = salt.utils.normalize_mode(mode) + if mode != perms['lmode']: + if __opts__['test'] is True: + ret['changes']['mode'] = mode + else: + set_mode(name, mode) + if mode != salt.utils.normalize_mode(get_mode(name)): + ret['result'] = False + ret['comment'].append( + 'Failed to change mode to {0}'.format(mode) + ) + else: + ret['changes']['mode'] = mode + if isinstance(orig_comment, six.string_types): if orig_comment: ret['comment'].insert(0, orig_comment) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index d0ed2cbf23..704e82e6fe 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -2488,6 +2488,32 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin): ret = self.run_function('state.sls', mods=state_file) self.assertSaltTrueReturn(ret) + @skip_if_not_root + @skipIf(not HAS_PWD, "pwd not available. Skipping test") + @skipIf(not HAS_GRP, "grp not available. Skipping test") + @with_system_user_and_group('user12209', 'group12209', + on_existing='delete', delete=True) + def test_issue_48336_file_managed_mode_setuid(self, user, group): + ''' + Ensure that mode is correct with changing of ownership and group + symlinks) + ''' + tempfile = os.path.join(TMP, 'temp_file_issue_48336') + + # Run the state + ret = self.run_state( + 'file.managed', name=tempfile, + user=user, group=group, mode='4750', + ) + self.assertSaltTrueReturn(ret) + + # Check that the owner and group are correct, and + # the mode is what we expect + temp_file_stats = os.stat(tempfile) + self.assertEqual(six.text_type(oct(stat.S_IMODE(temp_file_stats.st_mode))), '04750') + self.assertEqual(pwd.getpwuid(temp_file_stats.st_uid).pw_name, user) + self.assertEqual(grp.getgrgid(temp_file_stats.st_gid).gr_name, group) + class BlockreplaceTest(ModuleCase, SaltReturnAssertsMixin): marker_start = '# start' From 8efd33320f989dda69ba44cf97455dd437d75144 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Mon, 2 Jul 2018 09:11:42 -0700 Subject: [PATCH 02/15] Normalize the mode before we compare it. --- tests/integration/states/test_file.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 704e82e6fe..221ee41eb8 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -2510,7 +2510,12 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin): # Check that the owner and group are correct, and # the mode is what we expect temp_file_stats = os.stat(tempfile) - self.assertEqual(six.text_type(oct(stat.S_IMODE(temp_file_stats.st_mode))), '04750') + + # Normalize the mode + temp_file_mode = six.text_type(oct(stat.S_IMODE(temp_file_stats.st_mode))) + temp_file_mode = salt.utils.normalize_mode(temp_file_mode) + + self.assertEqual(temp_file_mode, '4750') self.assertEqual(pwd.getpwuid(temp_file_stats.st_uid).pw_name, user) self.assertEqual(grp.getgrgid(temp_file_stats.st_gid).gr_name, group) From 6509aa9089a96864e02711c6b60f9353c90fe3af Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Tue, 3 Jul 2018 14:24:52 -0500 Subject: [PATCH 03/15] Fix outputter detection in jobs.lookup_jid runner The outputter detection was always failing because `data` is the return from the `jobs.list_job` runner, which has an extra dictionary level at the top. --- salt/runners/jobs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/runners/jobs.py b/salt/runners/jobs.py index 1fa6142c44..88d4898a99 100644 --- a/salt/runners/jobs.py +++ b/salt/runners/jobs.py @@ -150,7 +150,7 @@ def lookup_jid(jid, try: # Check if the return data has an 'out' key. We'll use that as the # outputter in the absence of one being passed on the CLI. - outputter = data[next(iter(data))].get('out') + outputter = returns[next(iter(returns))].get('out') except (StopIteration, AttributeError): outputter = None From f8beab71ddee0349418acd17a5efb64bc907b937 Mon Sep 17 00:00:00 2001 From: Beorn Facchini Date: Tue, 3 Apr 2018 10:03:45 +1000 Subject: [PATCH 04/15] Regression to ignore retcodes on crontab calls --- salt/modules/cron.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/salt/modules/cron.py b/salt/modules/cron.py index 650b9e9ccf..033020ed39 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -282,12 +282,14 @@ def raw_cron(user): # Preserve line endings lines = sdecode(__salt__['cmd.run_stdout'](cmd, runas=user, + ignore_retcode=True, rstrip=False, python_shell=False)).splitlines(True) else: cmd = 'crontab -u {0} -l'.format(user) # Preserve line endings lines = sdecode(__salt__['cmd.run_stdout'](cmd, + ignore_retcode=True, rstrip=False, python_shell=False)).splitlines(True) From 8b4486248d80c668fde93c334e4557f9f7f172d7 Mon Sep 17 00:00:00 2001 From: Beorn Facchini Date: Wed, 4 Apr 2018 00:55:09 +1000 Subject: [PATCH 05/15] Added ignore_retcode to mock unit tests --- tests/unit/modules/test_cron.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/unit/modules/test_cron.py b/tests/unit/modules/test_cron.py index 6868b8f5a0..0d25e0f13d 100644 --- a/tests/unit/modules/test_cron.py +++ b/tests/unit/modules/test_cron.py @@ -789,6 +789,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l", runas=STUB_USER, + ignore_retcode=True, rstrip=False, python_shell=False) @@ -803,6 +804,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): MagicMock(return_value=False)): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -u root -l", + ignore_retcode=True, rstrip=False, python_shell=False) @@ -818,6 +820,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l", runas=STUB_USER, + ignore_retcode=True, rstrip=False, python_shell=False) @@ -833,6 +836,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l", runas=STUB_USER, + ignore_retcode=True, rstrip=False, python_shell=False) @@ -848,6 +852,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l", runas=STUB_USER, + ignore_retcode=True, rstrip=False, python_shell=False) @@ -863,6 +868,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin): cron.raw_cron(STUB_USER) cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l", runas=STUB_USER, + ignore_retcode=True, rstrip=False, python_shell=False) From 349a2b279e7f2ec133aa9adac77d8bea56493129 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 3 Jul 2018 20:31:26 +0000 Subject: [PATCH 06/15] Prepend test needs file.touch method --- tests/unit/states/test_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/states/test_file.py b/tests/unit/states/test_file.py index 5fb72ae76f..d934587268 100644 --- a/tests/unit/states/test_file.py +++ b/tests/unit/states/test_file.py @@ -1202,6 +1202,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): {'file.directory_exists': mock_f, 'file.makedirs': mock_t, 'file.stats': mock_f, + 'file.touch': mock_t, 'cp.get_template': mock_f, 'file.search': mock_f, 'file.prepend': mock_t}): From 5624865f86c532fc078fac5e197f767ded75fb1f Mon Sep 17 00:00:00 2001 From: Mark Troyer Date: Tue, 3 Jul 2018 18:41:11 -0700 Subject: [PATCH 07/15] Fix issue with redismod.hmset method redis.StrictRedis.hmset expects a dict as its second arg. hmset(self, name, mapping) method of redis.client.StrictRedis instance Set key to value within hash ``name`` for each corresponding key and value from the ``mapping`` dict --- salt/modules/redismod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/redismod.py b/salt/modules/redismod.py index 40ebbdc3a1..0544feb8e1 100644 --- a/salt/modules/redismod.py +++ b/salt/modules/redismod.py @@ -395,7 +395,7 @@ def hmset(key, **fieldsvals): database = fieldsvals.pop('db', None) password = fieldsvals.pop('password', None) server = _connect(host, port, database, password) - return server.hmset(key, **fieldsvals) + return server.hmset(key, fieldsvals) def hset(key, field, value, host=None, port=None, db=None, password=None): From f7fa7f57c68e1048a365a1720b9f3339b5e56737 Mon Sep 17 00:00:00 2001 From: Mark Troyer Date: Thu, 5 Jul 2018 11:43:46 -0700 Subject: [PATCH 08/15] Found another issue with redismod.hmset When run with salt.function in an orchestration, several private key/value pairs are passed in addition to the requested pairs: 127.0.0.1:6379> hkeys testing 1) "__pub_arg" 2) "field1" 3) "__pub_jid" 4) "__pub_fun" 5) "field2" 6) "field3" 7) "__pub_tgt" 8) "__pub_ret" 9) "__pub_user" 10) "__pub_master_id" 11) "__pub_tgt_type" Updated to filter them. --- salt/modules/redismod.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/salt/modules/redismod.py b/salt/modules/redismod.py index 0544feb8e1..e32eb5519f 100644 --- a/salt/modules/redismod.py +++ b/salt/modules/redismod.py @@ -395,7 +395,14 @@ def hmset(key, **fieldsvals): database = fieldsvals.pop('db', None) password = fieldsvals.pop('password', None) server = _connect(host, port, database, password) - return server.hmset(key, fieldsvals) + # orchestration passes several private key/var pairs in that we don't want + # to set in redis. + redispairs = {} + for field, value in fieldsvals.iteritems(): + if not field.startswith('__'): + redispairs[field] = value + + return server.hmset(key, redispairs) def hset(key, field, value, host=None, port=None, db=None, password=None): From 65817ac74dd80d8d2813e82a5f64f2945c61d218 Mon Sep 17 00:00:00 2001 From: Mark Troyer Date: Thu, 5 Jul 2018 13:56:02 -0700 Subject: [PATCH 09/15] Use clean_kwargs method instead --- salt/modules/redismod.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/salt/modules/redismod.py b/salt/modules/redismod.py index e32eb5519f..286fb7b1cb 100644 --- a/salt/modules/redismod.py +++ b/salt/modules/redismod.py @@ -19,6 +19,7 @@ Module to provide redis functionality to Salt from __future__ import absolute_import from salt.ext.six.moves import zip from salt.ext import six +from salt.utils import clean_kwargs from datetime import datetime # Import third party libs @@ -395,14 +396,7 @@ def hmset(key, **fieldsvals): database = fieldsvals.pop('db', None) password = fieldsvals.pop('password', None) server = _connect(host, port, database, password) - # orchestration passes several private key/var pairs in that we don't want - # to set in redis. - redispairs = {} - for field, value in fieldsvals.iteritems(): - if not field.startswith('__'): - redispairs[field] = value - - return server.hmset(key, redispairs) + return server.hmset(key, clean_kwargs(**fieldsvals)) def hset(key, field, value, host=None, port=None, db=None, password=None): From 392ab4e51ff1d5e8c8c334fb185b0f2610046bf9 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 6 Jul 2018 12:44:47 -0500 Subject: [PATCH 10/15] Add some configurations to tox --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e4939987e7..ef260ef2cf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,13 @@ [tox] -envlist = py27,py3 +envlist = py27,py34,py35,py36 +skip_missing_interpreters = True +skipsdist = True [testenv] deps = -r{toxinidir}/requirements/tests.txt commands = pytest --rootdir {toxinidir} {posargs} passenv = LANG HOME +sitepackages = True [pytest] addopts = --log-file /tmp/salt-runtests.log --no-print-logs --ssh-tests -ra -sv From 44aaac1d33ba78c4d72c96587cb994e2a5f12394 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 6 Jul 2018 13:24:07 -0500 Subject: [PATCH 11/15] use tox to run pylint Also allow pylint to be run from a virtualenv --- requirements/dev.txt | 1 + salt/netapi/rest_tornado/saltnado.py | 2 +- salt/utils/versions.py | 4 ++-- setup.py | 2 +- tox.ini | 10 +++++++++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 3c7ac1b19c..6cdeaa7975 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -10,3 +10,4 @@ git+https://github.com/saltstack/pytest-salt.git@master#egg=pytest-salt # satisfy other requirements, and httpretty 0.8.10 has bugs in setup.py that # prevent it from being successfully installed (at least on Python 3.4). httpretty; python_version >= '3.4' +pylint==1.6.5 diff --git a/salt/netapi/rest_tornado/saltnado.py b/salt/netapi/rest_tornado/saltnado.py index af8a5885e1..78e03e2159 100644 --- a/salt/netapi/rest_tornado/saltnado.py +++ b/salt/netapi/rest_tornado/saltnado.py @@ -210,7 +210,7 @@ import tornado TORNADO_50 = tornado.version_info >= (5,) if not TORNADO_50: - import zmq.eventloop.ioloop + import zmq.eventloop.ioloop # pylint: disable=import-error # instantiate the zmq IOLoop (specialized poller) zmq.eventloop.ioloop.install() diff --git a/salt/utils/versions.py b/salt/utils/versions.py index d6d73ac866..94fbc8bef8 100644 --- a/salt/utils/versions.py +++ b/salt/utils/versions.py @@ -14,8 +14,8 @@ # Import python libs from __future__ import absolute_import # pylint: disable=blacklisted-module -from distutils.version import StrictVersion as _StrictVersion -from distutils.version import LooseVersion as _LooseVersion +from distutils.version import StrictVersion as _StrictVersion # pylint: disable=no-name-in-module +from distutils.version import LooseVersion as _LooseVersion # pylint: disable=no-name-in-module # pylint: enable=blacklisted-module # Import 3rd-party libs diff --git a/setup.py b/setup.py index e1733e247e..bb062dbd55 100755 --- a/setup.py +++ b/setup.py @@ -366,7 +366,7 @@ class DownloadWindowsDlls(Command): import pip # pip has moved many things to `_internal` starting with pip 10 if LooseVersion(pip.__version__) < LooseVersion('10.0'): - from pip.utils.logging import indent_log + from pip.utils.logging import indent_log # pylint: disable=no-name-in-module else: from pip._internal.utils.logging import indent_log # pylint: disable=no-name-in-module platform_bits, _ = platform.architecture() diff --git a/tox.ini b/tox.ini index ef260ef2cf..0d4fa95f96 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36 +envlist = py27,py34,py35,py36,pylint skip_missing_interpreters = True skipsdist = True @@ -9,6 +9,14 @@ commands = pytest --rootdir {toxinidir} {posargs} passenv = LANG HOME sitepackages = True +[testenv:pylint] +basepython = python2.7 +deps = -r{toxinidir}/requirements/dev.txt +commands = + pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/ + pylint --rcfile=.testing.pylintrc --disable=W0232,E1002,W1307,str-format-in-logging tests/ +sitepackages = False + [pytest] addopts = --log-file /tmp/salt-runtests.log --no-print-logs --ssh-tests -ra -sv testpaths = tests From c7a3a7d8bdccba49efb2a2afb1cf62815c8d43e9 Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Fri, 6 Jul 2018 13:35:06 -0500 Subject: [PATCH 12/15] update jenkins tests to use tox for lint --- .ci/lint | 7 +++---- tox.ini | 14 +++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.ci/lint b/.ci/lint index f848a9d11f..e88c4bea68 100644 --- a/.ci/lint +++ b/.ci/lint @@ -16,8 +16,7 @@ pipeline { stage('setup') { steps { sh 'eval "$(pyenv init -)"; pyenv install 2.7.14 || echo "We already have this python."; pyenv local 2.7.14; pyenv shell 2.7.14' - sh 'eval "$(pyenv init -)"; pip install pylint SaltPyLint' - sh 'eval "$(pyenv init -)"; which pylint; pylint --version' + sh 'eval "$(pyenv init -)"; pip install tox' } } stage('linting') { @@ -25,13 +24,13 @@ pipeline { parallel { stage('salt linting') { steps { - sh 'eval "$(pyenv init -)"; pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/ | tee pylint-report.xml' + sh 'eval "$(pyenv init -)"; tox -e pylint-salt | tee pylint-report.xml' archiveArtifacts artifacts: 'pylint-report.xml' } } stage('test linting') { steps { - sh 'eval "$(pyenv init -)"; pylint --rcfile=.testing.pylintrc --disable=W0232,E1002,W1307,str-format-in-logging tests/ | tee pylint-report-tests.xml' + sh 'eval "$(pyenv init -)"; tox -e pylint-tests | tee pylint-report-tests.xml' archiveArtifacts artifacts: 'pylint-report-tests.xml' } } diff --git a/tox.ini b/tox.ini index 0d4fa95f96..193c7822fa 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36,pylint +envlist = py27,py34,py35,py36,pylint-salt,pylint-tests skip_missing_interpreters = True skipsdist = True @@ -9,12 +9,20 @@ commands = pytest --rootdir {toxinidir} {posargs} passenv = LANG HOME sitepackages = True -[testenv:pylint] +[testenv:pylint-salt] basepython = python2.7 deps = -r{toxinidir}/requirements/dev.txt commands = + pylint --version + pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/ +sitepackages = False + +[testenv:pylint-tests] +basepython = python2.7 +deps = -r{toxinidir}/requirements/dev.txt +commands = + pylint --version pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/ - pylint --rcfile=.testing.pylintrc --disable=W0232,E1002,W1307,str-format-in-logging tests/ sitepackages = False [pytest] From 935f9b560cf4c6dc97dd35dff460ce97ef74e01a Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 6 Jul 2018 15:46:57 -0600 Subject: [PATCH 13/15] Fix dependencies Adds back libnacl Adds back libsodium.dll Adds new python-certifi-win32 --- pkg/windows/modules/get-settings.psm1 | 2 ++ pkg/windows/req.txt | 2 ++ setup.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/windows/modules/get-settings.psm1 b/pkg/windows/modules/get-settings.psm1 index f69025d4a9..2ae32c8bc5 100644 --- a/pkg/windows/modules/get-settings.psm1 +++ b/pkg/windows/modules/get-settings.psm1 @@ -77,6 +77,7 @@ Function Get-Settings { "SSLeay" = "ssleay32.dll" "OpenSSLLic" = "OpenSSL_License.txt" "msvcr" = "msvcr120.dll" + "Libsodium" = "libsodium.dll" } $ini.Add("64bitDLLs", $64bitDLLs) @@ -86,6 +87,7 @@ Function Get-Settings { "SSLeay" = "ssleay32.dll" "OpenSSLLic" = "OpenSSL_License.txt" "msvcr" = "msvcr120.dll" + "Libsodium" = "libsodium.dll" } $ini.Add("32bitDLLs", $32bitDLLs) diff --git a/pkg/windows/req.txt b/pkg/windows/req.txt index e3b92aa119..8b495a43c5 100644 --- a/pkg/windows/req.txt +++ b/pkg/windows/req.txt @@ -12,6 +12,7 @@ idna==2.5 ioloop==0.1a0 ipaddress==1.0.18 Jinja2==2.9.6 +libnacl==1.6.1 # required by the nacl module lxml==3.7.3 Mako==1.0.6 MarkupSafe==1.0 @@ -23,6 +24,7 @@ pycrypto==2.6.1 pycurl==7.43.0 PyMySQL==0.7.11 pyOpenSSL==17.0.0 +python-certifi-win32==1.2 python-dateutil==2.6.0 python-gnupg==0.4.0 pywin32==223 diff --git a/setup.py b/setup.py index e1733e247e..c52eecd3a8 100755 --- a/setup.py +++ b/setup.py @@ -373,7 +373,7 @@ class DownloadWindowsDlls(Command): url = 'https://repo.saltstack.com/windows/dependencies/{bits}/{fname}.dll' dest = os.path.join(os.path.dirname(sys.executable), '{fname}.dll') with indent_log(): - for fname in ('libeay32', 'ssleay32', 'msvcr120'): + for fname in ('libeay32', 'libsodium', 'ssleay32', 'msvcr120'): # See if the library is already on the system if find_library(fname): continue From b0087d425cc25030d53681d4825c4b8bfe35801d Mon Sep 17 00:00:00 2001 From: twangboy Date: Fri, 6 Jul 2018 15:55:14 -0600 Subject: [PATCH 14/15] Add license info --- pkg/windows/readme.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/windows/readme.md b/pkg/windows/readme.md index 04527cf731..55c51b824a 100644 --- a/pkg/windows/readme.md +++ b/pkg/windows/readme.md @@ -9,34 +9,36 @@ salt for Windows with their corresponding licenses: | certifi | ISC | | cffi | MIT | | CherryPy | BSD | +| cryptography | BSD | | enum34 | BSD | | futures | BSD | | gitdb | BSD | | GitPython | BSD | | idna | BSD-like | -| ioflo | Apache 2.0 | | ioloop | MIT | | ipaddress | PSF | | Jinja2 | BSD | -| libnacl | --- | +| libnacl | Apache | +| lxml | BSD | | Mako | MIT | | MarkupSafe | BSD | -| msgpack-python | --- | +| msgpack-python | Apache 2.0 | | pip | MIT | | psutil | BSD | | pyasn1 | BSD | | pycparser | BSD | | pycurl | LGPL + MIT | | PyMySQL | MIT | -| pypiwin32 | PSF | +| PyOpenSSL | Apache 2.0 | +| python-certifi-win32 | BSD | | python-dateutil | Simplified BSD | | python-gnupg | BSD | +| pywin32 | PSF | | PyYAML | MIT | | pyzmq | LGPL + BSD | | requests | Apache 2.0 | | setuptools | MIT | | singledispatch | MIT | -| six | MIT | | smmap | BSD | | timelib | ZLIB/PHP | | tornado | Apache 2.0 | From 54341d1a8d3f8c305bfa3483c87949dd7818953f Mon Sep 17 00:00:00 2001 From: rallytime Date: Mon, 9 Jul 2018 10:34:38 -0400 Subject: [PATCH 15/15] Update old utils paths to use new utils paths --- salt/modules/file.py | 4 ++-- salt/states/archive.py | 2 +- tests/unit/states/test_file.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index 2e41037297..63abea73ee 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -4546,13 +4546,13 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False) if os.path.islink(name) and not follow_symlinks: pass else: - mode = salt.utils.normalize_mode(mode) + mode = salt.utils.files.normalize_mode(mode) if mode != perms['lmode']: if __opts__['test'] is True: ret['changes']['mode'] = mode else: set_mode(name, mode) - if mode != salt.utils.normalize_mode(get_mode(name)): + if mode != salt.utils.files.normalize_mode(get_mode(name)): ret['result'] = False ret['comment'].append( 'Failed to change mode to {0}'.format(mode) diff --git a/salt/states/archive.py b/salt/states/archive.py index 54be5597b1..4ca156cd04 100644 --- a/salt/states/archive.py +++ b/salt/states/archive.py @@ -84,7 +84,7 @@ def _checksum_file_path(path): path.lstrip('/\\'), ) elif str(exc).startswith('Cannot mix UNC'): - relpath = salt.utils.path_join('unc', path) + relpath = salt.utils.path.join('unc', path) else: raise ret = salt.utils.path.join(__opts__['cachedir'], 'archive_hash', relpath) diff --git a/tests/unit/states/test_file.py b/tests/unit/states/test_file.py index 94e015949f..c3fbd6dbd4 100644 --- a/tests/unit/states/test_file.py +++ b/tests/unit/states/test_file.py @@ -174,7 +174,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): 'file.group_to_gid': mock_empty, 'user.info': mock_empty, 'user.current': mock_user}): - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): comt = ('User {0} does not exist'.format(user)) ret = return_val({'comment': comt, 'name': name}) else: @@ -191,7 +191,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): 'user.current': mock_user}): with patch.dict(filestate.__opts__, {'test': True}): with patch.object(os.path, 'exists', mock_f): - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): comt = ('User {0} does not exist'.format(user)) ret = return_val( { @@ -220,7 +220,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): with patch.dict(filestate.__opts__, {'test': False}): with patch.object(os.path, 'isdir', mock_f): with patch.object(os.path, 'exists', mock_f): - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): comt = 'User {0} does not exist'.format(user) ret = return_val( { @@ -250,7 +250,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): with patch.object(os.path, 'isdir', mock_t): with patch.object(salt.states.file, '_check_symlink_ownership', mock_t): with patch('salt.utils.win_functions.get_sid_from_name', return_value='test-sid'): - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): comt = ('Symlink {0} is present and owned by ' '{1}'.format(name, user)) else: @@ -1178,7 +1178,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): Test to ensure that some text appears at the beginning of a file. ''' name = '/etc/motd' - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): name = 'c:\\etc\\motd' source = ['salt://motd/hr-messages.tmpl'] sources = ['salt://motd/devops-messages.tmpl'] @@ -1212,7 +1212,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin): comt = ('The following files will be changed:\n/etc:' ' directory - new\n') pchanges = {'/etc': {'directory': 'new'}} - if salt.utils.is_windows(): + if salt.utils.platform.is_windows(): comt = 'The directory "c:\\etc" will be changed' pchanges = {'c:\\etc': {'directory': 'new'}} ret.update({'comment': comt, 'name': name, 'pchanges': pchanges})