SIGIOT and SIGABRT are aliases on BSD systems.
This commit is contained in:
@@ -56,14 +56,43 @@
|
|||||||
extern const char *const sudo_sys_signame[NSIG];
|
extern const char *const sudo_sys_signame[NSIG];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Many systems use aliases for source backward compatibility.
|
||||||
|
*/
|
||||||
|
static struct sigalias {
|
||||||
|
const char *name;
|
||||||
|
int number;
|
||||||
|
} sigaliases[] = {
|
||||||
|
#ifdef SIGABRT
|
||||||
|
{ "ABRT", SIGABRT },
|
||||||
|
#endif
|
||||||
|
#ifdef SIGCLD
|
||||||
|
{ "CLD", SIGCLD },
|
||||||
|
#endif
|
||||||
|
#ifdef SIGIO
|
||||||
|
{ "IO", SIGIO },
|
||||||
|
#endif
|
||||||
|
#ifdef SIGIOT
|
||||||
|
{ "IOT", SIGIOT },
|
||||||
|
#endif
|
||||||
|
#ifdef SIGLOST
|
||||||
|
{ "LOST", SIGLOST },
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPOLL
|
||||||
|
{ "POLL", SIGPOLL },
|
||||||
|
#endif
|
||||||
|
{ NULL, -1 }
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate signal name to number.
|
* Translate signal name to number.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sudo_str2sig(const char *signame, int *result)
|
sudo_str2sig(const char *signame, int *result)
|
||||||
{
|
{
|
||||||
int signo;
|
struct sigalias *alias;
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
|
int signo;
|
||||||
|
|
||||||
/* Could be a signal number encoded as a string. */
|
/* Could be a signal number encoded as a string. */
|
||||||
if (isdigit((unsigned char)signame[0])) {
|
if (isdigit((unsigned char)signame[0])) {
|
||||||
@@ -74,84 +103,55 @@ sudo_str2sig(const char *signame, int *result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special cases. */
|
/* Check real-time signals. */
|
||||||
switch (signame[0]) {
|
|
||||||
case 'C':
|
|
||||||
/* support both SIGCLD and SIGCHLD */
|
|
||||||
#ifdef SIGCLD
|
|
||||||
if (strcmp(signame, "CLD") == 0) {
|
|
||||||
*result = SIGCLD;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef SIGCHLD
|
|
||||||
if (strcmp(signame, "CHLD") == 0) {
|
|
||||||
*result = SIGCHLD;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
#ifdef SIGIO
|
|
||||||
case 'I':
|
|
||||||
/* support both SIGIO and SIGPOLL */
|
|
||||||
if (strcmp(signame, "IO") == 0) {
|
|
||||||
*result = SIGIO;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef SIGPOLL
|
|
||||||
case 'P':
|
|
||||||
/* support both SIGIO and SIGPOLL */
|
|
||||||
if (strcmp(signame, "POLL") == 0) {
|
|
||||||
*result = SIGPOLL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case 'R':
|
|
||||||
/* real-time signals */
|
|
||||||
#if defined(SIGRTMIN)
|
#if defined(SIGRTMIN)
|
||||||
if (strncmp(signame, "RTMIN", 5) == 0) {
|
if (strncmp(signame, "RTMIN", 5) == 0) {
|
||||||
if (signame[5] == '\0') {
|
if (signame[5] == '\0') {
|
||||||
*result = SIGRTMIN;
|
*result = SIGRTMIN;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (signame[5] == '+') {
|
if (signame[5] == '+') {
|
||||||
if (isdigit((unsigned char)signame[6])) {
|
if (isdigit((unsigned char)signame[6])) {
|
||||||
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
||||||
const int off = signame[6] - '0';
|
const int off = signame[6] - '0';
|
||||||
|
|
||||||
if (rtmax > 0 && off < rtmax / 2) {
|
if (rtmax > 0 && off < rtmax / 2) {
|
||||||
*result = SIGRTMIN + off;
|
*result = SIGRTMIN + off;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(SIGRTMAX)
|
#if defined(SIGRTMAX)
|
||||||
if (strncmp(signame, "RTMAX", 5) == 0) {
|
if (strncmp(signame, "RTMAX", 5) == 0) {
|
||||||
if (signame[5] == '\0') {
|
if (signame[5] == '\0') {
|
||||||
*result = SIGRTMAX;
|
*result = SIGRTMAX;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (signame[5] == '-') {
|
if (signame[5] == '-') {
|
||||||
if (isdigit((unsigned char)signame[6])) {
|
if (isdigit((unsigned char)signame[6])) {
|
||||||
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
const long rtmax = sysconf(_SC_RTSIG_MAX);
|
||||||
const int off = signame[6] - '0';
|
const int off = signame[6] - '0';
|
||||||
|
|
||||||
if (rtmax > 0 && off < rtmax / 2) {
|
if (rtmax > 0 && off < rtmax / 2) {
|
||||||
*result = SIGRTMAX - off;
|
*result = SIGRTMAX - off;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
|
||||||
|
/* Check aliases. */
|
||||||
|
for (alias = sigaliases; alias->name != NULL; alias++) {
|
||||||
|
if (strcmp(signame, alias->name) == 0) {
|
||||||
|
*result = alias->number;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check sys_signame[]. */
|
||||||
for (signo = 1; signo < NSIG; signo++) {
|
for (signo = 1; signo < NSIG; signo++) {
|
||||||
if (sudo_sys_signame[signo] != NULL) {
|
if (sudo_sys_signame[signo] != NULL) {
|
||||||
if (strcmp(signame, sudo_sys_signame[signo]) == 0) {
|
if (strcmp(signame, sudo_sys_signame[signo]) == 0) {
|
||||||
|
Reference in New Issue
Block a user