Bug 1326496 - testing:mozbase: Use find_library to get libc filename. r=ahal draft
authorJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Fri, 30 Dec 2016 14:35:55 +0100
changeset 459456 5dbcebea648dc71e4841444a57c135ed19912fdb
parent 459455 bda4716b22c6aabc0dfcfa523920a578c80b5e54
child 541901 e8ce7bc8496e879a42124b5a261b8a346f6cb4ff
push id41227
push userbmo:mh+mozilla@glandium.org
push dateThu, 12 Jan 2017 00:47:30 +0000
reviewersahal
bugs1326496
milestone53.0a1
Bug 1326496 - testing:mozbase: Use find_library to get libc filename. r=ahal On architectures like alpha and ia64, the glibc does not use the canonical ABI version number 6 but 6.1 and therefore the filename of the C library is not libc.so.6 but libc.so.6.1. We're therefore making the Python code more flexible and use find_library from ctypes.util to determine the filename from the environment instead of hard-coding it.
testing/mozbase/mozinfo/mozinfo/mozinfo.py
--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
@@ -10,17 +10,17 @@
 
 from __future__ import absolute_import
 
 import os
 import platform
 import re
 import sys
 from .string_version import StringVersion
-
+from ctypes.util import find_library
 
 # keep a copy of the os module since updating globals overrides this
 _os = os
 
 
 class unknown(object):
     """marker class for unknown information"""
 
@@ -145,17 +145,17 @@ info.update({'processor': processor,
              'bits': int(bits),
              })
 
 if info['os'] == 'linux':
     import ctypes
     import errno
     PR_SET_SECCOMP = 22
     SECCOMP_MODE_FILTER = 2
-    ctypes.CDLL("libc.so.6", use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
+    ctypes.CDLL(find_library("c"), use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
     info['has_sandbox'] = ctypes.get_errno() == errno.EFAULT
 else:
     info['has_sandbox'] = True
 
 # standard value of choices, for easy inspection
 choices = {'os': ['linux', 'bsd', 'win', 'mac', 'unix'],
            'bits': [32, 64],
            'processor': ['x86', 'x86_64', 'ppc']}