]> granicus.if.org Git - sudo/commitdiff
Add check for strsignal() and a simple implementation if it is not there but sys_sigl...
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 14 Oct 2009 20:04:04 +0000 (20:04 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 14 Oct 2009 20:04:04 +0000 (20:04 +0000)
Makefile.in
config.h.in
configure
configure.in
strsignal.c [new file with mode: 0644]
sudo.h

index c995abaa5d90d2f3043c8d049755f394b73ccc3c..da0b974c4d279894bc6b777faa11cf388b0a892e 100644 (file)
@@ -110,10 +110,10 @@ SRCS = aix.c alias.c alloc.c audit.c bsm_audit.c check.c closefrom.c \
        gram.y interfaces.c isblank.c lbuf.c ldap.c list.c logging.c match.c \
        mkstemp.c memrchr.c nanosleep.c parse.c pwutil.c script.c  set_perms.c \
        sigaction.c snprintf.c strcasecmp.c strerror.c strlcat.c strlcpy.c \
-       sudo.c sudo_noexec.c sudo_edit.c sudo_nss.c term.c testsudoers.c \
-       tgetpass.c toke.c toke.l tsgetgrpw.c utimes.c vasgroups.c visudo.c \
-       zero_bytes.c redblack.c selinux.c sesh.c sudoreplay.c getdate.c \
-       getdate.y getline.c timestr.c $(AUTH_SRCS)
+       strsignal.c sudo.c sudo_noexec.c sudo_edit.c sudo_nss.c term.c \
+       testsudoers.c tgetpass.c toke.c toke.l tsgetgrpw.c utimes.c \
+       vasgroups.c visudo.c zero_bytes.c redblack.c selinux.c sesh.c \
+       sudoreplay.c getdate.c getdate.y getline.c timestr.c $(AUTH_SRCS)
 
 AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \
            auth/kerb4.c auth/kerb5.c auth/pam.c auth/passwd.c auth/rfc1938.c \
@@ -327,6 +327,8 @@ strlcat.o: $(srcdir)/strlcat.c $(srcdir)/compat.h config.h
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strlcat.c
 strlcpy.o: $(srcdir)/strlcpy.c $(srcdir)/compat.h config.h
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strlcpy.c
+strsignal.o: $(srcdir)/strsignal.c $(srcdir)/compat.h config.h
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strsignal.c
 selinux.o: $(srcdir)/selinux.c $(SUDODEP)
        $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/selinux.c
 sudo.o: $(srcdir)/sudo.c $(SUDODEP) sudo_usage.h $(srcdir)/interfaces.h
index 6ea8c3867aaf63275e60fdc8eb65781db5b460ae..b40c24765fc8d5a7dc6ee8f3489e90362cfe4ded 100644 (file)
 /* Define to 1 if you have the `strrchr' function. */
 #undef HAVE_STRRCHR
 
+/* Define to 1 if you have the `strsignal' function. */
+#undef HAVE_STRSIGNAL
+
 /* Define to 1 if your struct stat has an st_mtim member */
 #undef HAVE_ST_MTIM
 
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
+/* Define to 1 if you have the 'sys_siglist' symbol in libc. */
+#undef HAVE_SYS_SIGLIST
+
 /* Define to 1 if you have the <sys/sockio.h> header file. */
 #undef HAVE_SYS_SOCKIO_H
 
index c13810ff61855024455da24eb61762efb30b58b4..1afae21e4bdd698adcb8dab33a7f0e4247b56bcf 100755 (executable)
--- a/configure
+++ b/configure
 done
 
 
+
+for ac_func in strsignal
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
+#endif
+
+int
+main ()
+{
+return $ac_func ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       eval "$as_ac_var=no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+ac_res=`eval echo '${'$as_ac_var'}'`
+              { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+
+    { echo "$as_me:$LINENO: checking for sys_siglist" >&5
+echo $ECHO_N "checking for sys_siglist... $ECHO_C" >&6; }
+    if test "${sudo_cv_sys_siglist+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+extern char *sys_siglist; char *hup = sys_siglist[1];
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  sudo_cv_sys_siglist=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       sudo_cv_sys_siglist=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+
+    if test "$sudo_cv_sys_siglist" = "yes"; then
+       case " $LIBOBJS " in
+  *" strsignal.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS strsignal.$ac_objext"
+ ;;
+esac
+
+       cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYS_SIGLIST 1
+_ACEOF
+
+       cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRSIGNAL 1
+_ACEOF
+
+    fi
+    { echo "$as_me:$LINENO: result: $sudo_cv_sys_siglist" >&5
+echo "${ECHO_T}$sudo_cv_sys_siglist" >&6; }
+
+fi
+done
+
+
 netsvc_conf='/etc/netsvc.conf'
 nsswitch_conf='/etc/nsswitch.conf'
 if test ${with_netsvc-"no"} != "no"; then
index 8a393895616e510d5816d680a0ac681afddda173..ace66a2b43cc9750e816468ae71f49af450c5979 100644 (file)
@@ -1965,6 +1965,21 @@ AC_CHECK_FUNCS(getprogname, , [
     AC_MSG_RESULT($sudo_cv___progname)
 ])
 
+dnl
+dnl Check for strsignal() or sys_siglist
+dnl
+AC_CHECK_FUNCS(strsignal, [], [
+    AC_MSG_CHECKING([for sys_siglist])
+    AC_CACHE_VAL(sudo_cv_sys_siglist, [
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern char *sys_siglist; char *hup = sys_siglist[1];]])], [sudo_cv_sys_siglist=yes], [sudo_cv_sys_siglist=no])])
+    if test "$sudo_cv_sys_siglist" = "yes"; then
+       AC_LIBOBJ(strsignal)
+       AC_DEFINE(HAVE_SYS_SIGLIST)
+       AC_DEFINE(HAVE_STRSIGNAL)
+    fi
+    AC_MSG_RESULT($sudo_cv_sys_siglist)
+])
+
 dnl
 dnl nsswitch.conf and its equivalents
 dnl
diff --git a/strsignal.c b/strsignal.c
new file mode 100644 (file)
index 0000000..e83b4f0
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2009 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 <stdio.h>
+#include <signal.h>
+
+#include <config.h>
+#include <compat.h>
+
+#ifndef lint
+__unused static const char rcsid[] = "$Sudo$";
+#endif /* lint */
+
+/*
+ * Get signal description string
+ */
+char *
+strsignal(signo)
+    int signo;
+{
+    extern const char *const sys_siglist[];
+
+    if (signo > 0 && signo < NSIG)
+       return((char *)sys_siglist[signo]);
+    return("Unknown signal");
+}
diff --git a/sudo.h b/sudo.h
index 0db98fa47a470af2d6ec9be225160e7c3a6a841f..38f1a9610e46ff1fdf7947bdd16795af377204c9 100644 (file)
--- a/sudo.h
+++ b/sudo.h
@@ -246,6 +246,9 @@ int setenv          __P((const char *, const char *, int));
 #ifndef HAVE_UNSETENV
 int unsetenv           __P((const char *));
 #endif
+#ifdef HAVE_SYS_SIGLIST
+char *strsignal                __P((int));
+#endif
 char *sudo_goodpath    __P((const char *, struct stat *));
 char *tgetpass         __P((const char *, int, int));
 int find_path          __P((char *, char **, struct stat *, char *));