]> granicus.if.org Git - sudo/commitdiff
Almost no systems actually define OPEN_MAX since it is dynamic on
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 19 Feb 2015 16:59:25 +0000 (09:59 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 19 Feb 2015 16:59:25 +0000 (09:59 -0700)
modern OSes.  If sysconf(_SC_OPEN_MAX) ever fails, fall back on
_POSIX_OPEN_MAX instead.  We can assume modern systems have sysconf().
Also remove checks for strrchr() and strtoll() for which the HAVE_*
defines are no longer used.

config.h.in
configure
configure.ac
include/sudo_compat.h
lib/util/closefrom.c
lib/util/setgroups.c
plugins/sudoers/pwutil_impl.c
src/sudo.c

index 83534da00508b04abc3ebe8d09965949f0da2033..5d36f60d6f86da1c158678b8718f1c61ae90edae 100644 (file)
    don't. */
 #undef HAVE_DECL_LLONG_MIN
 
-/* Define to 1 if you have the declaration of `OPEN_MAX', and to 0 if you
-   don't. */
-#undef HAVE_DECL_OPEN_MAX
-
 /* Define to 1 if you have the declaration of `PATH_MAX', and to 0 if you
    don't. */
 #undef HAVE_DECL_PATH_MAX
 /* Define to 1 if your struct stat uses an st__tim union. */
 #undef HAVE_ST__TIM
 
-/* Define to 1 if you have the `sysconf' function. */
-#undef HAVE_SYSCONF
-
 /* Define to 1 if you have the `sysctl' function. */
 #undef HAVE_SYSCTL
 
index 85108fbf8895d82a61676f59499dbf1d6c3ada60..b12ca34bf9db94cb1ca1411e766bc8b5303f5403 100755 (executable)
--- a/configure
+++ b/configure
@@ -2833,7 +2833,6 @@ as_fn_append ac_header_list " sys/sysmacros.h"
 as_fn_append ac_func_list " killpg"
 as_fn_append ac_func_list " nl_langinfo"
 as_fn_append ac_func_list " strftime"
-as_fn_append ac_func_list " sysconf"
 as_fn_append ac_func_list " tzset"
 as_fn_append ac_func_list " seteuid"
 # Check that the precious variables saved in the cache have kept the same
@@ -18381,8 +18380,6 @@ done
 
 
 
-
-
 for ac_func in getgrouplist
 do :
   ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
@@ -21284,20 +21281,6 @@ _ACEOF
 
 _CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $OSDEFS"
-ac_fn_c_check_decl "$LINENO" "OPEN_MAX" "ac_cv_have_decl_OPEN_MAX" "
-#include <sys/types.h>
-#include <limits.h>
-
-"
-if test "x$ac_cv_have_decl_OPEN_MAX" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_OPEN_MAX $ac_have_decl
-_ACEOF
 ac_fn_c_check_decl "$LINENO" "LLONG_MAX" "ac_cv_have_decl_LLONG_MAX" "
 #include <sys/types.h>
 #include <limits.h>
index 416e2b2ff0c561ba67180f4250d92dc7167b34df..e0a4063cd26a26b3d32daf0eebc9898bbd245827 100644 (file)
@@ -2349,7 +2349,7 @@ dnl
 dnl Function checks
 dnl
 AC_FUNC_GETGROUPS
-AC_CHECK_FUNCS_ONCE([killpg nl_langinfo strftime sysconf tzset])
+AC_CHECK_FUNCS_ONCE([killpg nl_langinfo strftime tzset])
 AC_CHECK_FUNCS([getgrouplist], [], [
     case "$host_os" in
     aix*)
@@ -3010,7 +3010,7 @@ dnl We need to add OSDEFS to CFLAGS to expose LLONG_MAX et al on glibc.
 dnl
 _CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $OSDEFS"
-AC_CHECK_DECLS([OPEN_MAX, LLONG_MAX, LLONG_MIN, ULLONG_MAX, PATH_MAX, HOST_NAME_MAX], [], [], [
+AC_CHECK_DECLS([LLONG_MAX, LLONG_MIN, ULLONG_MAX, PATH_MAX, HOST_NAME_MAX], [], [], [
 #include <sys/types.h>
 #include <limits.h>
 ])
index f20513dcc14868ef151db572e4520c79f98b0f02..0f649e9c58d5d6c46b148afe33d2408185861a90 100644 (file)
 /*
  * Some systems lack full limit definitions.
  */
-#if defined(HAVE_DECL_OPEN_MAX) && !HAVE_DECL_OPEN_MAX
-# define OPEN_MAX      256
-#endif
-
 #if defined(HAVE_DECL_LLONG_MAX) && !HAVE_DECL_LLONG_MAX
 # if defined(HAVE_DECL_QUAD_MAX) && HAVE_DECL_QUAD_MAX
 #  define LLONG_MAX    QUAD_MAX
index 625c48eb337667004794c02f33e791506c6d5079..27c01d22b9d4b9f3d8c57a05926d3928248b24bd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004-2005, 2007, 2010, 2012-2014
+ * Copyright (c) 2004-2005, 2007, 2010, 2012-2015
  *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
 
 #include "sudo_compat.h"
 
+#ifndef _POSIX_OPEN_MAX
+# define _POSIX_OPEN_MAX       20
+#endif
+
 #if defined(HAVE_FCNTL_CLOSEM) && !defined(HAVE_DIRFD)
 # define sudo_closefrom        closefrom_fallback
 #endif
@@ -69,17 +73,13 @@ closefrom_fallback(int lowfd)
     long fd, maxfd;
 
     /*
-     * Fall back on sysconf() or getdtablesize().  We avoid checking
+     * Fall back on sysconf(_SC_OPEN_MAX).  We avoid checking
      * resource limits since it is possible to open a file descriptor
      * and then drop the rlimit such that it is below the open fd.
      */
-#ifdef HAVE_SYSCONF
     maxfd = sysconf(_SC_OPEN_MAX);
-#else
-    maxfd = getdtablesize();
-#endif /* HAVE_SYSCONF */
     if (maxfd < 0)
-       maxfd = OPEN_MAX;
+       maxfd = _POSIX_OPEN_MAX;
 
     for (fd = lowfd; fd < maxfd; fd++) {
 #ifdef __APPLE__
index 82dc77d4776d78f67068a4e21455067230976536..18843b39c81ea56bd3ca54bf452412194afcfd7e 100644 (file)
@@ -48,10 +48,8 @@ sudo_setgroups_v1(int ngids, const GETGROUPS_T *gids)
     rval = setgroups(ngids, (GETGROUPS_T *)gids);
     if (rval == -1 && errno == EINVAL) {
        /* Too many groups, try again with fewer. */
-#if defined(HAVE_SYSCONF) && defined(_SC_NGROUPS_MAX)
        maxgids = (int)sysconf(_SC_NGROUPS_MAX);
        if (maxgids == -1)
-#endif
            maxgids = NGROUPS_MAX;
        if (ngids > maxgids)
            rval = setgroups(maxgids, (GETGROUPS_T *)gids);
index ab37313061b07cb3c7590b18f80b08b2fe338201..4e50d03421ea1ba4f774609492f1d244b4e085f0 100644 (file)
@@ -248,10 +248,8 @@ sudo_make_grlist_item(const struct passwd *pw, char * const *unused1,
            gids = sudo_emallocarray(ngids, sizeof(GETGROUPS_T));
            (void)getgrouplist(pw->pw_name, pw->pw_gid, gids, &ngids);
        } else {
-#if defined(HAVE_SYSCONF) && defined(_SC_NGROUPS_MAX)
            ngids = (int)sysconf(_SC_NGROUPS_MAX) * 2;
            if (ngids < 0)
-#endif
                ngids = NGROUPS_MAX * 2;
            gids = sudo_emallocarray(ngids, sizeof(GETGROUPS_T));
            if (getgrouplist(pw->pw_name, pw->pw_gid, gids, &ngids) == -1) {
@@ -271,7 +269,7 @@ sudo_make_grlist_item(const struct passwd *pw, char * const *unused1,
     aix_setauthdb((char *) pw->pw_name);
 #endif
 
-#if defined(HAVE_SYSCONF) && defined(_SC_LOGIN_NAME_MAX)
+#ifdef _SC_LOGIN_NAME_MAX
     groupname_len = MAX((int)sysconf(_SC_LOGIN_NAME_MAX), 32);
 #else
     groupname_len = MAX(LOGIN_NAME_MAX, 32);
index 438a10ab0218cc6cfcd9c03a769571a481d35859..fdcb941f270364649b23d4eb8e9e3bebbc2f93fc 100644 (file)
@@ -397,10 +397,8 @@ get_user_groups(struct user_details *ud)
     int i, len, maxgroups, group_source;
     debug_decl(get_user_groups, SUDO_DEBUG_UTIL)
 
-#if defined(HAVE_SYSCONF) && defined(_SC_NGROUPS_MAX)
     maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
     if (maxgroups < 0)
-#endif
        maxgroups = NGROUPS_MAX;
 
     ud->groups = NULL;