From f44afdc4232d6bc0593b0e66d50a137c216e1a5c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 28 Aug 2012 10:11:38 -0400 Subject: [PATCH] Detect sys_sigabbrev[] and use it in place of sys_signame[] if present. For some reason glibc does not declare sys_sigabbrev so we must add an extern definition of our own. --- compat/strsigname.c | 6 +++++ config.h.in | 7 ++++++ configure | 57 ++++++++++++++++++++++++++++++++++++++++++++- configure.in | 18 ++++++++++++-- 4 files changed, 85 insertions(+), 3 deletions(-) diff --git a/compat/strsigname.c b/compat/strsigname.c index 6194724ff..3470c7efb 100644 --- a/compat/strsigname.c +++ b/compat/strsigname.c @@ -32,7 +32,13 @@ # define sudo_sys_signame _sys_signame #elif defined(HAVE_DECL___SYS_SIGNAME) && HAVE_DECL___SYS_SIGNAME == 1 # define sudo_sys_signame __sys_signame +#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1 +# define sudo_sys_signame sys_sigabbrev #else +# ifdef HAVE_SYS_SIGABBREV + /* sys_sigabbrev is not declared by glibc */ +# define sudo_sys_signame sys_sigabbrev +# endif extern const char *const sudo_sys_signame[NSIG]; #endif diff --git a/config.h.in b/config.h.in index a05208ea4..9f7990dad 100644 --- a/config.h.in +++ b/config.h.in @@ -87,6 +87,10 @@ don't. */ #undef HAVE_DECL_H_ERRNO +/* Define to 1 if you have the declaration of `sys_sigabbrev', and to 0 if you + don't. */ +#undef HAVE_DECL_SYS_SIGABBREV + /* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you don't. */ #undef HAVE_DECL_SYS_SIGLIST @@ -639,6 +643,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H +/* Define to 1 if your libc has the `sys_sigabbrev' symbol. */ +#undef HAVE_SYS_SIGABBREV + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKIO_H diff --git a/configure b/configure index 73867656b..7a2748a25 100755 --- a/configure +++ b/configure @@ -18385,15 +18385,69 @@ if test $ac_have_decl = 1; then : HAVE_SIGNAME="true" break +fi +ac_fn_c_check_decl "$LINENO" "sys_sigabbrev" "ac_cv_have_decl_sys_sigabbrev" " +$ac_includes_default +#include + +" +if test "x$ac_cv_have_decl_sys_sigabbrev" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SYS_SIGABBREV $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + + HAVE_SIGNAME="true" + break + fi if test "$HAVE_SIGNAME" != "true"; then - case " $LIBOBJS " in + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for undeclared sys_sigabbrev" >&5 +$as_echo_n "checking for undeclared sys_sigabbrev... " >&6; } +if ${sudo_cv_var_sys_sigabbrev+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +extern char **sys_sigabbrev; +int +main () +{ +return sys_sigabbrev[1]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + sudo_cv_var_sys_sigabbrev=yes +else + sudo_cv_var_sys_sigabbrev=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_sys_sigabbrev" >&5 +$as_echo "$sudo_cv_var_sys_sigabbrev" >&6; } + if test "$sudo_cv_var_sys_sigabbrev" = yes; then + $as_echo "#define HAVE_SYS_SIGABBREV 1" >>confdefs.h + + else + case " $LIBOBJS " in *" signame.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS signame.$ac_objext" ;; esac + fi fi fi @@ -23246,5 +23300,6 @@ fi + diff --git a/configure.in b/configure.in index 43ec11d4f..ce27db9b8 100644 --- a/configure.in +++ b/configure.in @@ -2574,7 +2574,7 @@ dnl AC_CHECK_FUNCS(strsigname, [], [ AC_LIBOBJ(strsigname) HAVE_SIGNAME="false" - AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame], [ + AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame, sys_sigabbrev], [ HAVE_SIGNAME="true" break ], [ ], [ @@ -2582,7 +2582,20 @@ AC_INCLUDES_DEFAULT #include ]) if test "$HAVE_SIGNAME" != "true"; then - AC_LIBOBJ(signame) + AC_CACHE_CHECK([for undeclared sys_sigabbrev], + [sudo_cv_var_sys_sigabbrev], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[extern char **sys_sigabbrev;]], [[return sys_sigabbrev[1];]])], + [sudo_cv_var_sys_sigabbrev=yes], + [sudo_cv_var_sys_sigabbrev=no] + ) + ] + ) + if test "$sudo_cv_var_sys_sigabbrev" = yes; then + AC_DEFINE(HAVE_SYS_SIGABBREV) + else + AC_LIBOBJ(signame) + fi fi ]) @@ -3627,6 +3640,7 @@ AH_TEMPLATE(RTLD_PRELOAD_ENABLE_VAR, [An extra environment variable that is requ AH_TEMPLATE(RTLD_PRELOAD_DELIM, [The delimiter to use when defining multiple preloaded objects.]) AH_TEMPLATE(RTLD_PRELOAD_DEFAULT, [The default value of preloaded objects (if any).]) AH_TEMPLATE(HAVE_DSO_VISIBILITY, [Define to 1 if the compiler supports the __visibility__ attribute.]) +AH_TEMPLATE(HAVE_SYS_SIGABBREV, [Define to 1 if your libc has the `sys_sigabbrev' symbol.]) dnl dnl Bits to copy verbatim into config.h.in -- 2.40.0