saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.03k stars 5.47k forks source link

Problem win_path.exists #27002

Closed jacky35 closed 8 years ago

jacky35 commented 8 years ago

Hello, There is a bug with the function "win_path.exists"

if you type : salt 'computer' win_path.exists 'C:\my_path'

All versions higher than Salt-Minion-2015.5.3 , will give this type of error message :


The minion function caused an exception: Traceback (most recent call last):

  File "C:\salt\bin\lib\site-packages\salt\minion.py", line 1004, in _thread_return
    return_data = func(*args, **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\modules\win_path.py", line 101, in exists
    sysPath = get_path()
  File "C:\salt\bin\lib\site-packages\salt\modules\win_path.py", line 78, in get_path
    'PATH').split(';')
AttributeError: 'dict' object has no attribute 'split'

Good day, Jacky

jfindlay commented 8 years ago

@jacky35, thanks for the report.

deniswal commented 8 years ago

Fix suggestion : edit salt/bin/Lib/site-packages/salt/modules/reg.py, line 151 ->

        return str(read_value(hive=hkey,
                          key=path,
                          vname=key)['vdata'])

    return str(read_value(hive=hkey, key=path)['vdata'])

It works better for me this way...

deniswal commented 8 years ago

Warning Warning: edit salt/bin/Lib/site-packages/salt/modules/reg.py line 223:

def set_key(hkey, path, value, key=None, vtype='REG_DWORD', reflection=True):

This seems wrong (And broke my Environment key definitions) -> Wrong order for arguments (Key value inversion): It should be ->

def set_key(hkey, path, key=None, value=None, vtype='REG_DWORD', reflection=True):

PS : This is one of the 10 lines I got in my registry (PATH defined the wrong way... And hard to remove afterwards):

c:\forge\ant\bin;c:\forge\eclipse;c:\forge\tomcat8;c:\forge\sqldeveloper;c:\forge\sqlplus\instantclient_12_1;c:\forge\maven\bin;c:\forge\jdk8\bin;c:\programdata\oracle\java\javapath;c:\forge\java\jdk8\bin;c:\forge\eclipse\bin;c:\forge\sqlplus\bin;c:\\forge\maven\bin;c:\\forge\java\jdk8\bin;"c:\program files (x86)\easyphp-devserver-14.1vc11\binaries\php\php_runningversion";"c:\program files (x86)\vim\vim74" %groovy_home%\bin;c:\cygwin\bin;c:\cygwin\usr\sbin;c:\forge\python;c:\forge\python27;c:\forge\sqlplus;c:\forge\tortoisegit\bin;c:\forge\tortoisehg;c:\program files (x86)\calibre2;c:\windows\system32;c:\program files(x86)\notes;c:\program files\openvpn\bin;c:\program files\tortoisesvn\bin;c:\program files(x86)\lotus\notes;c:\program files\notes;c:\program files\lotus\notes;c:\tools;c:\program files (x86)\skype\phone=PATH
twangboy commented 8 years ago

Fixed by: https://github.com/saltstack/salt/pull/27024

nvoronchev commented 8 years ago

This bug is reproduced in 2015.8.0.

twangboy commented 8 years ago

@NVoronchev This bug is fixed in 2015.8.1

sumitpandey1990 commented 8 years ago

@twangboy : Reproduced this issue in my setup with

COMMAND:
salt-master --version
OUTPUT:
salt-master 2015.8.1 (Beryllium)
COMMAND:
salt 'myminion' test.version
OUTPUT:
myminion:
    2015.5.5

COMMAND:

salt 'myminion' win_path.exists 'C:\Python27'

OUTPUT:

myminion:
    The minion function caused an exception: Traceback (most recent call last):
      File "c:\salt\bin\lib\site-packages\salt\minion.py", line 1173, in _thread_return
        return_data = func(*args, **kwargs)
      File "c:\salt\bin\lib\site-packages\salt\modules\win_path.py", line 100, in exists
        sysPath = get_path()
      File "c:\salt\bin\lib\site-packages\salt\modules\win_path.py", line 77, in get_path
        'PATH').split(';')
    AttributeError: 'dict' object has no attribute 'split'

NOTE: Path "C:\Python27" exists on myminion.

twangboy commented 8 years ago

@sumitpandey1990 This bug is fixed in 2015.5.6

sumitpandey1990 commented 8 years ago

@twangboy : Thanks, I'll try and update.

sumitpandey1990 commented 8 years ago

@twangboy: it's working :+1: