Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 739016
Collapse All | Expand All

(-)a/config.h.in (+3 lines)
Lines 740-745 Link Here
740
/* Define to 1 if you have the `sig2str' function. */
740
/* Define to 1 if you have the `sig2str' function. */
741
#undef HAVE_SIG2STR
741
#undef HAVE_SIG2STR
742
742
743
/* Define to 1 if you have the `sigabbrev_np' function. */
744
#undef HAVE_SIGABBREV_NP
745
743
/* Define to 1 if you use S/Key. */
746
/* Define to 1 if you use S/Key. */
744
#undef HAVE_SKEY
747
#undef HAVE_SKEY
745
748
(-)a/configure (-17 / +30 lines)
Lines 23687-23695 Link Here
23687
23687
23688
23688
23689
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
23689
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
23690
    COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
23690
    for ac_func in sigabbrev_np
23691
    HAVE_SIGNAME="false"
23691
do :
23692
    ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" "
23692
  ac_fn_c_check_func "$LINENO" "sigabbrev_np" "ac_cv_func_sigabbrev_np"
23693
if test "x$ac_cv_func_sigabbrev_np" = xyes; then :
23694
  cat >>confdefs.h <<_ACEOF
23695
#define HAVE_SIGABBREV_NP 1
23696
_ACEOF
23697
23698
fi
23699
done
23700
23701
    if test x"${ac_cv_func_sigabbrev_np}" != x"yes"; then
23702
	COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
23703
	HAVE_SIGNAME="false"
23704
	ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" "
23693
$ac_includes_default
23705
$ac_includes_default
23694
#include <signal.h>
23706
#include <signal.h>
23695
23707
Lines 23705-23711 Link Here
23705
_ACEOF
23717
_ACEOF
23706
if test $ac_have_decl = 1; then :
23718
if test $ac_have_decl = 1; then :
23707
23719
23708
	HAVE_SIGNAME="true"
23720
	    HAVE_SIGNAME="true"
23709
23721
23710
fi
23722
fi
23711
ac_fn_c_check_decl "$LINENO" "_sys_signame" "ac_cv_have_decl__sys_signame" "
23723
ac_fn_c_check_decl "$LINENO" "_sys_signame" "ac_cv_have_decl__sys_signame" "
Lines 23724-23730 Link Here
23724
_ACEOF
23736
_ACEOF
23725
if test $ac_have_decl = 1; then :
23737
if test $ac_have_decl = 1; then :
23726
23738
23727
	HAVE_SIGNAME="true"
23739
	    HAVE_SIGNAME="true"
23728
23740
23729
fi
23741
fi
23730
ac_fn_c_check_decl "$LINENO" "sys_sigabbrev" "ac_cv_have_decl_sys_sigabbrev" "
23742
ac_fn_c_check_decl "$LINENO" "sys_sigabbrev" "ac_cv_have_decl_sys_sigabbrev" "
Lines 23743-23754 Link Here
23743
_ACEOF
23755
_ACEOF
23744
if test $ac_have_decl = 1; then :
23756
if test $ac_have_decl = 1; then :
23745
23757
23746
	HAVE_SIGNAME="true"
23758
	    HAVE_SIGNAME="true"
23747
23759
23748
fi
23760
fi
23749
23761
23750
    if test "$HAVE_SIGNAME" != "true"; then
23762
	if test "$HAVE_SIGNAME" != "true"; then
23751
	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for undeclared sys_sigabbrev" >&5
23763
	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for undeclared sys_sigabbrev" >&5
23752
$as_echo_n "checking for undeclared sys_sigabbrev... " >&6; }
23764
$as_echo_n "checking for undeclared sys_sigabbrev... " >&6; }
23753
if ${sudo_cv_var_sys_sigabbrev+:} false; then :
23765
if ${sudo_cv_var_sys_sigabbrev+:} false; then :
23754
  $as_echo_n "(cached) " >&6
23766
  $as_echo_n "(cached) " >&6
Lines 23777-23793 Link Here
23777
fi
23789
fi
23778
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_sys_sigabbrev" >&5
23790
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_var_sys_sigabbrev" >&5
23779
$as_echo "$sudo_cv_var_sys_sigabbrev" >&6; }
23791
$as_echo "$sudo_cv_var_sys_sigabbrev" >&6; }
23780
	if test "$sudo_cv_var_sys_sigabbrev" = yes; then
23792
	    if test "$sudo_cv_var_sys_sigabbrev" = yes; then
23781
	    $as_echo "#define HAVE_SYS_SIGABBREV 1" >>confdefs.h
23793
		$as_echo "#define HAVE_SYS_SIGABBREV 1" >>confdefs.h
23782
23794
23783
	else
23795
	    else
23784
	    case " $LIBOBJS " in
23796
		case " $LIBOBJS " in
23785
  *" signame.$ac_objext "* ) ;;
23797
  *" signame.$ac_objext "* ) ;;
23786
  *) LIBOBJS="$LIBOBJS signame.$ac_objext"
23798
  *) LIBOBJS="$LIBOBJS signame.$ac_objext"
23787
 ;;
23799
 ;;
23788
esac
23800
esac
23789
23801
23790
	    SIGNAME=signame.lo
23802
		SIGNAME=signame.lo
23803
	    fi
23791
	fi
23804
	fi
23792
    fi
23805
    fi
23793
fi
23806
fi
(-)a/configure.ac (-21 / +24 lines)
Lines 3498-3526 Link Here
3498
dnl Also enable unit tests for sig2str() and str2sig().
3498
dnl Also enable unit tests for sig2str() and str2sig().
3499
dnl
3499
dnl
3500
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
3500
if test x"${ac_cv_func_sig2str}${ac_cv_func_str2sig}" != x"yesyes"; then
3501
    COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
3501
    AC_CHECK_FUNCS([sigabbrev_np])
3502
    HAVE_SIGNAME="false"
3502
    if test x"${ac_cv_func_sigabbrev_np}" != x"yes"; then
3503
    AC_CHECK_DECLS([sys_signame, _sys_signame, sys_sigabbrev], [
3503
	COMPAT_TEST_PROGS="${COMPAT_TEST_PROGS}${COMPAT_TEST_PROGS+ }strsig_test"
3504
	HAVE_SIGNAME="true"
3504
	HAVE_SIGNAME="false"
3505
    ], [ ], [
3505
	AC_CHECK_DECLS([sys_signame, _sys_signame, sys_sigabbrev], [
3506
	    HAVE_SIGNAME="true"
3507
	], [ ], [
3506
AC_INCLUDES_DEFAULT
3508
AC_INCLUDES_DEFAULT
3507
#include <signal.h>
3509
#include <signal.h>
3508
    ])
3510
	])
3509
    if test "$HAVE_SIGNAME" != "true"; then
3511
	if test "$HAVE_SIGNAME" != "true"; then
3510
	AC_CACHE_CHECK([for undeclared sys_sigabbrev],
3512
	    AC_CACHE_CHECK([for undeclared sys_sigabbrev],
3511
	    [sudo_cv_var_sys_sigabbrev],
3513
		[sudo_cv_var_sys_sigabbrev],
3512
	    [AC_LINK_IFELSE(
3514
		[AC_LINK_IFELSE(
3513
		[AC_LANG_PROGRAM([[extern char **sys_sigabbrev;]], [[return sys_sigabbrev[1];]])],
3515
		    [AC_LANG_PROGRAM([[extern char **sys_sigabbrev;]], [[return sys_sigabbrev[1];]])],
3514
		    [sudo_cv_var_sys_sigabbrev=yes],
3516
			[sudo_cv_var_sys_sigabbrev=yes],
3515
		    [sudo_cv_var_sys_sigabbrev=no]
3517
			[sudo_cv_var_sys_sigabbrev=no]
3516
		)
3518
		    )
3517
	    ]
3519
		]
3518
	)
3520
	    )
3519
	if test "$sudo_cv_var_sys_sigabbrev" = yes; then
3521
	    if test "$sudo_cv_var_sys_sigabbrev" = yes; then
3520
	    AC_DEFINE(HAVE_SYS_SIGABBREV)
3522
		AC_DEFINE(HAVE_SYS_SIGABBREV)
3521
	else
3523
	    else
3522
	    AC_LIBOBJ(signame)
3524
		AC_LIBOBJ(signame)
3523
	    SIGNAME=signame.lo
3525
		SIGNAME=signame.lo
3526
	    fi
3524
	fi
3527
	fi
3525
    fi
3528
    fi
3526
fi
3529
fi
(-)a/lib/util/sig2str.c (-21 / +28 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * SPDX-License-Identifier: ISC
2
 * SPDX-License-Identifier: ISC
3
 *
3
 *
4
 * Copyright (c) 2012-2015, 2017-2019 Todd C. Miller <Todd.Miller@sudo.ws>
4
 * Copyright (c) 2012-2015, 2017-2020 Todd C. Miller <Todd.Miller@sudo.ws>
5
 *
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
7
 * purpose with or without fee is hereby granted, provided that the above
Lines 32-51 Link Here
32
#include <unistd.h>
32
#include <unistd.h>
33
33
34
#include "sudo_compat.h"
34
#include "sudo_compat.h"
35
#include "sudo_util.h"
35
36
36
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
37
#if !defined(HAVE_SIGABBREV_NP)
37
#  define sudo_sys_signame	sys_signame
38
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
38
#elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
39
#   define sigabbrev_np(_x)	sys_signame[(_x)]
39
#  define sudo_sys_signame	_sys_signame
40
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
40
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
41
#   define sigabbrev_np(_x)	_sys_signame[(_x)]
41
#  define sudo_sys_signame	sys_sigabbrev
42
# elif defined(HAVE_SYS_SIGABBREV)
42
#else
43
#   define sigabbrev_np(_x)	sys_sigabbrev[(_x)]
43
# ifdef HAVE_SYS_SIGABBREV
44
#  if defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 0
44
   /* sys_sigabbrev is not declared by glibc */
45
    /* sys_sigabbrev is not declared by glibc */
45
#  define sudo_sys_signame	sys_sigabbrev
46
    extern const char *const sys_sigabbrev[NSIG];
47
#  endif
48
# else
49
#   define sigabbrev_np(_x)	sudo_sys_signame[(_x)]
50
    extern const char *const sudo_sys_signame[NSIG];
46
# endif
51
# endif
47
extern const char *const sudo_sys_signame[NSIG];
52
#endif /* !HAVE_SIGABBREV_NP */
48
#endif
49
53
50
/*
54
/*
51
 * Translate signal number to name.
55
 * Translate signal number to name.
Lines 77-91 Link Here
77
	return 0;
81
	return 0;
78
    }
82
    }
79
#endif
83
#endif
80
    if (signo > 0 && signo < NSIG && sudo_sys_signame[signo] != NULL) {
84
    if (signo > 0 && signo < NSIG) {
81
	strlcpy(signame, sudo_sys_signame[signo], SIG2STR_MAX);
85
	const char *cp = sigabbrev_np(signo);
82
	/* Make sure we always return an upper case signame. */
86
	if (cp != NULL) {
83
	if (islower((unsigned char)signame[0])) {
87
	    strlcpy(signame, cp, SIG2STR_MAX);
84
	    int i;
88
	    /* Make sure we always return an upper case signame. */
85
	    for (i = 0; signame[i] != '\0'; i++)
89
	    if (islower((unsigned char)signame[0])) {
86
		signame[i] = toupper((unsigned char)signame[i]);
90
		int i;
91
		for (i = 0; signame[i] != '\0'; i++)
92
		    signame[i] = toupper((unsigned char)signame[i]);
93
	    }
94
	    return 0;
87
	}
95
	}
88
	return 0;
89
    }
96
    }
90
    errno = EINVAL;
97
    errno = EINVAL;
91
    return -1;
98
    return -1;
(-)a/lib/util/str2sig.c (-16 / +19 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * SPDX-License-Identifier: ISC
2
 * SPDX-License-Identifier: ISC
3
 *
3
 *
4
 * Copyright (c) 2019 Todd C. Miller <Todd.Miller@sudo.ws>
4
 * Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
5
 *
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
7
 * purpose with or without fee is hereby granted, provided that the above
Lines 37-55 Link Here
37
#include "sudo_compat.h"
37
#include "sudo_compat.h"
38
#include "sudo_util.h"
38
#include "sudo_util.h"
39
39
40
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
40
#if !defined(HAVE_SIGABBREV_NP)
41
#  define sudo_sys_signame	sys_signame
41
# if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
42
#elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
42
#   define sigabbrev_np(_x)	sys_signame[(_x)]
43
#  define sudo_sys_signame	_sys_signame
43
# elif defined(HAVE_DECL__SYS_SIGNAME) && HAVE_DECL__SYS_SIGNAME == 1
44
#elif defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 1
44
#   define sigabbrev_np(_x)	_sys_signame[(_x)]
45
#  define sudo_sys_signame	sys_sigabbrev
45
# elif defined(HAVE_SYS_SIGABBREV)
46
#else
46
#   define sigabbrev_np(_x)	sys_sigabbrev[(_x)]
47
# ifdef HAVE_SYS_SIGABBREV
47
#  if defined(HAVE_DECL_SYS_SIGABBREV) && HAVE_DECL_SYS_SIGABBREV == 0
48
   /* sys_sigabbrev is not declared by glibc */
48
    /* sys_sigabbrev is not declared by glibc */
49
#  define sudo_sys_signame	sys_sigabbrev
49
    extern const char *const sys_sigabbrev[NSIG];
50
#  endif
51
# else
52
#   define sigabbrev_np(_x)	sudo_sys_signame[(_x)]
53
    extern const char *const sudo_sys_signame[NSIG];
50
# endif
54
# endif
51
extern const char *const sudo_sys_signame[NSIG];
55
#endif /* !HAVE_SIGABBREV_NP */
52
#endif
53
56
54
/*
57
/*
55
 * Many systems use aliases for source backward compatibility.
58
 * Many systems use aliases for source backward compatibility.
Lines 154-164 Link Here
154
	}
157
	}
155
    }
158
    }
156
159
157
    /* Check sys_signame[]. */
158
    for (signo = 1; signo < NSIG; signo++) {
160
    for (signo = 1; signo < NSIG; signo++) {
159
	if (sudo_sys_signame[signo] != NULL) {
161
	const char *cp = sigabbrev_np(signo);
162
	if (cp != NULL) {
160
	    /* On macOS sys_signame[] may contain lower-case names. */
163
	    /* On macOS sys_signame[] may contain lower-case names. */
161
	    if (strcasecmp(signame, sudo_sys_signame[signo]) == 0) {
164
	    if (strcasecmp(signame, cp) == 0) {
162
		*result = signo;
165
		*result = signo;
163
		return 0;
166
		return 0;
164
	    }
167
	    }

Return to bug 739016