]> granicus.if.org Git - sudo/commitdiff
If struct dirent has d_type, use it to avoid an extra stat().
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 13 Apr 2012 12:36:58 +0000 (08:36 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 13 Apr 2012 12:36:58 +0000 (08:36 -0400)
config.h.in
configure
configure.in
plugins/sudoers/sudoreplay.c

index 0574a4df73a692362e113f0b9a9820ab543d3bf7..8df0ad37569701630e7b50d7a7ed5f0e7adc7687 100644 (file)
 /* Define to 1 if you have the `strsignal' function. */
 #undef HAVE_STRSIGNAL
 
+/* Define to 1 if `d_type' is a member of `struct dirent'. */
+#undef HAVE_STRUCT_DIRENT_D_TYPE
+
 /* Define to 1 if the system has the type `struct in6_addr'. */
 #undef HAVE_STRUCT_IN6_ADDR
 
index aa3cd3041aa08156d86164d18ee1d049dd6e5849..7984cedcdc5c51d3cbb556ffbaae63cccb01a7cc 100755 (executable)
--- a/configure
+++ b/configure
@@ -17358,6 +17358,20 @@ rm -f core conftest.err conftest.$ac_objext \
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+ac_fn_c_check_member "$LINENO" "struct dirent" "d_type" "ac_cv_member_struct_dirent_d_type" "
+$ac_includes_default
+#include <$ac_header_dirent>
+
+"
+if test "x$ac_cv_member_struct_dirent_d_type" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_DIRENT_D_TYPE 1
+_ACEOF
+
+
+fi
+
 if test -n "$NEED_SNPRINTF"; then
     case " $LIBOBJS " in
   *" snprintf.$ac_objext "* ) ;;
index 1cbc836648222267a06fdc9837abe9b4eae26a11..201a00940565b9a970575d056b96f8fe367ebead 100644 (file)
@@ -2257,6 +2257,10 @@ dnl
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #include <$ac_header_dirent>]], [[DIR *d; (void)dirfd(d);]])], [AC_DEFINE(HAVE_DIRFD)], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #include <$ac_header_dirent>]], [[DIR d; memset(&d, 0, sizeof(d)); return(d.dd_fd);]])], [AC_DEFINE(HAVE_DD_FD)], [])])
+AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [
+AC_INCLUDES_DEFAULT
+#include <$ac_header_dirent>
+])
 dnl
 dnl If NEED_SNPRINTF is set, add snprintf.c to LIBOBJS
 dnl (it contains snprintf, vsnprintf, asprintf, and vasprintf)
index 1173ccdeb6fa9c29d4017ff6ef79ea1b43a3e884..37c7e32189bcea9f4651c1ce3dc5382072c92060 100644 (file)
@@ -881,6 +881,10 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
        if (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' ||
            (dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
            continue;
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
+       if (dp->d_type != DT_DIR)
+           continue;
+#endif
 
        /* Add name to session list. */
        if (sessions_len + 1 > sessions_size) {
@@ -908,7 +912,9 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
        } else {
            /* Strip off "/log" and recurse if a dir. */
            pathbuf[sdlen + len - 4] = '\0';
+#ifndef HAVE_STRUCT_DIRENT_D_TYPE
            if (lstat(pathbuf, &sb) == 0 && S_ISDIR(sb.st_mode))
+#endif
                find_sessions(pathbuf, re, user, tty);
        }
     }