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

Wrap all cache calls in state.sls in correct umask #28461

Merged
merged 1 commit into from
Nov 2, 2015
Merged
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions salt/modules/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,13 @@ def sls(mods,
)

st_ = salt.state.HighState(opts, pillar, kwargs.get('__pub_jid'))

umask = os.umask(0o77)
if kwargs.get('cache'):
if os.path.isfile(cfn):
with salt.utils.fopen(cfn, 'rb') as fp_:
high_ = serial.load(fp_)
return st_.state.call_high(high_)
os.umask(umask)

if isinstance(mods, string_types):
mods = mods.split(',')
Expand Down Expand Up @@ -491,11 +492,11 @@ def sls(mods,
msg = 'Unable to write to SLS cache file {0}. Check permission.'
log.error(msg.format(cache_file))

os.umask(cumask)
_set_retcode(ret)
# Work around Windows multiprocessing bug, set __opts__['test'] back to
# value from before this function was run.
__opts__['test'] = orig_test

try:
with salt.utils.fopen(cfn, 'w+b') as fp_:
try:
Expand All @@ -506,6 +507,7 @@ def sls(mods,
except (IOError, OSError):
msg = 'Unable to write to highstate cache file {0}. Do you have permissions?'
log.error(msg.format(cfn))
os.umask(cumask)
return ret


Expand Down