From: Todd C. Miller Date: Tue, 30 Aug 2011 14:05:30 +0000 (-0400) Subject: Add configure test for missing errno declaration and only X-Git-Tag: SUDO_1_8_3~50^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47af0fc2b8c052cf32656bdcd5f37c93393e4393;p=sudo Add configure test for missing errno declaration and only declare it ourselves if it is missing. --- diff --git a/compat/regress/glob/globtest.c b/compat/regress/glob/globtest.c index 0c966fe7c..70de67caf 100644 --- a/compat/regress/glob/globtest.c +++ b/compat/regress/glob/globtest.c @@ -21,11 +21,9 @@ #endif #include -#define MAX_RESULTS 256 +#include "missing.h" -#ifndef errno -extern int errno; -#endif +#define MAX_RESULTS 256 struct gl_entry { int flags; diff --git a/config.h.in b/config.h.in index a0c704597..d0945540a 100644 --- a/config.h.in +++ b/config.h.in @@ -79,6 +79,10 @@ /* Define to 1 if your `DIR' contains dd_fd. */ #undef HAVE_DD_FD +/* Define to 1 if you have the declaration of `errno', and to 0 if you don't. + */ +#undef HAVE_DECL_ERRNO + /* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you don't. */ #undef HAVE_DECL_SYS_SIGLIST diff --git a/configure b/configure index bf25d637a..d58a8df98 100755 --- a/configure +++ b/configure @@ -17758,6 +17758,22 @@ if test X"$enable_zlib" = X"builtin"; then fi +ac_fn_c_check_decl "$LINENO" "errno" "ac_cv_have_decl_errno" " +$ac_includes_default +#include + +" +if test "x$ac_cv_have_decl_errno" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ERRNO $ac_have_decl +_ACEOF + + for ac_func in strsignal do : ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal" diff --git a/configure.in b/configure.in index f7ca72132..d0ce291b5 100644 --- a/configure.in +++ b/configure.in @@ -2300,6 +2300,14 @@ if test X"$enable_zlib" = X"builtin"; then AC_CONFIG_FILES([zlib/Makefile]) fi +dnl +dnl Check for errno declaration in errno.h +dnl +AC_CHECK_DECLS([errno], [], [], [ +AC_INCLUDES_DEFAULT +#include +]) + dnl dnl Check for strsignal() or sys_siglist dnl diff --git a/include/missing.h b/include/missing.h index e7eae3eba..7ac9588cd 100644 --- a/include/missing.h +++ b/include/missing.h @@ -202,6 +202,13 @@ void setprogname(const char *); #endif /* HAVE___PROGNAME */ #endif /* !HAVE_GETPROGNAME */ +/* + * Declare errno if errno.h doesn't do it for us. + */ +#if defined(HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO +extern int errno; +#endif /* !HAVE_DECL_ERRNO */ + #ifndef timevalclear # define timevalclear(tv) ((tv)->tv_sec = (tv)->tv_usec = 0) #endif diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h index 3c8c6a1e3..6e21d9684 100644 --- a/plugins/sudoers/sudoers.h +++ b/plugins/sudoers/sudoers.h @@ -341,9 +341,4 @@ extern sudo_conv_t sudo_conv; extern sudo_printf_t sudo_printf; #endif -/* Some systems don't declare errno in errno.h */ -#ifndef errno -extern int errno; -#endif - #endif /* _SUDO_SUDOERS_H */ diff --git a/src/sudo.h b/src/sudo.h index cbf4860d3..f3155059f 100644 --- a/src/sudo.h +++ b/src/sudo.h @@ -230,8 +230,4 @@ int get_net_ifs(char **addrinfo); /* setgroups.c */ int sudo_setgroups(int ngids, const GETGROUPS_T *gids); -#ifndef errno -extern int errno; -#endif - #endif /* _SUDO_SUDO_H */ diff --git a/src/sudo_noexec.c b/src/sudo_noexec.c index 2c18c6011..7f050aa3f 100644 --- a/src/sudo_noexec.c +++ b/src/sudo_noexec.c @@ -34,10 +34,6 @@ * few programs actually do that. */ -#ifndef errno -extern int errno; -#endif - #define DUMMY_BODY \ { \ errno = EACCES; \