IronWilliamCash
IronWilliamCash

Reputation: 539

Adding registry key in windows through Salt-Stack

My problem is using Salt-Stack to add a registry key in Windows. I'm using a .sls file to define the following :

#AutoLogin on Windows Machines with a-testauto account
'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\AutoAdminLogon':
  reg.present:
    - value: '1'
    - vtype: REG_SZ
    - reflection: True
'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\DefaultUsername':
  reg.present:
    - value: user
    - vtype: REG_SZ
    - reflection: True
'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\DefaultPassword':
  reg.present:
    - value: password
    - vtype: REG_SZ
    - reflection: True
'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\DefaultDomainName':
  reg.present:
    - value: VLAB
    - vtype: REG_SZ
    - reflection: True

When the Minion calls the salt-master and applies the registry keys, everything works fine, except that the keys are not applied in the correct path. They are added to the following:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Winlogon

Basically I know that this is a 64bit machine and that this path represents the 64bit equivalent of the path that I am trying to manipulate. But when I reboot the machine, Windows does not use the 64bit version of the path but instead uses the original path.

My question is how do I get Salt-Stack to set the keys in the actual path that I specified instead of the Wow6432Node?

Is something wrong with my decleration in the sls file? I thought the "reflection:True" would have taken care of mirroring the info in both paths.

Thanks for any info on why this doesn't work.

Upvotes: 1

Views: 2593

Answers (1)

IronWilliamCash
IronWilliamCash

Reputation: 539

I found the answer to this problem. There is in fact a bug with SaltStack, it does not consider the 32bit/64bit aspect of the windows registry and just calls the regular regedit. Windows actually will call the registry redirector to decide weather to add the key to the wow6432node or the regular node.

I have actually publised a bug to the github of SaltStack. See here: https://github.com/saltstack/salt/issues/13513#issuecomment-46373007

That being said, I found a workaround for this problem. If you use SaltStack to actually call the registry editor through a command line or batch file. You can specify the .reg file that you want to import and then you can specify the following parameter to force it to the 32bit path of the registry:

/reg:64

I hope this answers anyone elses questions on the subject

Upvotes: 2

Related Questions