Skip to content

Commit

Permalink
Merge pull request #45638 from twangboy/win_fix_shell_info
Browse files Browse the repository at this point in the history
Win fix shell info
  • Loading branch information
Nicole Thomas authored Jan 23, 2018
2 parents 2d1dd11 + 872da3f commit 1081296
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 2 additions & 3 deletions salt/modules/cmdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,9 +2749,8 @@ def shell_info(shell, list_modules=False):
'HKEY_LOCAL_MACHINE',
'Software\\Microsoft\\PowerShell\\{0}'.format(reg_ver),
'Install')
if 'vtype' in install_data and \
install_data['vtype'] == 'REG_DWORD' and \
install_data['vdata'] == 1:
if install_data.get('vtype') == 'REG_DWORD' and \
install_data.get('vdata') == 1:
details = __salt__['reg.list_values'](
'HKEY_LOCAL_MACHINE',
'Software\\Microsoft\\PowerShell\\{0}\\'
Expand Down
15 changes: 12 additions & 3 deletions salt/modules/reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,15 @@ def list_values(hive, key=None, use_32bit_registry=False, include_default=True):
value = {'hive': local_hive,
'key': local_key,
'vname': _to_mbcs(vname),
'vdata': _to_mbcs(vdata),
'vtype': registry.vtype_reverse[vtype],
'success': True}
# Only convert text types to unicode
if vtype == win32con.REG_MULTI_SZ:
value['vdata'] = [_to_mbcs(i) for i in vdata]
elif vtype in [win32con.REG_SZ, win32con.REG_EXPAND_SZ]:
value['vdata'] = _to_mbcs(vdata)
else:
value['vdata'] = vdata
values.append(value)
except pywintypes.error as exc: # pylint: disable=E0602
log.debug(exc)
Expand Down Expand Up @@ -372,11 +378,14 @@ def read_value(hive, key, vname=None, use_32bit_registry=False):
# RegQueryValueEx returns and accepts unicode data
vdata, vtype = win32api.RegQueryValueEx(handle, local_vname)
if vdata or vdata in [0, '']:
# Only convert text types to unicode
ret['vtype'] = registry.vtype_reverse[vtype]
if vtype == 7:
if vtype == win32con.REG_MULTI_SZ:
ret['vdata'] = [_to_mbcs(i) for i in vdata]
else:
elif vtype in [win32con.REG_SZ, win32con.REG_EXPAND_SZ]:
ret['vdata'] = _to_mbcs(vdata)
else:
ret['vdata'] = vdata
else:
ret['comment'] = 'Empty Value'
except WindowsError: # pylint: disable=E0602
Expand Down

0 comments on commit 1081296

Please sign in to comment.