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
uuid.getnode() MAC address on AIX #61495
Comments
uuid.getnode() on AIX returned random integer. This patch finds MAC in output of |
@aivars sorry about the delay in getting back to you. |
Thanks for the patch, but I'm not even sure AIX is an officially supported platform, so I'm not sure what to do with this patch. |
Huh? What does officially supported platform mean? CPython builds and runs on AIX. |
It means a platform for which we have regular contributors committed We apparently have an unstable buildbot with mainy tests failing (and So it would be nice to have the full regtest pass (with skips if applicable). |
David is listed against AIX on the experts list https://docs.python.org/devguide/experts.html. That alone suggests to me that AIX is an officially supported platform. |
Thank you Aivars for your patch. I have verified and confirm that this method works on AIX and True64 UNIX (it should also work on IRIX, but I can't login in Snakebite's i6). Here is modified patch. MAC address is now searched only in column with the "Address" header. Added try/except around converting to int for the case if candidate word contains non-heximal digits. Synchronized _netstat_getnode() with current code of _find_mac and extracted common code in separate function. Split _ifconfig_getnode() into separate functions which use different commands: ifconfig, arp and lanscan. |
If there are no objections, I'll commit the patch soon. |
My only comment would be to use subprocess instead of os.popen(). |
This is different issue and can be applied only to 3.5. |
Why is that a different issue? Furthermore, the code catches OSError when calling popen(), but |
FYI os.popen() now calls subprocess... So it's safe to call directly subprocess. |
+ cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, '-ia') It's safer to use the subprocess module instead of using a shell (see the recent Shellshock story) to change the environment variables and to redirect stderr. subprocess now has a convinient subprocess.DEVNULL. So it's something like: env = os.environ.copy()
env['LC_ALL'] = 'C'
process = subprocess.Popen([executable, '-ia'], stderr=subprocess.DEVNULL)
... |
Added code is just modified copy of existing code.
It can raise an exception in rare cases. The manual of pipe mentions this. The code of posix_popen() contains error handling.
Not in 2.7.
May be, but this is different issue, which is not related to this issue. If os.popen should be replaced with subprocess, it should be done even without applying the patch of this issue. Please open new issue. However the recent Shellshock story affects only users of platforms which use bash or zsh as system shell (are there any?).
Not in 2.7. |
Here is a patch for 3.5 which uses subprocess.Popen() (subprocess.Popen() used in _find_mac() since bpo-22637). |
You probably forgot to attach the patch... |
Indeed. :-( |
Here are updated patches for 3.5 (using subprocess) and 3.4 (using os.popen) |
New changeset e80cb046e764 by Serhiy Storchaka in branch '2.7': New changeset ba4b31ed2952 by Serhiy Storchaka in branch '3.4': New changeset 3e4f3cc4f1f9 by Serhiy Storchaka in branch 'default': |
Looks as this hasn't broke buildbots. Thank you Aivars for your patch. Thank you Natali and Victor for your suggestions and reviews. |
koobs-freebsd10 buildbot broken on all branches since: 2.7: e80cb046e7641fb8a71dda8254d2e619cdd64480 Full (2.7) log attached. ====================================================================== Traceback (most recent call last):
File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/test/test_uuid.py", line 312, in test_arp_getnode
node = uuid._arp_getnode()
File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/uuid.py", line 348, in _arp_getnode
ip_addr = socket.gethostbyname(socket.gethostname())
gaierror: [Errno 8] hostname nor servname provided, or not known |
This issue had added new tests. Here is a patch against 2.7 (3.4+ should use OSError instead of socket.gaierror) which fixes _arp_getnode(). |
I only attached the 2.7 build log because the failures from 3.4 and 3.x are identical, copying them here for completeness: From 3.4: ====================================================================== Traceback (most recent call last):
File "/usr/home/buildbot/python/3.4.koobs-freebsd10/build/Lib/test/test_uuid.py", line 324, in test_arp_getnode
node = uuid._arp_getnode()
File "/usr/home/buildbot/python/3.4.koobs-freebsd10/build/Lib/uuid.py", line 364, in _arp_getnode
ip_addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: [Errno 8] hostname nor servname provided, or not known Ran 18 tests in 0.209s From 3.x: ====================================================================== Traceback (most recent call last):
File "/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_uuid.py", line 325, in test_arp_getnode
node = uuid._arp_getnode()
File "/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/uuid.py", line 362, in _arp_getnode
ip_addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: [Errno 8] hostname nor servname provided, or not known |
Oh, socket.gaierror was not made an alias of OSError, only subclass of it. Well, we can apply the same patch to all releases. Does it fix tests? |
I don't have the environment to test here. Can you run a custom build on the buildbots? |
New changeset 301d62ef5c0b by Serhiy Storchaka in branch '2.7': New changeset 97ceab0bd6f8 by Serhiy Storchaka in branch '3.4': |
I'm getting socket.gaierror from test_ifconfig_getnode / uuid._ifconfig_getnode() on python 3.4.2 on Linux, in a no network environment. Thus i'd like to see these try:/excepts: to be ported back to 3.4 branch, if they haven't been already. I filed http://bugs.python.org/issue23170 to track my issue. Feel free to close that one as a (related) dupe of this one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: