Skip to content

Commit 795ee24

Browse files
Merge pull request #1258 from MaxKellermann/at_secure
cups/globals: use getauxval(AT_SECURE) for SUID check
2 parents 6ccd0de + 5a14257 commit 795ee24

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

config-scripts/cups-common.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ dnl Checks for header files.
132132
AC_CHECK_HEADER([langinfo.h], AC_DEFINE([HAVE_LANGINFO_H], [1], [Have <langinfo.h> header?]))
133133
AC_CHECK_HEADER([malloc.h], AC_DEFINE([HAVE_MALLOC_H], [1], [Have <malloc.h> header?]))
134134
AC_CHECK_HEADER([stdint.h], AC_DEFINE([HAVE_STDINT_H], [1], [Have <stdint.h> header?]))
135+
AC_CHECK_HEADER([sys/auxv.h], AC_DEFINE([HAVE_SYS_AUXV_H], [1], [Have <sys/auxv.h> header?]))
135136
AC_CHECK_HEADER([sys/ioctl.h], AC_DEFINE([HAVE_SYS_IOCTL_H], [1], [Have <sys/ioctl.h> header?]))
136137
AC_CHECK_HEADER([sys/param.h], AC_DEFINE([HAVE_SYS_PARAM_H], [1], [Have <sys/param.h> header?]))
137138
AC_CHECK_HEADER([sys/ucred.h], AC_DEFINE([HAVE_SYS_UCRED_H], [1], [Have <sys/ucred.h> header?]))

config.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@
295295
#undef HAVE_AVAHI
296296

297297

298+
/*
299+
* Do we have <sys/auxv.h>?
300+
*/
301+
302+
#undef HAVE_SYS_AUXV_H
303+
304+
298305
/*
299306
* Do we have <sys/ioctl.h>?
300307
*/

cups/globals.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include "debug-internal.h"
1414
#ifndef _WIN32
1515
# include <pwd.h>
16+
# ifdef HAVE_SYS_AUXV_H
17+
# include <sys/auxv.h> // for getauxval()
18+
# endif
1619
#endif /* !_WIN32 */
1720

1821

@@ -294,7 +297,9 @@ cups_globals_alloc(void)
294297
*xdg_config_home = getenv("XDG_CONFIG_HOME");
295298
// Environment variables
296299
# endif // !__APPLE__
297-
# ifdef HAVE_GETEUID
300+
# if defined(HAVE_SYS_AUXV_H) && defined(AT_SECURE)
301+
if (getauxval(AT_SECURE))
302+
# elif defined(HAVE_GETEUID)
298303
if ((geteuid() != getuid() && getuid()) || getegid() != getgid())
299304
# else
300305
if (!getuid())

0 commit comments

Comments
 (0)