Use sigabbrev_np(3) to access signal abbreviations if supported.
glibc-2.32 has removed sys_sigabbrev[], we can use sigabbrev_np(3) instead.
This commit is contained in:
@@ -740,6 +740,9 @@
|
|||||||
/* Define to 1 if you have the `sig2str' function. */
|
/* Define to 1 if you have the `sig2str' function. */
|
||||||
#undef HAVE_SIG2STR
|
#undef HAVE_SIG2STR
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sigabbrev_np' function. */
|
||||||
|
#undef HAVE_SIGABBREV_NP
|
||||||
|
|
||||||
/* Define to 1 if you use S/Key. */
|
/* Define to 1 if you use S/Key. */
|
||||||
#undef HAVE_SKEY
|
#undef HAVE_SKEY
|
||||||
|
|
||||||
|
13
configure
vendored
13
configure
vendored
@@ -23687,6 +23687,18 @@ done
|
|||||||
|
|
||||||
|
|
||||||
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
|
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
|
||||||
|
for ac_func in sigabbrev_np
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "sigabbrev_np" "ac_cv_func_sigabbrev_np"
|
||||||
|
if test "x$ac_cv_func_sigabbrev_np" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_SIGABBREV_NP 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if test x"${ac_cv_func_sigabbrev_np}" != x"yes"; then
|
||||||
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
|
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
|
||||||
HAVE_SIGNAME="false"
|
HAVE_SIGNAME="false"
|
||||||
ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" "
|
ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" "
|
||||||
@@ -23791,6 +23803,7 @@ esac
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
OLIBS="$LIBS"
|
OLIBS="$LIBS"
|
||||||
LIBS="$LIBS $lt_cv_dlopen_libs"
|
LIBS="$LIBS $lt_cv_dlopen_libs"
|
||||||
|
@@ -3498,6 +3498,8 @@ dnl Check for sys_signame or sys_sigabbrev if missing sig2str() or str2sig().
|
|||||||
dnl Also enable unit tests for sig2str() and str2sig().
|
dnl Also enable unit tests for sig2str() and str2sig().
|
||||||
dnl
|
dnl
|
||||||
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
|
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
|
||||||
|
AC_CHECK_FUNCS([sigabbrev_np])
|
||||||
|
if test x"${ac_cv_func_sigabbrev_np}" != x"yes"; then
|
||||||
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
|
COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
|
||||||
HAVE_SIGNAME="false"
|
HAVE_SIGNAME="false"
|
||||||
AC_CHECK_DECLS([sys_signame, _sys_signame, sys_sigabbrev], [
|
AC_CHECK_DECLS([sys_signame, _sys_signame, sys_sigabbrev], [
|
||||||
@@ -3524,6 +3526,7 @@ AC_INCLUDES_DEFAULT
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl Check for dl_iterate_phdr, may require -ldl
|
dnl Check for dl_iterate_phdr, may require -ldl
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: ISC
|
* SPDX-License-Identifier: ISC
|
||||||
*
|
*
|
||||||
* Copyright (c) 2012-2015, 2017-2019 Todd C. Miller <Todd.Miller@sudo.ws>
|
* Copyright (c) 2012-2015, 2017-2020 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -32,20 +32,24 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
|
#include "sudo_util.h"
|
||||||
|
|
||||||
|
#if !defined(HAVE_SIGABBREV_NP)
|
||||||
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame sys_signame
|
# define sigabbrev_np(_x) sys_signame[(_x)]
|
||||||
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame _sys_signame
|
# define sigabbrev_np(_x) _sys_signame[(_x)]
|
||||||
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
|
# elif defined(HAVE_SYS_SIGABBREV)
|
||||||
# define sudo_sys_signame sys_sigabbrev
|
# define sigabbrev_np(_x) sys_sigabbrev[(_x)]
|
||||||
#else
|
# if defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 0
|
||||||
# ifdef HAVE_SYS_SIGABBREV
|
|
||||||
/* sys_sigabbrev is not declared by glibc */
|
/* sys_sigabbrev is not declared by glibc */
|
||||||
# define sudo_sys_signame sys_sigabbrev
|
extern const char *const sys_sigabbrev[NSIG];
|
||||||
# endif
|
# endif
|
||||||
|
# else
|
||||||
|
# define sigabbrev_np(_x) sudo_sys_signame[(_x)]
|
||||||
extern const char *const sudo_sys_signame[NSIG];
|
extern const char *const sudo_sys_signame[NSIG];
|
||||||
# endif
|
# endif
|
||||||
|
#endif /* !HAVE_SIGABBREV_NP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate signal number to name.
|
* Translate signal number to name.
|
||||||
@@ -77,8 +81,10 @@ sudo_sig2str(int signo, char *signame)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL) {
|
if (signo > 0 && signo < NSIG) {
|
||||||
strlcpy(signame, sudo_sys_signame[signo], SIG2STR_MAX);
|
const char *cp = sigabbrev_np(signo);
|
||||||
|
if (cp != NULL) {
|
||||||
|
strlcpy(signame, cp, SIG2STR_MAX);
|
||||||
/* Make sure we always return an upper case signame. */
|
/* Make sure we always return an upper case signame. */
|
||||||
if (islower((unsigned char)signame[0])) {
|
if (islower((unsigned char)signame[0])) {
|
||||||
int i;
|
int i;
|
||||||
@@ -87,6 +93,7 @@ sudo_sig2str(int signo, char *signame)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-License-Identifier: ISC
|
* SPDX-License-Identifier: ISC
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Todd C. Miller <Todd.Miller@sudo.ws>
|
* Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -37,19 +37,22 @@
|
|||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
#include "sudo_util.h"
|
#include "sudo_util.h"
|
||||||
|
|
||||||
|
#if !defined(HAVE_SIGABBREV_NP)
|
||||||
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame sys_signame
|
# define sigabbrev_np(_x) sys_signame[(_x)]
|
||||||
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
|
||||||
# define sudo_sys_signame _sys_signame
|
# define sigabbrev_np(_x) _sys_signame[(_x)]
|
||||||
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
|
# elif defined(HAVE_SYS_SIGABBREV)
|
||||||
# define sudo_sys_signame sys_sigabbrev
|
# define sigabbrev_np(_x) sys_sigabbrev[(_x)]
|
||||||
#else
|
# if defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 0
|
||||||
# ifdef HAVE_SYS_SIGABBREV
|
|
||||||
/* sys_sigabbrev is not declared by glibc */
|
/* sys_sigabbrev is not declared by glibc */
|
||||||
# define sudo_sys_signame sys_sigabbrev
|
extern const char *const sys_sigabbrev[NSIG];
|
||||||
# endif
|
# endif
|
||||||
|
# else
|
||||||
|
# define sigabbrev_np(_x) sudo_sys_signame[(_x)]
|
||||||
extern const char *const sudo_sys_signame[NSIG];
|
extern const char *const sudo_sys_signame[NSIG];
|
||||||
# endif
|
# endif
|
||||||
|
#endif /* !HAVE_SIGABBREV_NP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Many systems use aliases for source backward compatibility.
|
* Many systems use aliases for source backward compatibility.
|
||||||
@@ -154,11 +157,11 @@ sudo_str2sig(const char *signame, int *result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check sys_signame[]. */
|
|
||||||
for (signo = 1; signo < NSIG; signo++) {
|
for (signo = 1; signo < NSIG; signo++) {
|
||||||
if (sudo_sys_signame[signo] != NULL) {
|
const char *cp = sigabbrev_np(signo);
|
||||||
|
if (cp != NULL) {
|
||||||
/* On macOS sys_signame[] may contain lower-case names. */
|
/* On macOS sys_signame[] may contain lower-case names. */
|
||||||
if (strcasecmp(signame, sudo_sys_signame[signo]) == 0) {
|
if (strcasecmp(signame, cp) == 0) {
|
||||||
*result = signo;
|
*result = signo;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user