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.11k stars 5.47k forks source link

[BUG] win_dns_client.get_dns_config interface naming issues. #58725

Open whytewolf opened 3 years ago

whytewolf commented 3 years ago

Description In the win_dns_client.get_dns_config is using the wrong wmi field for the interface name.

for all other parts of the module iface.NetConnectionID is used

Setup currently, win_dns_client.get_dns_config is using iface.Description as the interface name when it should be using iface.NetConnectionID like everything else in this tool.

as an example of the differences in these see. the following code.

PS C:\WINDOWS\system32> $interfaces = Get-WmiObject Win32_NetworkAdapter
PS C:\WINDOWS\system32> $interfaces | foreach {
>> $friendlyname = $_ | Select-Object -ExpandProperty NetConnectionID
>> $name = $_ | Select-Object -ExpandProperty Description
>> "$friendlyname is $name"
>> }
Ethernet 3 is AnchorFree TAP-Windows Adapter V9
Ethernet 2 is TAP-Windows Adapter V9
 is Microsoft Kernel Debug Network Adapter
 is WAN Miniport (SSTP)
 is WAN Miniport (IKEv2)
 is WAN Miniport (L2TP)
 is WAN Miniport (PPTP)
 is WAN Miniport (PPPOE)
 is WAN Miniport (IP)
 is WAN Miniport (IPv6)
 is WAN Miniport (Network Monitor)
 is Hyper-V Virtual Switch Extension Adapter
vEthernet (Default Switch) is Hyper-V Virtual Ethernet Adapter
Ethernet is Intel(R) Ethernet Connection (7) I219-V
Wi-Fi is Intel(R) Wireless-AC 9560
 is Microsoft Wi-Fi Direct Virtual Adapter
 is Microsoft Wi-Fi Direct Virtual Adapter
Bluetooth Network Connection is Bluetooth Device (Personal Area Network)

Steps to Reproduce the behavior Try and use the same interface id for win_dns_client.get_dns_servers and win_dns_client.get_dns_config when NetConnectionID and Descriptor do not line up.

Expected behavior consistency.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) ``` Desktop: Salt Version: Salt: 3001.1 Dependency Versions: cffi: 1.12.2 cherrypy: 17.4.1 dateutil: 2.8.0 docker-py: Not Installed gitdb: 2.0.5 gitpython: Not Installed Jinja2: 2.10.1 libgit2: Not Installed M2Crypto: Not Installed Mako: 1.0.7 msgpack-pure: Not Installed msgpack-python: 1.0.0 mysql-python: Not Installed pycparser: 2.19 pycrypto: Not Installed pycryptodome: 3.9.7 pygit2: Not Installed Python: 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] python-gnupg: 0.4.4 PyYAML: 5.3.1 PyZMQ: 18.0.1 smmap: 2.0.5 timelib: 0.2.4 Tornado: 4.5.3 ZMQ: 4.3.1 System Versions: dist: locale: cp1252 machine: AMD64 release: 10 system: Windows version: 10 10.0.19041 SP0 ```

Additional context Add any other context about the problem here.

xeacott commented 3 years ago

So after discussion, the issue described here is the following:

[root@salt00 ~]# salt Desktop win_dns_client.get_dns_config 'Wi-Fi'
Desktop:
    None
[root@salt00 ~]# salt Desktop win_dns_client.get_dns_config 'Intel(R) Wireless-AC 9560'
Desktop:
    True
[root@salt00 ~]# salt Desktop win_dns_client.get_dns_servers 'Wi-Fi'
Desktop:
    - 10.40.2.3
    - 10.40.2.4
    - 10.40.2.7
[root@salt00 ~]# salt Desktop win_dns_client.get_dns_servers 'Intel(R) Wireless-AC 9560'
Desktop:
    False

So the fix would be to update get_dns_servers and get_dns_client to ensure consistency between the two.