Use strsigname() to print signal names in the debug output.
If the system has no strsigname(), use our own.
This commit is contained in:
3
MANIFEST
3
MANIFEST
@@ -41,6 +41,8 @@ compat/isblank.c
|
|||||||
compat/memrchr.c
|
compat/memrchr.c
|
||||||
compat/mksiglist.c
|
compat/mksiglist.c
|
||||||
compat/mksiglist.h
|
compat/mksiglist.h
|
||||||
|
compat/mksigname.c
|
||||||
|
compat/mksigname.h
|
||||||
compat/mktemp.c
|
compat/mktemp.c
|
||||||
compat/nanosleep.c
|
compat/nanosleep.c
|
||||||
compat/pw_dup.c
|
compat/pw_dup.c
|
||||||
@@ -55,6 +57,7 @@ compat/stdbool.h
|
|||||||
compat/strlcat.c
|
compat/strlcat.c
|
||||||
compat/strlcpy.c
|
compat/strlcpy.c
|
||||||
compat/strsignal.c
|
compat/strsignal.c
|
||||||
|
compat/strsigname.c
|
||||||
compat/timespec.h
|
compat/timespec.h
|
||||||
compat/utime.h
|
compat/utime.h
|
||||||
compat/utimes.c
|
compat/utimes.c
|
||||||
|
@@ -85,9 +85,15 @@ libreplace.la: $(LTLIBOBJS)
|
|||||||
siglist.c: mksiglist
|
siglist.c: mksiglist
|
||||||
./mksiglist > $@
|
./mksiglist > $@
|
||||||
|
|
||||||
|
signame.c: mksigname
|
||||||
|
./mksigname > $@
|
||||||
|
|
||||||
mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(incdir)/missing.h $(top_builddir)/config.h
|
mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(incdir)/missing.h $(top_builddir)/config.h
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@
|
||||||
|
|
||||||
|
mksigname: $(srcdir)/mksigname.c $(srcdir)/mksigname.h $(incdir)/missing.h $(top_builddir)/config.h
|
||||||
|
$(CC) $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksigname.c -o $@
|
||||||
|
|
||||||
fnm_test: fnm_test.o libreplace.la
|
fnm_test: fnm_test.o libreplace.la
|
||||||
$(LIBTOOL) --mode=link $(CC) -o $@ fnm_test.o libreplace.la
|
$(LIBTOOL) --mode=link $(CC) -o $@ fnm_test.o libreplace.la
|
||||||
|
|
||||||
@@ -96,7 +102,12 @@ globtest: globtest.o libreplace.la
|
|||||||
|
|
||||||
$(srcdir)/mksiglist.h: $(srcdir)/siglist.in
|
$(srcdir)/mksiglist.h: $(srcdir)/siglist.in
|
||||||
@if [ -n "$(DEVEL)" ]; then \
|
@if [ -n "$(DEVEL)" ]; then \
|
||||||
awk 'BEGIN {print "/* public domain */\n"} /^ [A-Z]/ {printf("#ifdef SIG%s\n if (my_sys_siglist[SIG%s] == NULL)\n\tmy_sys_siglist[SIG%s] = \"%s\";\n#endif\n", $$1, $$1, $$1, substr($$0, 13))}' < $(srcdir)/siglist.in > $@; \
|
awk 'BEGIN {print "/* public domain */\n"} /^ [A-Z]/ {printf("#ifdef SIG%s\n if (sudo_sys_siglist[SIG%s] == NULL)\n\tsudo_sys_siglist[SIG%s] = \"%s\";\n#endif\n", $$1, $$1, $$1, substr($$0, 13))}' < $(srcdir)/siglist.in > $@; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
$(srcdir)/mksigname.h: $(srcdir)/siglist.in
|
||||||
|
@if [ -n "$(DEVEL)" ]; then \
|
||||||
|
awk 'BEGIN {print "/* public domain */\n"} /^ [A-Z]/ {printf("#ifdef SIG%s\n if (sudo_sys_signame[SIG%s] == NULL)\n\tsudo_sys_signame[SIG%s] = \"%s\";\n#endif\n", $$1, $$1, $$1, $$1)}' < $(srcdir)/siglist.in > $@; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pre-install:
|
pre-install:
|
||||||
@@ -134,7 +145,7 @@ check: $(TEST_PROGS)
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-$(LIBTOOL) --mode=clean rm -f $(TEST_PROGS) mksiglist siglist.c *.lo *.o *.la *.a stamp-* core *.core core.*
|
-$(LIBTOOL) --mode=clean rm -f $(TEST_PROGS) mksiglist mksignal siglist.c signame.c *.lo *.o *.la *.a stamp-* core *.core core.*
|
||||||
|
|
||||||
mostlyclean: clean
|
mostlyclean: clean
|
||||||
|
|
||||||
@@ -183,6 +194,9 @@ memrchr.lo: $(srcdir)/memrchr.c $(top_builddir)/config.h $(incdir)/missing.h
|
|||||||
mksiglist.lo: $(srcdir)/mksiglist.c $(top_builddir)/config.h \
|
mksiglist.lo: $(srcdir)/mksiglist.c $(top_builddir)/config.h \
|
||||||
$(incdir)/missing.h $(top_srcdir)/compat/mksiglist.h
|
$(incdir)/missing.h $(top_srcdir)/compat/mksiglist.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksiglist.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksiglist.c
|
||||||
|
mksigname.lo: $(srcdir)/mksigname.c $(top_builddir)/config.h \
|
||||||
|
$(incdir)/missing.h $(top_srcdir)/compat/mksigname.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mksigname.c
|
||||||
mktemp.lo: $(srcdir)/mktemp.c $(top_builddir)/config.h $(incdir)/missing.h
|
mktemp.lo: $(srcdir)/mktemp.c $(top_builddir)/config.h $(incdir)/missing.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mktemp.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/mktemp.c
|
||||||
nanosleep.lo: $(srcdir)/nanosleep.c $(top_builddir)/config.h \
|
nanosleep.lo: $(srcdir)/nanosleep.c $(top_builddir)/config.h \
|
||||||
@@ -201,6 +215,9 @@ strlcpy.lo: $(srcdir)/strlcpy.c $(top_builddir)/config.h $(incdir)/missing.h
|
|||||||
strsignal.lo: $(srcdir)/strsignal.c $(top_builddir)/config.h \
|
strsignal.lo: $(srcdir)/strsignal.c $(top_builddir)/config.h \
|
||||||
$(incdir)/missing.h $(incdir)/gettext.h
|
$(incdir)/missing.h $(incdir)/gettext.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsignal.c
|
||||||
|
strsigname.lo: $(srcdir)/strsigname.c $(top_builddir)/config.h \
|
||||||
|
$(incdir)/missing.h $(incdir)/gettext.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/strsigname.c
|
||||||
utimes.lo: $(srcdir)/utimes.c $(top_builddir)/config.h \
|
utimes.lo: $(srcdir)/utimes.c $(top_builddir)/config.h \
|
||||||
$(top_srcdir)/compat/utime.h $(incdir)/missing.h
|
$(top_srcdir)/compat/utime.h $(incdir)/missing.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/utimes.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/utimes.c
|
||||||
|
57
compat/mksigname.c
Normal file
57
compat/mksigname.c
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2012 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stddef.h>
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
|
#endif /* STDC_HEADERS */
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "missing.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
static char *my_sys_signame[NSIG];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#include "compat/mksigname.h"
|
||||||
|
|
||||||
|
printf("#include <config.h>\n");
|
||||||
|
printf("#include <signal.h>\n");
|
||||||
|
printf("#include \"missing.h\"\n\n");
|
||||||
|
printf("const char *const my_sys_signame[NSIG] = {\n");
|
||||||
|
for (i = 0; i < NSIG; i++) {
|
||||||
|
if (my_sys_signame[i] != NULL) {
|
||||||
|
printf(" \"%s\",\n", my_sys_signame[i]);
|
||||||
|
} else {
|
||||||
|
printf(" \"Signal %d\",\n", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("};\n");
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
175
compat/mksigname.h
Normal file
175
compat/mksigname.h
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/* public domain */
|
||||||
|
|
||||||
|
my_sys_signame[0] = "Signal 0";
|
||||||
|
#ifdef SIGHUP
|
||||||
|
if (my_sys_signame[SIGHUP] == NULL)
|
||||||
|
my_sys_signame[SIGHUP] = "HUP";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGINT
|
||||||
|
if (my_sys_signame[SIGINT] == NULL)
|
||||||
|
my_sys_signame[SIGINT] = "INT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGQUIT
|
||||||
|
if (my_sys_signame[SIGQUIT] == NULL)
|
||||||
|
my_sys_signame[SIGQUIT] = "QUIT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGILL
|
||||||
|
if (my_sys_signame[SIGILL] == NULL)
|
||||||
|
my_sys_signame[SIGILL] = "ILL";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTRAP
|
||||||
|
if (my_sys_signame[SIGTRAP] == NULL)
|
||||||
|
my_sys_signame[SIGTRAP] = "TRAP";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGABRT
|
||||||
|
if (my_sys_signame[SIGABRT] == NULL)
|
||||||
|
my_sys_signame[SIGABRT] = "ABRT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGIOT
|
||||||
|
if (my_sys_signame[SIGIOT] == NULL)
|
||||||
|
my_sys_signame[SIGIOT] = "IOT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGEMT
|
||||||
|
if (my_sys_signame[SIGEMT] == NULL)
|
||||||
|
my_sys_signame[SIGEMT] = "EMT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGFPE
|
||||||
|
if (my_sys_signame[SIGFPE] == NULL)
|
||||||
|
my_sys_signame[SIGFPE] = "FPE";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGKILL
|
||||||
|
if (my_sys_signame[SIGKILL] == NULL)
|
||||||
|
my_sys_signame[SIGKILL] = "KILL";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGUNUSED
|
||||||
|
if (my_sys_signame[SIGUNUSED] == NULL)
|
||||||
|
my_sys_signame[SIGUNUSED] = "UNUSED";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGBUS
|
||||||
|
if (my_sys_signame[SIGBUS] == NULL)
|
||||||
|
my_sys_signame[SIGBUS] = "BUS";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGSEGV
|
||||||
|
if (my_sys_signame[SIGSEGV] == NULL)
|
||||||
|
my_sys_signame[SIGSEGV] = "SEGV";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGSYS
|
||||||
|
if (my_sys_signame[SIGSYS] == NULL)
|
||||||
|
my_sys_signame[SIGSYS] = "SYS";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPIPE
|
||||||
|
if (my_sys_signame[SIGPIPE] == NULL)
|
||||||
|
my_sys_signame[SIGPIPE] = "PIPE";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGALRM
|
||||||
|
if (my_sys_signame[SIGALRM] == NULL)
|
||||||
|
my_sys_signame[SIGALRM] = "ALRM";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTERM
|
||||||
|
if (my_sys_signame[SIGTERM] == NULL)
|
||||||
|
my_sys_signame[SIGTERM] = "TERM";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGSTKFLT
|
||||||
|
if (my_sys_signame[SIGSTKFLT] == NULL)
|
||||||
|
my_sys_signame[SIGSTKFLT] = "STKFLT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGIO
|
||||||
|
if (my_sys_signame[SIGIO] == NULL)
|
||||||
|
my_sys_signame[SIGIO] = "IO";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGXCPU
|
||||||
|
if (my_sys_signame[SIGXCPU] == NULL)
|
||||||
|
my_sys_signame[SIGXCPU] = "XCPU";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGXFSZ
|
||||||
|
if (my_sys_signame[SIGXFSZ] == NULL)
|
||||||
|
my_sys_signame[SIGXFSZ] = "XFSZ";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGVTALRM
|
||||||
|
if (my_sys_signame[SIGVTALRM] == NULL)
|
||||||
|
my_sys_signame[SIGVTALRM] = "VTALRM";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPROF
|
||||||
|
if (my_sys_signame[SIGPROF] == NULL)
|
||||||
|
my_sys_signame[SIGPROF] = "PROF";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGWINCH
|
||||||
|
if (my_sys_signame[SIGWINCH] == NULL)
|
||||||
|
my_sys_signame[SIGWINCH] = "WINCH";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGLOST
|
||||||
|
if (my_sys_signame[SIGLOST] == NULL)
|
||||||
|
my_sys_signame[SIGLOST] = "LOST";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGUSR1
|
||||||
|
if (my_sys_signame[SIGUSR1] == NULL)
|
||||||
|
my_sys_signame[SIGUSR1] = "USR1";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGUSR2
|
||||||
|
if (my_sys_signame[SIGUSR2] == NULL)
|
||||||
|
my_sys_signame[SIGUSR2] = "USR2";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPWR
|
||||||
|
if (my_sys_signame[SIGPWR] == NULL)
|
||||||
|
my_sys_signame[SIGPWR] = "PWR";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPOLL
|
||||||
|
if (my_sys_signame[SIGPOLL] == NULL)
|
||||||
|
my_sys_signame[SIGPOLL] = "POLL";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGSTOP
|
||||||
|
if (my_sys_signame[SIGSTOP] == NULL)
|
||||||
|
my_sys_signame[SIGSTOP] = "STOP";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTSTP
|
||||||
|
if (my_sys_signame[SIGTSTP] == NULL)
|
||||||
|
my_sys_signame[SIGTSTP] = "TSTP";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGCONT
|
||||||
|
if (my_sys_signame[SIGCONT] == NULL)
|
||||||
|
my_sys_signame[SIGCONT] = "CONT";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGCHLD
|
||||||
|
if (my_sys_signame[SIGCHLD] == NULL)
|
||||||
|
my_sys_signame[SIGCHLD] = "CHLD";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGCLD
|
||||||
|
if (my_sys_signame[SIGCLD] == NULL)
|
||||||
|
my_sys_signame[SIGCLD] = "CLD";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTTIN
|
||||||
|
if (my_sys_signame[SIGTTIN] == NULL)
|
||||||
|
my_sys_signame[SIGTTIN] = "TTIN";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTTOU
|
||||||
|
if (my_sys_signame[SIGTTOU] == NULL)
|
||||||
|
my_sys_signame[SIGTTOU] = "TTOU";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGINFO
|
||||||
|
if (my_sys_signame[SIGINFO] == NULL)
|
||||||
|
my_sys_signame[SIGINFO] = "INFO";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGURG
|
||||||
|
if (my_sys_signame[SIGURG] == NULL)
|
||||||
|
my_sys_signame[SIGURG] = "URG";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGWAITING
|
||||||
|
if (my_sys_signame[SIGWAITING] == NULL)
|
||||||
|
my_sys_signame[SIGWAITING] = "WAITING";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGLWP
|
||||||
|
if (my_sys_signame[SIGLWP] == NULL)
|
||||||
|
my_sys_signame[SIGLWP] = "LWP";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGFREEZE
|
||||||
|
if (my_sys_signame[SIGFREEZE] == NULL)
|
||||||
|
my_sys_signame[SIGFREEZE] = "FREEZE";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTHAW
|
||||||
|
if (my_sys_signame[SIGTHAW] == NULL)
|
||||||
|
my_sys_signame[SIGTHAW] = "THAW";
|
||||||
|
#endif
|
||||||
|
#ifdef SIGCANCEL
|
||||||
|
if (my_sys_signame[SIGCANCEL] == NULL)
|
||||||
|
my_sys_signame[SIGCANCEL] = "CANCEL";
|
||||||
|
#endif
|
@@ -27,13 +27,13 @@
|
|||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
#if defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST == 1
|
#if defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST == 1
|
||||||
# define my_sys_siglist sys_siglist
|
# define sudo_sys_siglist sys_siglist
|
||||||
#elif defined(HAVE_DECL__SYS_SIGLIST) && HAVE_DECL__SYS_SIGLIST == 1
|
#elif defined(HAVE_DECL__SYS_SIGLIST) && HAVE_DECL__SYS_SIGLIST == 1
|
||||||
# define my_sys_siglist _sys_siglist
|
# define sudo_sys_siglist _sys_siglist
|
||||||
#elif defined(HAVE_DECL___SYS_SIGLIST) && HAVE_DECL___SYS_SIGLIST == 1
|
#elif defined(HAVE_DECL___SYS_SIGLIST) && HAVE_DECL___SYS_SIGLIST == 1
|
||||||
# define my_sys_siglist __sys_siglist
|
# define sudo_sys_siglist __sys_siglist
|
||||||
#else
|
#else
|
||||||
extern const char *const my_sys_siglist[NSIG];
|
extern const char *const sudo_sys_siglist[NSIG];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -43,6 +43,7 @@ char *
|
|||||||
strsignal(int signo)
|
strsignal(int signo)
|
||||||
{
|
{
|
||||||
if (signo > 0 && signo < NSIG)
|
if (signo > 0 && signo < NSIG)
|
||||||
return (char *)my_sys_siglist[signo];
|
return (char *)sudo_sys_siglist[signo];
|
||||||
|
/* XXX - should be "Unknown signal: %s" */
|
||||||
return _("Unknown signal");
|
return _("Unknown signal");
|
||||||
}
|
}
|
||||||
|
49
compat/strsigname.c
Normal file
49
compat/strsigname.c
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
#include "missing.h"
|
||||||
|
|
||||||
|
#define DEFAULT_TEXT_DOMAIN "sudo"
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_DECL_SYS_SIGNAME) && HAVE_DECL_SYS_SIGNAME == 1
|
||||||
|
# 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_SIGNAME) && HAVE_DECL___SYS_SIGNAME == 1
|
||||||
|
# define sudo_sys_signame __sys_signame
|
||||||
|
#else
|
||||||
|
extern const char *const sudo_sys_signame[NSIG];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return signal name
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
strsigname(int signo)
|
||||||
|
{
|
||||||
|
if (signo > 0 && signo < NSIG)
|
||||||
|
return (char *)sudo_sys_signame[signo];
|
||||||
|
/* XXX - should be "Unknown signal: %s" */
|
||||||
|
return _("Unknown signal");
|
||||||
|
}
|
18
config.h.in
18
config.h.in
@@ -91,14 +91,26 @@
|
|||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_SYS_SIGLIST
|
#undef HAVE_DECL_SYS_SIGLIST
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `sys_signame', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL_SYS_SIGNAME
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `_sys_siglist', and to 0 if you
|
/* Define to 1 if you have the declaration of `_sys_siglist', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL__SYS_SIGLIST
|
#undef HAVE_DECL__SYS_SIGLIST
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `_sys_signame', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL__SYS_SIGNAME
|
||||||
|
|
||||||
/* Define to 1 if you have the declaration of `__sys_siglist', and to 0 if you
|
/* Define to 1 if you have the declaration of `__sys_siglist', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL___SYS_SIGLIST
|
#undef HAVE_DECL___SYS_SIGLIST
|
||||||
|
|
||||||
|
/* Define to 1 if you have the declaration of `__sys_signame', and to 0 if you
|
||||||
|
don't. */
|
||||||
|
#undef HAVE_DECL___SYS_SIGNAME
|
||||||
|
|
||||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||||
*/
|
*/
|
||||||
#undef HAVE_DIRENT_H
|
#undef HAVE_DIRENT_H
|
||||||
@@ -487,6 +499,9 @@
|
|||||||
/* Define to 1 if you have the <spawn.h> header file. */
|
/* Define to 1 if you have the <spawn.h> header file. */
|
||||||
#undef HAVE_SPAWN_H
|
#undef HAVE_SPAWN_H
|
||||||
|
|
||||||
|
/* Define to 1 to enable SSSD support. */
|
||||||
|
#undef HAVE_SSSD
|
||||||
|
|
||||||
/* Define to 1 if stdbool.h conforms to C99. */
|
/* Define to 1 if stdbool.h conforms to C99. */
|
||||||
#undef HAVE_STDBOOL_H
|
#undef HAVE_STDBOOL_H
|
||||||
|
|
||||||
@@ -517,6 +532,9 @@
|
|||||||
/* Define to 1 if you have the `strsignal' function. */
|
/* Define to 1 if you have the `strsignal' function. */
|
||||||
#undef HAVE_STRSIGNAL
|
#undef HAVE_STRSIGNAL
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strsigname' function. */
|
||||||
|
#undef HAVE_STRSIGNAME
|
||||||
|
|
||||||
/* Define to 1 if `d_type' is a member of `struct dirent'. */
|
/* Define to 1 if `d_type' is a member of `struct dirent'. */
|
||||||
#undef HAVE_STRUCT_DIRENT_D_TYPE
|
#undef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
|
|
||||||
|
91
configure
vendored
91
configure
vendored
@@ -18309,6 +18309,97 @@ fi
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
for ac_func in strsigname
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "strsigname" "ac_cv_func_strsigname"
|
||||||
|
if test "x$ac_cv_func_strsigname" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_STRSIGNAME 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case " $LIBOBJS " in
|
||||||
|
*" strsigname.$ac_objext "* ) ;;
|
||||||
|
*) LIBOBJS="$LIBOBJS strsigname.$ac_objext"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
HAVE_SIGNAME="false"
|
||||||
|
ac_fn_c_check_decl "$LINENO" "sys_signame" "ac_cv_have_decl_sys_signame" "
|
||||||
|
$ac_includes_default
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
"
|
||||||
|
if test "x$ac_cv_have_decl_sys_signame" = xyes; then :
|
||||||
|
ac_have_decl=1
|
||||||
|
else
|
||||||
|
ac_have_decl=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_DECL_SYS_SIGNAME $ac_have_decl
|
||||||
|
_ACEOF
|
||||||
|
if test $ac_have_decl = 1; then :
|
||||||
|
|
||||||
|
HAVE_SIGNAME="true"
|
||||||
|
break
|
||||||
|
|
||||||
|
fi
|
||||||
|
ac_fn_c_check_decl "$LINENO" "_sys_signame" "ac_cv_have_decl__sys_signame" "
|
||||||
|
$ac_includes_default
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
"
|
||||||
|
if test "x$ac_cv_have_decl__sys_signame" = xyes; then :
|
||||||
|
ac_have_decl=1
|
||||||
|
else
|
||||||
|
ac_have_decl=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_DECL__SYS_SIGNAME $ac_have_decl
|
||||||
|
_ACEOF
|
||||||
|
if test $ac_have_decl = 1; then :
|
||||||
|
|
||||||
|
HAVE_SIGNAME="true"
|
||||||
|
break
|
||||||
|
|
||||||
|
fi
|
||||||
|
ac_fn_c_check_decl "$LINENO" "__sys_signame" "ac_cv_have_decl___sys_signame" "
|
||||||
|
$ac_includes_default
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
|
"
|
||||||
|
if test "x$ac_cv_have_decl___sys_signame" = xyes; then :
|
||||||
|
ac_have_decl=1
|
||||||
|
else
|
||||||
|
ac_have_decl=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_DECL___SYS_SIGNAME $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
|
||||||
|
*" signame.$ac_objext "* ) ;;
|
||||||
|
*) LIBOBJS="$LIBOBJS signame.$ac_objext"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
if test ${with_netsvc-"no"} != "no"; then
|
if test ${with_netsvc-"no"} != "no"; then
|
||||||
cat >>confdefs.h <<EOF
|
cat >>confdefs.h <<EOF
|
||||||
#define _PATH_NETSVC_CONF "${with_netsvc-/etc/netsvc.conf}"
|
#define _PATH_NETSVC_CONF "${with_netsvc-/etc/netsvc.conf}"
|
||||||
|
18
configure.in
18
configure.in
@@ -2568,6 +2568,24 @@ AC_INCLUDES_DEFAULT
|
|||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl Check for strsigname() or sys_signame
|
||||||
|
dnl
|
||||||
|
AC_CHECK_FUNCS(strsigname, [], [
|
||||||
|
AC_LIBOBJ(strsigname)
|
||||||
|
HAVE_SIGNAME="false"
|
||||||
|
AC_CHECK_DECLS([sys_signame, _sys_signame, __sys_signame], [
|
||||||
|
HAVE_SIGNAME="true"
|
||||||
|
break
|
||||||
|
], [ ], [
|
||||||
|
AC_INCLUDES_DEFAULT
|
||||||
|
#include <signal.h>
|
||||||
|
])
|
||||||
|
if test "$HAVE_SIGNAME" != "true"; then
|
||||||
|
AC_LIBOBJ(signame)
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl nsswitch.conf and its equivalents
|
dnl nsswitch.conf and its equivalents
|
||||||
dnl
|
dnl
|
||||||
|
@@ -376,5 +376,8 @@ int unsetenv(const char *);
|
|||||||
#ifndef HAVE_STRSIGNAL
|
#ifndef HAVE_STRSIGNAL
|
||||||
char *strsignal(int);
|
char *strsignal(int);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAVE_STRSIGNAME
|
||||||
|
char *strsigname(int);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _SUDO_MISSING_H */
|
#endif /* _SUDO_MISSING_H */
|
||||||
|
2
mkdep.pl
2
mkdep.pl
@@ -55,7 +55,7 @@ sub mkdep {
|
|||||||
$makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo sssd.lo:;
|
$makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo sssd.lo:;
|
||||||
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
|
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
|
||||||
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
|
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
|
||||||
$makefile =~ s:\@LTLIBOBJS\@:closefrom.lo dlopen.lo fnmatch.lo getcwd.lo getgrouplist.lo getline.lo getprogname.lo glob.lo isblank.lo memrchr.lo mksiglist.lo mktemp.lo nanosleep.lo pw_dup.lo siglist.lo snprintf.lo strlcat.lo strlcpy.lo strsignal.lo utimes.lo globtest.o fnm_test.o:;
|
$makefile =~ s:\@LTLIBOBJS\@:closefrom.lo dlopen.lo fnmatch.lo getcwd.lo getgrouplist.lo getline.lo getprogname.lo glob.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo pw_dup.lo siglist.lo snprintf.lo strlcat.lo strlcpy.lo strsignal.lo strsigname.lo utimes.lo globtest.o fnm_test.o:;
|
||||||
|
|
||||||
# Parse OBJS lines
|
# Parse OBJS lines
|
||||||
my %objs;
|
my %objs;
|
||||||
|
14
src/exec.c
14
src/exec.c
@@ -511,7 +511,7 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
cstat->val = errno;
|
cstat->val = errno;
|
||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "received signal %d", signo);
|
sudo_debug_printf(SUDO_DEBUG_DIAG, "received SIG%s", strsigname(signo));
|
||||||
if (signo == SIGCHLD) {
|
if (signo == SIGCHLD) {
|
||||||
/*
|
/*
|
||||||
* If logging I/O, child is the intermediate process,
|
* If logging I/O, child is the intermediate process,
|
||||||
@@ -541,8 +541,8 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
saved_pgrp = tcgetpgrp(fd);
|
saved_pgrp = tcgetpgrp(fd);
|
||||||
if (kill(getpid(), WSTOPSIG(status)) != 0) {
|
if (kill(getpid(), WSTOPSIG(status)) != 0) {
|
||||||
warning("kill(%d, %d)", (int)getpid(),
|
warning("kill(%d, SIG%s)", (int)getpid(),
|
||||||
WSTOPSIG(status));
|
strsigname(WSTOPSIG(status)));
|
||||||
}
|
}
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
if (saved_pgrp != (pid_t)-1)
|
if (saved_pgrp != (pid_t)-1)
|
||||||
@@ -566,7 +566,7 @@ handle_signals(int sv[2], pid_t child, int log_io, struct command_status *cstat)
|
|||||||
if (signo == SIGALRM)
|
if (signo == SIGALRM)
|
||||||
terminate_command(child, false);
|
terminate_command(child, false);
|
||||||
else if (kill(child, signo) != 0)
|
else if (kill(child, signo) != 0)
|
||||||
warning("kill(%d, %d)", (int)child, signo);
|
warning("kill(%d, SIG%s)", (int)child, strsigname(signo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,7 +587,8 @@ forward_signals(int sock)
|
|||||||
while (!tq_empty(&sigfwd_list)) {
|
while (!tq_empty(&sigfwd_list)) {
|
||||||
sigfwd = tq_first(&sigfwd_list);
|
sigfwd = tq_first(&sigfwd_list);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"sending signal %d to child over backchannel", sigfwd->signo);
|
"sending SIG%s to child over backchannel",
|
||||||
|
strsigname(sigfwd->signo));
|
||||||
cstat.type = CMD_SIGNO;
|
cstat.type = CMD_SIGNO;
|
||||||
cstat.val = sigfwd->signo;
|
cstat.val = sigfwd->signo;
|
||||||
do {
|
do {
|
||||||
@@ -622,7 +623,8 @@ schedule_signal(int signo)
|
|||||||
struct sigforward *sigfwd;
|
struct sigforward *sigfwd;
|
||||||
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
|
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "forwarding signal %d to child", signo);
|
sudo_debug_printf(SUDO_DEBUG_DIAG, "forwarding SIG%s to child",
|
||||||
|
strsigname(signo));
|
||||||
|
|
||||||
sigfwd = ecalloc(1, sizeof(*sigfwd));
|
sigfwd = ecalloc(1, sizeof(*sigfwd));
|
||||||
sigfwd->prev = sigfwd;
|
sigfwd->prev = sigfwd;
|
||||||
|
@@ -378,9 +378,10 @@ suspend_parent(int signo)
|
|||||||
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
|
||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
sigaction(signo, &sa, &osa);
|
sigaction(signo, &sa, &osa);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent %d", signo);
|
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s",
|
||||||
|
strsigname(signo));
|
||||||
if (killpg(ppgrp, signo) != 0)
|
if (killpg(ppgrp, signo) != 0)
|
||||||
warning("killpg(%d, %d)", (int)ppgrp, signo);
|
warning("killpg(%d, SIG%s)", (int)ppgrp, strsigname(signo));
|
||||||
|
|
||||||
/* Check foreground/background status on resume. */
|
/* Check foreground/background status on resume. */
|
||||||
check_foreground();
|
check_foreground();
|
||||||
@@ -826,8 +827,8 @@ deliver_signal(pid_t pid, int signo, bool from_parent)
|
|||||||
debug_decl(deliver_signal, SUDO_DEBUG_EXEC);
|
debug_decl(deliver_signal, SUDO_DEBUG_EXEC);
|
||||||
|
|
||||||
/* Handle signal from parent. */
|
/* Handle signal from parent. */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "received signal %d%s", signo,
|
sudo_debug_printf(SUDO_DEBUG_INFO, "received SIG%s%s",
|
||||||
from_parent ? " from parent" : "");
|
strsigname(signo), from_parent ? " from parent" : "");
|
||||||
switch (signo) {
|
switch (signo) {
|
||||||
case SIGALRM:
|
case SIGALRM:
|
||||||
terminate_command(pid, true);
|
terminate_command(pid, true);
|
||||||
@@ -906,16 +907,16 @@ handle_sigchld(int backchannel, struct command_status *cstat)
|
|||||||
cstat->type = CMD_WSTATUS;
|
cstat->type = CMD_WSTATUS;
|
||||||
cstat->val = status;
|
cstat->val = status;
|
||||||
if (WIFSTOPPED(status)) {
|
if (WIFSTOPPED(status)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "command stopped, signal %d",
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
WSTOPSIG(status));
|
"command stopped, SIG%s", strsigname(WSTOPSIG(status)));
|
||||||
do {
|
do {
|
||||||
cmnd_pgrp = tcgetpgrp(io_fds[SFD_SLAVE]);
|
cmnd_pgrp = tcgetpgrp(io_fds[SFD_SLAVE]);
|
||||||
} while (cmnd_pgrp == -1 && errno == EINTR);
|
} while (cmnd_pgrp == -1 && errno == EINTR);
|
||||||
if (send_status(backchannel, cstat) == -1)
|
if (send_status(backchannel, cstat) == -1)
|
||||||
return alive; /* XXX */
|
return alive; /* XXX */
|
||||||
} else if (WIFSIGNALED(status)) {
|
} else if (WIFSIGNALED(status)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "command killed, signal %d",
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
WTERMSIG(status));
|
"command killed, SIG%s", strsigname(WTERMSIG(status)));
|
||||||
} else {
|
} else {
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "command exited: %d",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "command exited: %d",
|
||||||
WEXITSTATUS(status));
|
WEXITSTATUS(status));
|
||||||
|
Reference in New Issue
Block a user