diff --git a/config.h.in b/config.h.in index 8567a323d..2501ffd5e 100644 --- a/config.h.in +++ b/config.h.in @@ -107,6 +107,10 @@ */ #undef HAVE_DECL_ERRNO +/* Define to 1 if you have the declaration of `getdelim', and to 0 if you + don't. */ +#undef HAVE_DECL_GETDELIM + /* Define to 1 if you have the declaration of `getdomainname', and to 0 if you don't. */ #undef HAVE_DECL_GETDOMAINNAME diff --git a/configure b/configure index d1471a48b..1ab6b8c83 100755 --- a/configure +++ b/configure @@ -19901,6 +19901,19 @@ if test "x$ac_cv_func_getdelim" = xyes; then : #define HAVE_GETDELIM 1 _ACEOF + # Out of date gcc fixed includes may result in missing getdelim() prototype + ac_fn_c_check_decl "$LINENO" "getdelim" "ac_cv_have_decl_getdelim" "$ac_includes_default" +if test "x$ac_cv_have_decl_getdelim" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETDELIM $ac_have_decl +_ACEOF + + else case " $LIBOBJS " in diff --git a/configure.ac b/configure.ac index 321d24b55..bb6190688 100644 --- a/configure.ac +++ b/configure.ac @@ -2680,7 +2680,10 @@ AC_CHECK_FUNCS([getgrouplist], [], [ esac SUDO_APPEND_COMPAT_EXP(sudo_getgrouplist) ]) -AC_CHECK_FUNCS([getdelim], [], [ +AC_CHECK_FUNCS([getdelim], [ + # Out of date gcc fixed includes may result in missing getdelim() prototype + AC_CHECK_DECLS([getdelim]) +], [ AC_LIBOBJ(getdelim) SUDO_APPEND_COMPAT_EXP(sudo_getdelim) COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }getdelim_test" diff --git a/include/sudo_compat.h b/include/sudo_compat.h index 51afd6fcb..80c007b93 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -446,10 +446,13 @@ __dso_public int sudo_getgrouplist(const char *name, GETGROUPS_T basegid, GETGRO # undef getgrouplist # define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d)) #endif /* GETGROUPLIST */ -#ifndef HAVE_GETDELIM +#if !defined(HAVE_GETDELIM) __dso_public ssize_t sudo_getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp); # undef getdelim # define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d)) +#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM +/* getdelim present in libc but missing prototype (old gcc fixed includes?) */ +ssize_t getdelim(char **bufp, size_t *bufsizep, int delim, FILE *fp); #endif /* HAVE_GETDELIM */ #ifndef HAVE_GETUSERSHELL __dso_public char *sudo_getusershell(void);