mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Update state.py
create `_clean_tag()` method to safely encode tag names for file creation use `_clean_tag()` method for both create and read of state cache file
This commit is contained in:
parent
44b3caead1
commit
1dcf167bb7
@ -25,6 +25,7 @@ import traceback
|
||||
import re
|
||||
import time
|
||||
import random
|
||||
from urllib import quote
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -145,6 +146,11 @@ def _gen_tag(low):
|
||||
'''
|
||||
return '{0[state]}_|-{0[__id__]}_|-{0[name]}_|-{0[fun]}'.format(low)
|
||||
|
||||
def _clean_tag(tag):
|
||||
'''
|
||||
urllib safe quote the tag value to avoid invalid chars in the filename
|
||||
'''
|
||||
return quote(tag, safe='')
|
||||
|
||||
def _l_tag(name, id_):
|
||||
low = {'name': 'listen_{0}'.format(name),
|
||||
@ -1695,7 +1701,7 @@ class State(object):
|
||||
trb)
|
||||
}
|
||||
troot = os.path.join(self.opts['cachedir'], self.jid)
|
||||
tfile = os.path.join(troot, tag)
|
||||
tfile = os.path.join(troot, _clean_tag(tag))
|
||||
if not os.path.isdir(troot):
|
||||
try:
|
||||
os.makedirs(troot)
|
||||
@ -2047,7 +2053,7 @@ class State(object):
|
||||
proc = running[tag].get('proc')
|
||||
if proc:
|
||||
if not proc.is_alive():
|
||||
ret_cache = os.path.join(self.opts['cachedir'], self.jid, tag)
|
||||
ret_cache = os.path.join(self.opts['cachedir'], self.jid, _clean_tag(tag))
|
||||
if not os.path.isfile(ret_cache):
|
||||
ret = {'result': False,
|
||||
'comment': 'Parallel process failed to return',
|
||||
|
Loading…
Reference in New Issue
Block a user