diff options
author | Mina Galić (deprecated: Igor Galić) <me+git@igalic.co> | 2020-05-18 17:42:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 11:42:43 -0400 |
commit | 904ad3670f95ccc2ae89e6ebf68c9f67c4edbb25 (patch) | |
tree | 2562dfb4cc60bbc6a5bc989dff4ac24aa29e1233 | |
parent | e7a8da75fa7a0063ac9eba11a0ab120c20b3be07 (diff) | |
download | vyos-cloud-init-904ad3670f95ccc2ae89e6ebf68c9f67c4edbb25.tar.gz vyos-cloud-init-904ad3670f95ccc2ae89e6ebf68c9f67c4edbb25.zip |
make finding libc platform independent (#366)
and slower.
and since we're making it slower, let's cache it, in case boottime gets
called more than once.
-rw-r--r-- | cloudinit/util.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 4cae7ec8..985e7d20 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1866,6 +1866,7 @@ def time_rfc2822(): return ts +@lru_cache() def boottime(): """Use sysctlbyname(3) via ctypes to find kern.boottime @@ -1875,6 +1876,7 @@ def boottime(): @return boottime: float to be compatible with linux """ import ctypes + import ctypes.util NULL_BYTES = b"\x00" @@ -1883,7 +1885,7 @@ def boottime(): ("tv_sec", ctypes.c_int64), ("tv_usec", ctypes.c_int64) ] - libc = ctypes.CDLL('libc.so') + libc = ctypes.CDLL(ctypes.util.find_library('c')) size = ctypes.c_size_t() size.value = ctypes.sizeof(timeval) buf = timeval() |