diff --git a/common/gettime.c b/common/gettime.c index 903c4b360..103cc070f 100644 --- a/common/gettime.c +++ b/common/gettime.c @@ -33,12 +33,5 @@ int gettime(struct timeval *tv) { - int rval; -#if defined(HAVE_GETTIMEOFDAY) && (defined(HAVE_ST_MTIM) || defined(HAVE_ST_MTIMESPEC)) - rval = gettimeofday(tv, NULL); -#else - rval = (int)time(&tv->tv_sec); - tv->tv_usec = 0; -#endif - return (rval); + return gettimeofday(tv, NULL); } diff --git a/compat/snprintf.c b/compat/snprintf.c index 40c8370fe..f5f5949d9 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -122,22 +122,6 @@ static int xxxprintf(char **, size_t, int, const char *, va_list); #define BUF 68 -#ifndef HAVE_MEMCHR -void * -memchr(const void *s, unsigned char c, size_t n) -{ - if (n != 0) { - const unsigned char *p = s; - - do { - if (*p++ == c) - return ((void *)(p - 1)); - } while (--n != 0); - } - return (NULL); -} -#endif /* !HAVE_MEMCHR */ - /* * Convert an unsigned long to ASCII for printf purposes, returning * a pointer to the first character of the string representation. diff --git a/compat/strcasecmp.c b/compat/strcasecmp.c deleted file mode 100644 index 6e17a3c23..000000000 --- a/compat/strcasecmp.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2004-2005, 2010 - * Todd C. Miller - * - * 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 -#include -#include - -/* - * Case insensitive string compare routines, same semantics as str[n]cmp() - * (assumes ASCII..). - * Derived from a public domain implementation included with the pdksh shell. - */ -static const char ichars[256] = { - 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -int -strcasecmp(const char *s1, const char *s2) -{ - const unsigned char *us1 = (const unsigned char *) s1; - const unsigned char *us2 = (const unsigned char *) s2; - - while (ichars[*us1] == ichars[*us2++]) { - if (*us1++ == '\0') - return 0; - } - return ichars[*us1] - ichars[*--us2]; -} - -int -strncasecmp(const char *s1, const char *s2, size_t n) -{ - const unsigned char *us1 = (const unsigned char *) s1; - const unsigned char *us2 = (const unsigned char *) s2; - - while (n != 0 && ichars[*us1] == ichars[*us2++]) { - if (*us1++ == '\0') - return 0; - n--; - } - return n ? ichars[*us1] - ichars[*--us2] : 0; -} diff --git a/compat/strerror.c b/compat/strerror.c deleted file mode 100644 index 5b444e47f..000000000 --- a/compat/strerror.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1999-2005, 2010 - * Todd C. Miller - * - * 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. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ - -#include -#include - -#include -#include - -/* - * Map errno -> error string. - */ -char * -strerror(int n) -{ - extern int sys_nerr; - extern char *sys_errlist[]; - - if (n > 0 && n < sys_nerr) - return(sys_errlist[n]); - errno = EINVAL; - return("Unknown error"); -} diff --git a/config.h.in b/config.h.in index a3cc7f6c0..6b7e3f46b 100644 --- a/config.h.in +++ b/config.h.in @@ -150,7 +150,7 @@ /* Define to 1 if you have the `getdomainname' function. */ #undef HAVE_GETDOMAINNAME -/* Define to 1 if your system has a working `getgroups' function. */ +/* Define to 1 if you have the `getgroups' function. */ #undef HAVE_GETGROUPS /* Define to 1 if you have the `getifaddrs' function. */ @@ -181,9 +181,6 @@ passwords) */ #undef HAVE_GETSPWUID -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - /* Define to 1 if you have the `getuserattr' function. */ #undef HAVE_GETUSERATTR @@ -325,21 +322,12 @@ /* Define to 1 if you have the `mbr_check_membership' function. */ #undef HAVE_MBR_CHECK_MEMBERSHIP -/* Define to 1 if you have the `memchr' function. */ -#undef HAVE_MEMCHR - -/* Define to 1 if you have the `memcpy' function. */ -#undef HAVE_MEMCPY - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memrchr' function. */ #undef HAVE_MEMRCHR -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - /* Define to 1 if you have the `mkstemps' function. */ #undef HAVE_MKSTEMPS @@ -430,9 +418,6 @@ /* Define to 1 if you have the `setreuid' function. */ #undef HAVE_SETREUID -/* Define to 1 if you have the `setrlimit' function. */ -#undef HAVE_SETRLIMIT - /* Define to 1 if you have the `setrlimit64' function. */ #undef HAVE_SETRLIMIT64 @@ -460,15 +445,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - -/* Define to 1 if you have the `strchr' function. */ -#undef HAVE_STRCHR - -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - /* Define to 1 if you have the `strftime' function. */ #undef HAVE_STRFTIME @@ -558,18 +534,9 @@ /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF -/* Define to 1 if you have the `vhangup' function. */ -#undef HAVE_VHANGUP - /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* Define to 1 if you have the `wait3' function. */ -#undef HAVE_WAIT3 - -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - /* Define to 1 if you have the header file. */ #undef HAVE_ZLIB_H @@ -794,17 +761,6 @@ # endif /* HAVE_ST_MTIMESPEC */ #endif /* HAVE_ST_MTIM */ -/* - * Emulate a subset of waitpid() if we don't have it. - */ -#ifdef HAVE_WAITPID -# define sudo_waitpid(p, s, o) waitpid(p, s, o) -#else -# ifdef HAVE_WAIT3 -# define sudo_waitpid(p, s, o) wait3(s, o, NULL) -# endif -#endif - /* GNU stow needs /etc/sudoers to be a symlink. */ #ifdef USE_STOW # define stat_sudoers stat diff --git a/configure b/configure index c7f8f559f..a3d31d75c 100755 --- a/configure +++ b/configure @@ -13176,8 +13176,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c89_strcasecmp" >&5 $as_echo "$ac_cv_lib_c89_strcasecmp" >&6; } if test "x$ac_cv_lib_c89_strcasecmp" = x""yes; then : - $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h - LIBS="${LIBS} -lc89"; ac_cv_func_strcasecmp=yes + LIBS="${LIBS} -lc89" fi : ${mansectsu='1m'} @@ -14746,10 +14745,8 @@ $as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h fi LIBS=$ac_save_LIBS -for ac_func in strchr strrchr memchr memcpy memset sysconf tzset \ - strftime setrlimit initgroups getgroups fstat gettimeofday \ - regcomp setlocale getaddrinfo vhangup \ - mbr_check_membership setrlimit64 +for ac_func in strrchr sysconf tzset strftime initgroups getgroups fstat \ + regcomp setlocale getaddrinfo mbr_check_membership setrlimit64 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -15160,19 +15157,6 @@ _ACEOF fi done -for ac_func in waitpid wait3 -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - break -fi -done - for ac_func in innetgr _innetgr do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -15333,7 +15317,7 @@ esac fi -for ac_func in memrchr strerror strcasecmp strlcpy strlcat setenv +for ac_func in memrchr strlcpy strlcat setenv do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 07981a050..29b1e2f71 100644 --- a/configure.in +++ b/configure.in @@ -1677,7 +1677,7 @@ case "$host" in : ${with_rpath='yes'} ;; *-ncr-sysv4*|*-ncr-sysvr4*) - AC_CHECK_LIB(c89, strcasecmp, AC_DEFINE(HAVE_STRCASECMP) [LIBS="${LIBS} -lc89"; ac_cv_func_strcasecmp=yes]) + AC_CHECK_LIB(c89, strcasecmp, [LIBS="${LIBS} -lc89"]) : ${mansectsu='1m'} : ${mansectform='4'} : ${with_rpath='yes'} @@ -1915,10 +1915,8 @@ dnl dnl Function checks dnl AC_FUNC_GETGROUPS -AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \ - strftime setrlimit initgroups getgroups fstat gettimeofday \ - regcomp setlocale getaddrinfo vhangup \ - mbr_check_membership setrlimit64) +AC_CHECK_FUNCS(strrchr sysconf tzset strftime initgroups getgroups fstat \ + regcomp setlocale getaddrinfo mbr_check_membership setrlimit64) AC_CHECK_FUNCS(getline, [], [ AC_LIBOBJ(getline) AC_CHECK_FUNCS(fgetln) @@ -1964,13 +1962,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int i = GLOB_BRACE | AC_MSG_RESULT(yes)], [AC_LIBOBJ(glob) AC_MSG_RESULT(no)])], [AC_LIBOBJ(glob)]) AC_CHECK_FUNCS(lockf flock, [break]) -AC_CHECK_FUNCS(waitpid wait3, [break]) AC_CHECK_FUNCS(innetgr _innetgr, [AC_CHECK_FUNCS(getdomainname) [break]]) AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_FUNCS(futime) AC_LIBOBJ(utimes)]) AC_CHECK_FUNCS(killpg, [], [AC_LIBOBJ(killpg)]) SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)]) SUDO_FUNC_ISBLANK -AC_REPLACE_FUNCS(memrchr strerror strcasecmp strlcpy strlcat setenv) +AC_REPLACE_FUNCS(memrchr strlcpy strlcat setenv) AC_CHECK_FUNCS(nanosleep, [], [ # On Solaris, nanosleep is in librt AC_CHECK_LIB(rt, nanosleep, [REPLAY_LIBS="${REPLAY_LIBS} -lrt"], [AC_LIBOBJ(nanosleep)]) @@ -2910,17 +2907,6 @@ AH_BOTTOM([/* # endif /* HAVE_ST_MTIMESPEC */ #endif /* HAVE_ST_MTIM */ -/* - * Emulate a subset of waitpid() if we don't have it. - */ -#ifdef HAVE_WAITPID -# define sudo_waitpid(p, s, o) waitpid(p, s, o) -#else -# ifdef HAVE_WAIT3 -# define sudo_waitpid(p, s, o) wait3(s, o, NULL) -# endif -#endif - /* GNU stow needs /etc/sudoers to be a symlink. */ #ifdef USE_STOW # define stat_sudoers stat diff --git a/include/compat.h b/include/compat.h index 2ce7c3f7a..333a88069 100644 --- a/include/compat.h +++ b/include/compat.h @@ -118,19 +118,6 @@ # define STDERR_FILENO 2 #endif -/* - * These should be defined in but not everyone has them. - */ -#ifndef SEEK_SET -# define SEEK_SET 0 -#endif -#ifndef SEEK_CUR -# define SEEK_CUR 1 -#endif -#ifndef SEEK_END -# define SEEK_END 2 -#endif - /* * BSD defines these in but others may not. */ @@ -149,22 +136,6 @@ int isblank(int); # define isblank(_x) ((_x) == ' ' || (_x) == '\t') #endif -/* - * Old BSD systems lack strchr(), strrchr(), memset() and memcpy() - */ -#if !defined(HAVE_STRCHR) && !defined(strchr) -# define strchr(_s, _c) index(_s, _c) -#endif -#if !defined(HAVE_STRRCHR) && !defined(strrchr) -# define strrchr(_s, _c) rindex(_s, _c) -#endif -#if !defined(HAVE_MEMCPY) && !defined(memcpy) -# define memcpy(_d, _s, _n) (bcopy(_s, _d, _n)) -#endif -#if !defined(HAVE_MEMSET) && !defined(memset) -# define memset(_s, _x, _n) (bzero(_s, _n)) -#endif - /* * NCR's SVr4 has _innetgr(3) instead of innetgr(3) for some reason. */ diff --git a/include/missing.h b/include/missing.h index a0460fc13..844023b4a 100644 --- a/include/missing.h +++ b/include/missing.h @@ -51,9 +51,6 @@ int asprintf(char **, const char *, ...) __printflike(2, 3); #ifndef HAVE_VASPRINTF int vasprintf(char **, const char *, va_list) __printflike(2, 0); #endif -#ifndef HAVE_STRCASECMP -int strcasecmp(const char *, const char *); -#endif #ifndef HAVE_STRLCAT size_t strlcat(char *, const char *, size_t); #endif diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index 8e2ea1004..4990a4be8 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -440,11 +440,7 @@ send_mail(const char *fmt, ...) default: /* Parent. */ do { -#ifdef HAVE_WAITPID rv = waitpid(pid, &status, 0); -#else - rv = wait(&status); -#endif } while (rv == -1 && errno == EINTR); return; } @@ -565,11 +561,7 @@ send_mail(const char *fmt, ...) fclose(mail); do { -#ifdef HAVE_WAITPID rv = waitpid(pid, &status, 0); -#else - rv = wait(&status); -#endif } while (rv == -1 && errno == EINTR); _exit(0); } diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 41b6eb184..eed912596 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -33,10 +33,6 @@ #include #include #include -#ifdef HAVE_SETRLIMIT -# include -# include -#endif #include #ifdef STDC_HEADERS # include @@ -63,9 +59,7 @@ #include #include #include -#if TIME_WITH_SYS_TIME -# include -#endif +#include #ifdef HAVE_SETLOCALE # include #endif diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 03ba088c5..f89e3cf93 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -670,11 +670,7 @@ run_command(char *path, char **argv) } do { -#ifdef sudo_waitpid - rv = sudo_waitpid(pid, &status, 0); -#else - rv = wait(&status); -#endif + rv = waitpid(pid, &status, 0); } while (rv == -1 && errno == EINTR); if (rv == -1 || !WIFEXITED(status)) diff --git a/src/sudo.c b/src/sudo.c index b5de995c0..140d4948b 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -28,10 +28,8 @@ #ifdef HAVE_SYS_SELECT_H # include #endif /* HAVE_SYS_SELECT_H */ -#ifdef HAVE_SETRLIMIT -# include -# include -#endif +#include +#include #include #ifdef STDC_HEADERS # include