Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-98415: Fix UUID ifconfig MAC address detection#98423
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedOct 19, 2022 • edited by ghost
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by ghost
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedOct 19, 2022
Most changes to Pythonrequire a NEWS entry. Please add it using theblurb_it web app or theblurb command-line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Nice catch!
I reproduce the issue with the following script:
importsubprocess"""Get the hardware address on Unix by running ifconfig."""# This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.deffoo(*args):command= ("/sbin/ifconfig",)+argsproc=subprocess.Popen(command,stdout=subprocess.PIPE,stderr=subprocess.DEVNULL)ifnotproc:returnstdout,stderr=proc.communicate()mac=stdout# This is fine for this example (normally it'd have parsed out a macifnotmac:print(args,mac,stderr)forargsin ('','-a','-av'):foo(args)
Uh oh!
There was an error while loading.Please reload this page.
bedevere-bot commentedOct 22, 2022
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Misc/NEWS.d/next/Core and Builtins/2022-10-19-01-01-08.gh-issue-98415.ZS2eWh.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I have a preference for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would it be possible to write an unit test with unittest.mock to check that subprocess is not called with an empty string argument?
Uh oh!
There was an error while loading.Please reload this page.
It looks hard to write the unittest due to system-specific implementation. |
Thanks@csanders-git for the PR, and@vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry@csanders-git and@vstinner, I had trouble checking out the |
…98423)The uuid.getnode() function has multiple implementations, tested sequentially.The ifconfig implementation was incorrect and always failed: fix it.In practice, functions of libuuid library are preferred, if available:uuid_generate_time_safe(), uuid_create() or uuid_generate_time().(cherry picked from commite3ec272)Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
bedevere-bot commentedNov 2, 2022
GH-99020 is a backport of this pull request to the3.10 branch. |
Thanks@csanders-git for the PR, and@vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
…98423)The uuid.getnode() function has multiple implementations, tested sequentially.The ifconfig implementation was incorrect and always failed: fix it.In practice, functions of libuuid library are preferred, if available:uuid_generate_time_safe(), uuid_create() or uuid_generate_time().(cherry picked from commite3ec272)Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
bedevere-bot commentedNov 2, 2022
GH-99021 is a backport of this pull request to the3.11 branch. |
Ok, thanks@csanders-git for the fix: I merged it. I rewrote the commit message to clarify its scope. |
It makes me sad, but I'm fine with not adding a test :-) |
In the past, I fixed a risk of shell injection by avoiding a shell in the uuid module: commitb9d0199. I didn't add any test for that neither :-( |
The uuid.getnode() function has multiple implementations, tested sequentially.The ifconfig implementation was incorrect and always failed: fix it.In practice, functions of libuuid library are preferred, if available:uuid_generate_time_safe(), uuid_create() or uuid_generate_time().(cherry picked from commite3ec272)Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
The uuid.getnode() function has multiple implementations, tested sequentially.The ifconfig implementation was incorrect and always failed: fix it.In practice, functions of libuuid library are preferred, if available:uuid_generate_time_safe(), uuid_create() or uuid_generate_time().(cherry picked from commite3ec272)Co-authored-by: Chaim Sanders <csanders-git@users.noreply.github.com>Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
See#98415 for explanation