Merge branch 'remove-secure-libc' into 'master'

Remove unused HAVE_LIBC_ENABLE_SECURE  and add a glibc implementation for g_check_setuid

See merge request GNOME/glib!45
This commit is contained in:
Xavier Claessens 2018-05-31 16:20:12 +00:00
commit 09b8c6d24b
5 changed files with 19 additions and 30 deletions

View File

@ -250,9 +250,6 @@
/* Define if your <locale.h> file defines LC_MESSAGES. */ /* Define if your <locale.h> file defines LC_MESSAGES. */
#mesondefine HAVE_LC_MESSAGES #mesondefine HAVE_LC_MESSAGES
/* Define if you have the __libc_enable_secure variable (GNU libc, eglibc) */
#mesondefine HAVE_LIBC_ENABLE_SECURE
/* Define if libelf is available */ /* Define if libelf is available */
#mesondefine HAVE_LIBELF #mesondefine HAVE_LIBELF
@ -528,6 +525,9 @@
*/ */
#mesondefine HAVE_SYS_DIR_H #mesondefine HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/auxv.h> header file. */
#mesondefine HAVE_SYS_AUXV_H
/* Define to 1 if you have the <sys/event.h> header file. */ /* Define to 1 if you have the <sys/event.h> header file. */
#mesondefine HAVE_SYS_EVENT_H #mesondefine HAVE_SYS_EVENT_H

View File

@ -254,9 +254,6 @@
/* Define if your <locale.h> file defines LC_MESSAGES. */ /* Define if your <locale.h> file defines LC_MESSAGES. */
/* #undef HAVE_LC_MESSAGES */ /* #undef HAVE_LC_MESSAGES */
/* Define if you have the __libc_enable_secure variable (GNU libc, eglibc) */
/* #undef HAVE_LIBC_ENABLE_SECURE */
/* Define if libelf is available */ /* Define if libelf is available */
/* #undef HAVE_LIBELF */ /* #undef HAVE_LIBELF */

View File

@ -506,17 +506,6 @@ AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2 issetugid)
AC_CHECK_FUNCS(timegm gmtime_r) AC_CHECK_FUNCS(timegm gmtime_r)
AC_FUNC_STRERROR_R() AC_FUNC_STRERROR_R()
AC_CACHE_CHECK([for __libc_enable_secure], glib_cv_have_libc_enable_secure,
[AC_TRY_LINK([#include <unistd.h>
extern int __libc_enable_secure;],
[return __libc_enable_secure;],
glib_cv_have_libc_enable_secure=yes,
glib_cv_have_libc_enable_secure=no)])
AS_IF([test x$glib_cv_have_libc_enable_secure = xyes], [
AC_DEFINE(HAVE_LIBC_ENABLE_SECURE, 1,
[Define if you have the __libc_enable_secure variable (GNU libc, eglibc)])
])
AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long)
@ -685,7 +674,7 @@ fi
# check for header files # check for header files
AC_CHECK_HEADERS([sys/param.h sys/resource.h mach/mach_time.h]) AC_CHECK_HEADERS([sys/param.h sys/resource.h mach/mach_time.h])
AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h]) AC_CHECK_HEADERS([sys/select.h stdint.h inttypes.h sched.h malloc.h])
AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h]) AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h sys/auxv.h])
AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h]) AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
AC_CHECK_HEADERS([linux/magic.h]) AC_CHECK_HEADERS([linux/magic.h])
AC_CHECK_HEADERS([termios.h]) AC_CHECK_HEADERS([termios.h])

View File

@ -50,6 +50,9 @@
#ifdef HAVE_CRT_EXTERNS_H #ifdef HAVE_CRT_EXTERNS_H
#include <crt_externs.h> /* for _NSGetEnviron */ #include <crt_externs.h> /* for _NSGetEnviron */
#endif #endif
#ifdef HAVE_SYS_AUXV_H
#include <sys/auxv.h>
#endif
#include "glib-init.h" #include "glib-init.h"
#include "glib-private.h" #include "glib-private.h"
@ -2495,22 +2498,21 @@ const gchar *g_get_tmp_dir_utf8 (void) { return g_get_tmp_dir (); }
/* Private API: /* Private API:
* *
* Returns %TRUE if the current process was executed as setuid (or an * Returns %TRUE if the current process was executed as setuid
* equivalent __libc_enable_secure is available). See:
* http://osdir.com/ml/linux.lfs.hardened/2007-04/msg00032.html
*/ */
gboolean gboolean
g_check_setuid (void) g_check_setuid (void)
{ {
/* TODO: get __libc_enable_secure exported from glibc. #if defined(HAVE_SYS_AUXV_H)
* See http://www.openwall.com/lists/owl-dev/2012/08/14/1 unsigned long value;
*/ int errsv;
#if 0 && defined(HAVE_LIBC_ENABLE_SECURE)
{ errno = 0;
/* See glibc/include/unistd.h */ value = getauxval (AT_SECURE);
extern int __libc_enable_secure; errsv = errno;
return __libc_enable_secure; if (errsv)
} g_error ("getauxval () failed: %s", g_strerror (errsv));
return value;
#elif defined(HAVE_ISSETUGID) && !defined(__BIONIC__) #elif defined(HAVE_ISSETUGID) && !defined(__BIONIC__)
/* BSD: http://www.freebsd.org/cgi/man.cgi?query=issetugid&sektion=2 */ /* BSD: http://www.freebsd.org/cgi/man.cgi?query=issetugid&sektion=2 */

View File

@ -229,6 +229,7 @@ headers = [
'stdlib.h', 'stdlib.h',
'string.h', 'string.h',
'strings.h', 'strings.h',
'sys/auxv.h',
'sys/event.h', 'sys/event.h',
'sys/filio.h', 'sys/filio.h',
'sys/inotify.h', 'sys/inotify.h',