mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #43226 from lomeroe/fix_43166
Fixes for issues in PR #43166
This commit is contained in:
commit
ac2189c870
1 changed files with 11 additions and 10 deletions
|
@ -2835,7 +2835,8 @@ def _findOptionValueInSeceditFile(option):
|
|||
_reader = codecs.open(_tfile, 'r', encoding='utf-16')
|
||||
_secdata = _reader.readlines()
|
||||
_reader.close()
|
||||
_ret = __salt__['file.remove'](_tfile)
|
||||
if __salt__['file.file_exists'](_tfile):
|
||||
_ret = __salt__['file.remove'](_tfile)
|
||||
for _line in _secdata:
|
||||
if _line.startswith(option):
|
||||
return True, _line.split('=')[1].strip()
|
||||
|
@ -2856,16 +2857,20 @@ def _importSeceditConfig(infdata):
|
|||
_tInfFile = '{0}\\{1}'.format(__salt__['config.get']('cachedir'),
|
||||
'salt-secedit-config-{0}.inf'.format(_d))
|
||||
# make sure our temp files don't already exist
|
||||
_ret = __salt__['file.remove'](_tSdbfile)
|
||||
_ret = __salt__['file.remove'](_tInfFile)
|
||||
if __salt__['file.file_exists'](_tSdbfile):
|
||||
_ret = __salt__['file.remove'](_tSdbfile)
|
||||
if __salt__['file.file_exists'](_tInfFile):
|
||||
_ret = __salt__['file.remove'](_tInfFile)
|
||||
# add the inf data to the file, win_file sure could use the write() function
|
||||
_ret = __salt__['file.touch'](_tInfFile)
|
||||
_ret = __salt__['file.append'](_tInfFile, infdata)
|
||||
# run secedit to make the change
|
||||
_ret = __salt__['cmd.run']('secedit /configure /db {0} /cfg {1}'.format(_tSdbfile, _tInfFile))
|
||||
# cleanup our temp files
|
||||
_ret = __salt__['file.remove'](_tSdbfile)
|
||||
_ret = __salt__['file.remove'](_tInfFile)
|
||||
if __salt__['file.file_exists'](_tSdbfile):
|
||||
_ret = __salt__['file.remove'](_tSdbfile)
|
||||
if __salt__['file.file_exists'](_tInfFile):
|
||||
_ret = __salt__['file.remove'](_tInfFile)
|
||||
return True
|
||||
except Exception as e:
|
||||
log.debug('error occurred while trying to import secedit data')
|
||||
|
@ -4174,8 +4179,6 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
|
|||
existing_data = ''
|
||||
base_policy_settings = {}
|
||||
policy_data = _policy_info()
|
||||
#//{0}:policy[@displayName = "{1}" and (@class = "Both" or @class = "{2}") ]
|
||||
#policySearchXpath = etree.XPath('//*[@ns1:id = $id or @ns1:name = $id]')
|
||||
policySearchXpath = '//ns1:*[@id = "{0}" or @name = "{0}"]'
|
||||
try:
|
||||
if admx_policy_definitions is None or adml_policy_resources is None:
|
||||
|
@ -4206,8 +4209,7 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
|
|||
this_valuename = None
|
||||
if str(base_policy_settings[adm_namespace][admPolicy]).lower() == 'disabled':
|
||||
log.debug('time to disable {0}'.format(admPolicy))
|
||||
#this_policy = policySearchXpath(admx_policy_definitions, id=admPolicy, namespaces={'ns1': adm_namespace})
|
||||
this_policy = admx_policy_definitions.xpath(policySearchXpath.format('ns1', admPolicy), namespaces={'ns1': adm_namespace})
|
||||
this_policy = admx_policy_definitions.xpath(policySearchXpath.format(admPolicy), namespaces={'ns1': adm_namespace})
|
||||
if this_policy:
|
||||
this_policy = this_policy[0]
|
||||
if 'class' in this_policy.attrib:
|
||||
|
@ -4318,7 +4320,6 @@ def _writeAdminTemplateRegPolFile(admtemplate_data,
|
|||
log.error(msg.format(this_policy.attrib))
|
||||
else:
|
||||
log.debug('time to enable and set the policy "{0}"'.format(admPolicy))
|
||||
#this_policy = policySearchXpath(admx_policy_definitions, id=admPolicy, namespaces={'ns1': adm_namespace})
|
||||
this_policy = admx_policy_definitions.xpath(policySearchXpath.format(admPolicy), namespaces={'ns1': adm_namespace})
|
||||
log.debug('found this_policy == {0}'.format(this_policy))
|
||||
if this_policy:
|
||||
|
|
Loading…
Add table
Reference in a new issue