From https://android.googlesource.com/platform/external/libselinux