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.
This commit is contained in:
Todd C. Miller
2012-08-28 10:11:38 -04:00
parent af4f02d3e2
commit f44afdc423
4 changed files with 85 additions and 3 deletions

View File

@@ -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

View File

@@ -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 <sys/select.h> 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 <sys/sockio.h> header file. */
#undef HAVE_SYS_SOCKIO_H

57
configure vendored
View File

@@ -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 <signal.h>
"
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

View File

@@ -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 <signal.h>
])
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