-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
GH-85724: Ignore the MAC from the Touch Bar interface on macOS in uuid #99717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
All Intel MacBook Pro devices with a Touch Bar have a network interface connected to a controller for that device that has the same MAC address for all MacBooks. Ignore these MAC adresses in the UUID library.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,9 +403,16 @@ def _get_command_stdout(command, *args): | |
# | ||
# See https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local | ||
|
||
|
||
def _is_universal(mac): | ||
return not (mac & (1 << 41)) | ||
|
||
# MAC adresses that are blacklisted for finding a node id | ||
_MAC_BLACKLIST={ | ||
# (GH-85724) Hardcoded MAC adres for all Intel MacBook's with Touch Bar. | ||
ronaldoussoren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int("ac:de:48:00:11:22".replace(":", ""), 16), | ||
ronaldoussoren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
|
||
def _find_mac_near_keyword(command, args, keywords, get_word_index): | ||
"""Searches a command's output for a MAC address near a keyword. | ||
|
@@ -436,6 +443,8 @@ def _find_mac_near_keyword(command, args, keywords, get_word_index): | |
# real MAC address | ||
pass | ||
else: | ||
if mac in _MAC_BLACKLIST: | ||
continue | ||
if _is_universal(mac): | ||
return mac | ||
first_local_mac = first_local_mac or mac | ||
|
@@ -498,6 +507,8 @@ def _find_mac_under_heading(command, args, heading): | |
mac = _parse_mac(word) | ||
if mac is None: | ||
continue | ||
if mac in _MAC_BLACKLIST: | ||
continue | ||
if _is_universal(mac): | ||
return mac | ||
if first_local_mac is None: | ||
|
@@ -581,6 +592,18 @@ def _netbios_getnode(): | |
_generate_time_safe = getattr(_uuid, "generate_time_safe", None) | ||
_UuidCreate = getattr(_uuid, "UuidCreate", None) | ||
_has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe | ||
|
||
if sys.platform == "darwin" and _generate_time_safe is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not 100% sure about this test, and in particular not about the test for "darwin". There are people running Linux on Apple hardware and I don't know if those could be affected by this issue, in particular if there is a driver that exposes a ethernet-like interface to the Touch Bar hardware. |
||
# On macOS check if generate_time_safe uses the MAC adddress | ||
# of the Touch Bar on Intel Macbooks and ignore the function | ||
# if it does because this is a single MAC adress for all | ||
# devices. See GH-85724 | ||
_x = _generate_time_safe()[0] | ||
if _x.endswith(bytes.fromhex("ac:de:48:00:11:22".replace(":", ""))): | ||
_has_uuid_generate_time_safe = False | ||
_generate_time_safe = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense/be possible to implement this test directly in the _uuid module: remove the function if it returns this address? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... Possible yes, sensible maybe not. The implementation of I have a patch, but haven't tested it on a device with a Touch Bar yet. That patch adds 49 lines of code to _uuidmodule.c and removes the 4 lines of python code above. |
||
del _x | ||
|
||
except ImportError: | ||
_uuid = None | ||
_generate_time_safe = None | ||
|
Uh oh!
There was an error while loading. Please reload this page.