[issue28009] core logic of uuid.getnode() is broken for netstat

Michael Felt report at bugs.python.org
Thu Jun 13 05:39:16 EDT 2019


Michael Felt <aixtools at felt.demon.nl> added the comment:

I have modified -

_NODE_GETTERS_WIN32 = [_windll_getnode, _netbios_getnode, _ipconfig_getnode]

_NODE_GETTERS_UNIX = [_unix_getnode, _ifconfig_getnode, _ip_getnode,
                      _arp_getnode, _lanscan_getnode, _netstat_getnode]

to:

  +683  # _OS_GETTERS, when known, are targetted for a specific OS or platform.
  +684  # The order is by 'common practice' on the specified platform.
  +685  # Note: 'posix' and 'windows' _OS_GETTERS are prefixed by a dll/dlload() method
  +686  # which, when successful, means none of these "external" methods are called.
  +687  # _GETTERS is (also) used by test_uuid.py to SkipUnless(), e.g.,
  +688  #     @unittest.skipUnless(_uuid._ifconfig_getnode in _uuid._GETTERS, ...)
  +689  if _LINUX:
  +690      _OS_GETTERS = [_ip_getnode, _ifconfig_getnode]
  +691  elif _DARWIN:
  +692      _OS_GETTERS = [_ifconfig_getnode, _arp_getnode, _netstat_getnode]
  +693  elif _WINDOWS:
  +694      _OS_GETTERS = [_netbios_getnode, _ipconfig_getnode]
  +695  elif _AIX:
  +696      _OS_GETTERS = [_netstat_getnode]
  +697  else:
  +698      _OS_GETTERS = [_ifconfig_getnode, _ip_getnode, _arp_getnode,
  +699                     _netstat_getnode, _lanscan_getnode]
  +700  if os.name == 'posix':
  +701      _GETTERS = [_unix_getnode] + _OS_GETTERS
  +702  elif os.name == 'nt':
  +703      _GETTERS = [_windll_getnode] + _OS_GETTERS
  +704  else:
  +705      _GETTERS = _OS_GETTERS

The shortened list, and in particular the move of _ip_getnode before _ifconfig_getnode is my experience that the "old" programs such as ifconfig, arp, and netstat are (occasionally) not available - with "ip" being the replacement for all.

Further, re: linux, on the two distros I could test (centos and debian) neither arp nor netstat return a (useable) MACADDR aka "node" value.

Requesting verification from people with other platforms.

Also, would like to know specifics for other platforms (e.g., OpenBSD, HPUX, Solaris). 

More generally speaking - if os.name is "posix" or "windows" - this  lists are almost irrelevant because the "DLL" _uuid module should provide the needed value.

The "plus" is that on systems that audit such things, there are fewer calls to non-existent programs and/or negative side-effects from calling programs that can/do not provide any useful data.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue28009>
_______________________________________


More information about the Python-bugs-list mailing list