Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2019.2] Merge forward from 2018.3 to 2019.2 #52528

Merged
merged 56 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
59b1d4f
Revert back to using reg to get timezone
twangboy Mar 7, 2019
9a8afa6
Fix tests, add null byte test
twangboy Mar 7, 2019
34bdae5
Merge branch '2018.3' into use_reg_timezone
twangboy Mar 8, 2019
b466f8a
Merge branch '2018.3' into use_reg_timezone
twangboy Mar 11, 2019
1bf0cbc
Merge branch '2018.3' into use_reg_timezone
twangboy Mar 19, 2019
bfdc47b
Handle new enhanced retcode 2
twangboy Mar 21, 2019
7aec2d3
Merge branch '2018.3' into fix_choco_retcode
twangboy Mar 28, 2019
d0987e6
Merge branch '2018.3' into use_reg_timezone
twangboy Mar 28, 2019
e3f5be3
Use uncommon item in mine delete test
waynew Apr 2, 2019
6d98577
Altered code to support salt-ssh on AIX
Apr 2, 2019
8bfa340
Correct typo
Apr 2, 2019
b374034
Re-raise queued exceptions with traceback
dwoz Apr 8, 2019
503cdd2
Remove IPCClient singleton
dwoz Apr 8, 2019
2b35437
Fix linter issues
dwoz Apr 8, 2019
47203f7
Fix ipc unit tests
dwoz Apr 8, 2019
29999b0
Close message service on subscriber close
dwoz Apr 9, 2019
c7ad732
Use six.reraise for py3 compatability
dwoz Apr 9, 2019
1bdaf29
Ensure exceptions in service future are handled
dwoz Apr 10, 2019
f66d474
Add support to avoid calling refresh_db in opkg.del_repo
chotea Aug 30, 2018
c8d547e
Use prune option in Pygit2 provider when fetching
chotea Oct 10, 2018
a891fd3
Make opkg.del_repo be compatible with pkrepo state module
chotea Aug 30, 2018
0e0c42e
2018 backport: modules.cmdmod: handle windows environ better
mattp- Apr 10, 2019
89bd258
Merge pull request #52445 from dwoz/ipc_fixes_2018.3
dwoz Apr 10, 2019
d699485
Merge pull request #52393 from waynew/52087-mine-delete-test-enhancem…
dwoz Apr 10, 2019
4dfb2f8
Merge pull request #52474 from Ch3LL/bp-49984
dwoz Apr 10, 2019
2df74ca
Merge pull request #52476 from bloomberg/win_cmd_2018
dwoz Apr 10, 2019
e3e1d2e
fix reactor ping test
dwoz Feb 19, 2019
75ddeb3
fix linter
dwoz Feb 19, 2019
7c963c1
Merge branch '2018.3' into ping_reaction_test
garethgreenaway Apr 10, 2019
e9d175b
Fix traceback when invalid source passed to archive.extracted
terminalmage Apr 11, 2019
6e79e24
Merge pull request #52500 from terminalmage/invalid-archive-source
twangboy Apr 11, 2019
7083d21
Merge branch '2018.3' into ping_reaction_test
garethgreenaway Apr 11, 2019
fc8e970
Merge branch '2018.3' into use_reg_timezone
twangboy Apr 11, 2019
b682ec5
transport.zmq: fix bug introduced by b7df7e75cf2
mattp- Apr 11, 2019
48ee82d
Merge branch '2018.3' into bp-49437
Ch3LL Apr 11, 2019
cd5cd7d
The exit code matters.
s0undt3ch Apr 11, 2019
53228ae
Merge pull request #52475 from Ch3LL/bp-49464
dwoz Apr 11, 2019
bbfd412
Merge branch '2018.3' into bp-49437
dwoz Apr 11, 2019
3a3114d
Fix merge conflict wart
dwoz Apr 11, 2019
452bbeb
Merge pull request #52512 from dwoz/supervisord_2018.3
dwoz Apr 11, 2019
8b05e77
Merge branch '2018.3' into ping_reaction_test
dwoz Apr 11, 2019
781385f
Merge branch '2018.3' into bp-49437
garethgreenaway Apr 11, 2019
9b7a0d1
Merge pull request #52505 from bloomberg/2018_zmq_uri
dwoz Apr 11, 2019
d830bc6
Merge pull request #52493 from dwoz/ping_reaction_test
dwoz Apr 11, 2019
576478e
Merge pull request #52473 from Ch3LL/bp-49437
dwoz Apr 12, 2019
0d09608
Merge pull request #52396 from dmurphy18/fix_aix_ssh
thatch45 Apr 12, 2019
dd7a4ba
Merge pull request #52046 from twangboy/use_reg_timezone
thatch45 Apr 12, 2019
262516c
Merge pull request #52209 from twangboy/fix_choco_retcode
thatch45 Apr 12, 2019
2941567
Merge branch '2018.3' into '2019.2'
Ch3LL Apr 12, 2019
c70772c
Fix linux state tests- add new comment
Ch3LL Apr 12, 2019
795a7f6
Fix windows tests - increase timeout
Ch3LL Apr 13, 2019
048a82e
Merge branch '2019.2' into merge-2019.2
Ch3LL Apr 13, 2019
474efa1
Fix pylint and state test failure
Ch3LL Apr 15, 2019
2c3ff2f
Merge branch '2019.2' into merge-2019.2
Ch3LL Apr 15, 2019
3442202
Increase timeout for test_kwarg tests
Ch3LL Apr 15, 2019
87cf385
increase timeout on test_state for windows
Ch3LL Apr 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion salt/client/ssh/ssh_py_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def need_deployment():
if dstat.st_uid != euid:
# Attack detected, try again
need_deployment()
if dstat.st_mode != 16832:
# AIX has non-POSIX bit 0o240700, isolate to 0o40700
if dstat.st_mode & ~65536 != 16832:
# Attack detected
need_deployment()
# If SUDOing then also give the super user group write permissions
Expand Down
7 changes: 6 additions & 1 deletion salt/modules/chocolatey.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ def list_(narrow=None,

result = __salt__['cmd.run_all'](cmd, python_shell=False)

if result['retcode'] != 0:
# Chocolatey introduced Enhanced Exit Codes starting with version 0.10.12
# Exit Code 2 means there were no results, but is not a failure
# This may start to effect other functions in the future as Chocolatey
# moves more functions to this new paradigm
# https://github.com/chocolatey/choco/issues/1758
if result['retcode'] not in [0, 2]:
raise CommandExecutionError(
'Running chocolatey failed: {0}'.format(result['stdout'])
)
Expand Down
71 changes: 36 additions & 35 deletions salt/modules/opkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,27 +1168,27 @@ def list_repos(**kwargs): # pylint: disable=unused-argument
return repos


def get_repo(alias, **kwargs): # pylint: disable=unused-argument
def get_repo(repo, **kwargs): # pylint: disable=unused-argument
'''
Display a repo from the ``/etc/opkg/*.conf``

CLI Examples:

.. code-block:: bash

salt '*' pkg.get_repo alias
salt '*' pkg.get_repo repo
'''
repos = list_repos()

if repos:
for source in six.itervalues(repos):
for sub in source:
if sub['name'] == alias:
if sub['name'] == repo:
return sub
return {}


def _del_repo_from_file(alias, filepath):
def _del_repo_from_file(repo, filepath):
'''
Remove a repo from filepath
'''
Expand All @@ -1201,30 +1201,30 @@ def _del_repo_from_file(alias, filepath):
if line.startswith('#'):
line = line[1:]
cols = salt.utils.args.shlex_split(line.strip())
if alias != cols[1]:
if repo != cols[1]:
output.append(salt.utils.stringutils.to_str(line))
with salt.utils.files.fopen(filepath, 'w') as fhandle:
fhandle.writelines(output)


def _add_new_repo(alias, uri, compressed, enabled=True):
def _add_new_repo(repo, uri, compressed, enabled=True):
'''
Add a new repo entry
'''
repostr = '# ' if not enabled else ''
repostr += 'src/gz ' if compressed else 'src '
if ' ' in alias:
repostr += '"' + alias + '" '
if ' ' in repo:
repostr += '"' + repo + '" '
else:
repostr += alias + ' '
repostr += repo + ' '
repostr += uri + '\n'
conffile = os.path.join(OPKG_CONFDIR, alias + '.conf')
conffile = os.path.join(OPKG_CONFDIR, repo + '.conf')

with salt.utils.files.fopen(conffile, 'a') as fhandle:
fhandle.write(salt.utils.stringutils.to_str(repostr))


def _mod_repo_in_file(alias, repostr, filepath):
def _mod_repo_in_file(repo, repostr, filepath):
'''
Replace a repo entry in filepath with repostr
'''
Expand All @@ -1234,15 +1234,15 @@ def _mod_repo_in_file(alias, repostr, filepath):
cols = salt.utils.args.shlex_split(
salt.utils.stringutils.to_unicode(line).strip()
)
if alias not in cols:
if repo not in cols:
output.append(line)
else:
output.append(salt.utils.stringutils.to_str(repostr + '\n'))
with salt.utils.files.fopen(filepath, 'w') as fhandle:
fhandle.writelines(output)


def del_repo(alias, **kwargs): # pylint: disable=unused-argument
def del_repo(repo, **kwargs): # pylint: disable=unused-argument
'''
Delete a repo from ``/etc/opkg/*.conf``

Expand All @@ -1253,21 +1253,22 @@ def del_repo(alias, **kwargs): # pylint: disable=unused-argument

.. code-block:: bash

salt '*' pkg.del_repo alias
salt '*' pkg.del_repo repo
'''
refresh = salt.utils.data.is_true(kwargs.get('refresh', True))
repos = list_repos()
if repos:
deleted_from = dict()
for repo in repos:
source = repos[repo][0]
if source['name'] == alias:
for repository in repos:
source = repos[repository][0]
if source['name'] == repo:
deleted_from[source['file']] = 0
_del_repo_from_file(alias, source['file'])
_del_repo_from_file(repo, source['file'])

if deleted_from:
ret = ''
for repo in repos:
source = repos[repo][0]
for repository in repos:
source = repos[repository][0]
if source['file'] in deleted_from:
deleted_from[source['file']] += 1
for repo_file, count in six.iteritems(deleted_from):
Expand All @@ -1279,22 +1280,22 @@ def del_repo(alias, **kwargs): # pylint: disable=unused-argument
os.remove(repo_file)
except OSError:
pass
ret += msg.format(alias, repo_file)
# explicit refresh after a repo is deleted
refresh_db()
ret += msg.format(repo, repo_file)
if refresh:
refresh_db()
return ret

return "Repo {0} doesn't exist in the opkg repo lists".format(alias)
return "Repo {0} doesn't exist in the opkg repo lists".format(repo)


def mod_repo(alias, **kwargs):
def mod_repo(repo, **kwargs):
'''
Modify one or more values for a repo. If the repo does not exist, it will
be created, so long as uri is defined.

The following options are available to modify a repo definition:

alias
repo
alias by which opkg refers to the repo.
uri
the URI to the repo.
Expand All @@ -1310,18 +1311,18 @@ def mod_repo(alias, **kwargs):

.. code-block:: bash

salt '*' pkg.mod_repo alias uri=http://new/uri
salt '*' pkg.mod_repo alias enabled=False
salt '*' pkg.mod_repo repo uri=http://new/uri
salt '*' pkg.mod_repo repo enabled=False
'''
repos = list_repos()
found = False
uri = ''
if 'uri' in kwargs:
uri = kwargs['uri']

for repo in repos:
source = repos[repo][0]
if source['name'] == alias:
for repository in repos:
source = repos[repository][0]
if source['name'] == repo:
found = True
repostr = ''
if 'enabled' in kwargs and not kwargs['enabled']:
Expand All @@ -1330,13 +1331,13 @@ def mod_repo(alias, **kwargs):
repostr += 'src/gz ' if kwargs['compressed'] else 'src'
else:
repostr += 'src/gz' if source['compressed'] else 'src'
repo_alias = kwargs['alias'] if 'alias' in kwargs else alias
repo_alias = kwargs['alias'] if 'alias' in kwargs else repo
if ' ' in repo_alias:
repostr += ' "{0}"'.format(repo_alias)
else:
repostr += ' {0}'.format(repo_alias)
repostr += ' {0}'.format(kwargs['uri'] if 'uri' in kwargs else source['uri'])
_mod_repo_in_file(alias, repostr, source['file'])
_mod_repo_in_file(repo, repostr, source['file'])
elif uri and source['uri'] == uri:
raise CommandExecutionError(
'Repository \'{0}\' already exists as \'{1}\'.'.format(uri, source['name']))
Expand All @@ -1345,12 +1346,12 @@ def mod_repo(alias, **kwargs):
# Need to add a new repo
if 'uri' not in kwargs:
raise CommandExecutionError(
'Repository \'{0}\' not found and no URI passed to create one.'.format(alias))
'Repository \'{0}\' not found and no URI passed to create one.'.format(repo))
# If compressed is not defined, assume True
compressed = kwargs['compressed'] if 'compressed' in kwargs else True
# If enabled is not defined, assume True
enabled = kwargs['enabled'] if 'enabled' in kwargs else True
_add_new_repo(alias, kwargs['uri'], compressed, enabled)
_add_new_repo(repo, kwargs['uri'], compressed, enabled)

if 'refresh' in kwargs:
refresh_db()
Expand Down
21 changes: 11 additions & 10 deletions salt/modules/win_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,23 @@ def get_zone():
Returns:
str: Timezone in unix format

Raises:
CommandExecutionError: If timezone could not be gathered

CLI Example:

.. code-block:: bash

salt '*' timezone.get_zone
'''
cmd = ['tzutil', '/g']
res = __salt__['cmd.run_all'](cmd, python_shell=False)
if res['retcode'] or not res['stdout']:
raise CommandExecutionError('tzutil encountered an error getting '
'timezone',
info=res)
return mapper.get_unix(res['stdout'].lower(), 'Unknown')
win_zone = __utils__['reg.read_value'](
hive='HKLM',
key='SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation',
vname='TimeZoneKeyName')['vdata']
# Some data may have null characters. We only need the first portion up to
# the first null character. See the following:
# https://github.com/saltstack/salt/issues/51940
# https://stackoverflow.com/questions/27716746/hklm-system-currentcontrolset-control-timezoneinformation-timezonekeyname-corrup
if '\0' in win_zone:
win_zone = win_zone.split('\0')[0]
return mapper.get_unix(win_zone.lower(), 'Unknown')


def get_offset():
Expand Down
5 changes: 5 additions & 0 deletions salt/states/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@ def extracted(name,
ret['comment'] = exc.strerror
return ret

if not source_match:
ret['result'] = False
ret['comment'] = 'Invalid source "{0}"'.format(source)
return ret

urlparsed_source = _urlparse(source_match)
urlparsed_scheme = urlparsed_source.scheme
urlparsed_path = os.path.join(
Expand Down
3 changes: 1 addition & 2 deletions salt/transport/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,8 @@ def _connect(self, timeout=None):
if self.stream is None:
with salt.utils.asynchronous.current_ioloop(self.io_loop):
self.stream = IOStream(
socket.socket(sock_type, socket.SOCK_STREAM),
socket.socket(sock_type, socket.SOCK_STREAM)
)

try:
log.trace('IPCClient: Connecting to socket: %s', self.socket_path)
yield self.stream.connect(sock_addr)
Expand Down
22 changes: 18 additions & 4 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1611,11 +1611,19 @@ def clean_stale_refs(self, local_refs=None): # pylint: disable=arguments-differ
'''
Clean stale local refs so they don't appear as fileserver environments
'''
try:
if pygit2.GIT_FETCH_PRUNE:
# Don't need to clean anything, pygit2 can do it by itself
return []
except AttributeError:
# However, only in 0.26.2 and newer
pass
if self.credentials is not None:
log.debug(
'pygit2 does not support detecting stale refs for '
'authenticated remotes, saltenvs will not reflect '
'branches/tags removed from remote \'%s\'', self.id
'The installed version of pygit2 (%s) does not support '
'detecting stale refs for authenticated remotes, saltenvs '
'will not reflect branches/tags removed from remote \'%s\'',
PYGIT2_VERSION, self.id
)
return []
return super(Pygit2, self).clean_stale_refs()
Expand Down Expand Up @@ -1721,6 +1729,11 @@ def _fetch(self):
else:
if self.credentials is not None:
origin.credentials = self.credentials
try:
fetch_kwargs['prune'] = pygit2.GIT_FETCH_PRUNE
except AttributeError:
# pruning only available in pygit2 >= 0.26.2
pass
try:
fetch_results = origin.fetch(**fetch_kwargs)
except GitError as exc:
Expand Down Expand Up @@ -2573,7 +2586,8 @@ def _recommend():
LIBGIT2_VERSION
)
)
if not salt.utils.path.which('git'):
if not getattr(pygit2, 'GIT_FETCH_PRUNE', False) \
and not salt.utils.path.which('git'):
errors.append(
'The git command line utility is required when using the '
'\'pygit2\' {0}_provider.'.format(self.role)
Expand Down
8 changes: 8 additions & 0 deletions salt/utils/rsax931.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def _load_libcrypto():
# two checks below
lib = glob.glob('/opt/local/lib/libcrypto.so*') + glob.glob('/opt/tools/lib/libcrypto.so*')
lib = lib[0] if len(lib) > 0 else None
if not lib and salt.utils.platform.is_aix():
if os.path.isdir('/opt/salt/lib'):
# preference for Salt installed fileset
lib = glob.glob('/opt/salt/lib/libcrypto.so*')
lib = lib[0] if len(lib) > 0 else None
else:
lib = glob.glob('/opt/freeware/lib/libcrypto.so*')
lib = lib[0] if len(lib) > 0 else None
if lib:
return cdll.LoadLibrary(lib)
raise OSError('Cannot locate OpenSSL libcrypto')
Expand Down
Loading