gutils: Check whether getauxval function exists

FreeBSD 12 adds a new header, sys/auxv.h, to declare a function, elf_aux_info,
for public use, which was considered an internal function in previous releases.
This new function provides similar functionality with glibc getauxval, which is
also declared in the same header, but their interfaces are not compatible. Since
the only usage of sys/auxv.h is in g_check_setuid and FreeBSD already has
issetugid to provide the required functionality, we fixes the compilation error
by adding a check for getauxval function to prevent g_check_setuid from calling
getauxval when sys/auxv.h is found but getauxval is not available.

https://reviews.freebsd.org/D12743
https://reviews.freebsd.org/rS324815
This commit is contained in:
Ting-Wei Lan 2018-10-28 01:37:39 +08:00 committed by Philip Withnall
parent 6e77089337
commit 295964a380
3 changed files with 3 additions and 1 deletions

View File

@ -862,6 +862,7 @@ AC_CHECK_FUNCS(getmntent_r setmntent endmntent hasmntopt getfsstat getvfsstat fa
case $host_os in aix*) ac_cv_func_splice=no ;; esac # AIX splice() is something else case $host_os in aix*) ac_cv_func_splice=no ;; esac # AIX splice() is something else
AC_CHECK_FUNCS(splice) AC_CHECK_FUNCS(splice)
AC_CHECK_FUNCS(prlimit) AC_CHECK_FUNCS(prlimit)
AC_CHECK_FUNCS(getauxval)
# To avoid finding a compatibility unusable statfs, which typically # To avoid finding a compatibility unusable statfs, which typically
# successfully compiles, but warns to use the newer statvfs interface: # successfully compiles, but warns to use the newer statvfs interface:

View File

@ -2503,7 +2503,7 @@ const gchar *g_get_tmp_dir_utf8 (void) { return g_get_tmp_dir (); }
gboolean gboolean
g_check_setuid (void) g_check_setuid (void)
{ {
#if defined(HAVE_SYS_AUXV_H) #if defined(HAVE_SYS_AUXV_H) && defined(HAVE_GETAUXVAL) && defined(AT_SECURE)
unsigned long value; unsigned long value;
int errsv; int errsv;

View File

@ -397,6 +397,7 @@ functions = [
'fchown', 'fchown',
'fdwalk', 'fdwalk',
'fsync', 'fsync',
'getauxval',
'getc_unlocked', 'getc_unlocked',
'getfsstat', 'getfsstat',
'getgrgid_r', 'getgrgid_r',