]> granicus.if.org Git - sudo/commitdiff
iIf struct dirent has d_type, use it to avoid an extra stat().
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 May 2012 15:14:41 +0000 (11:14 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 May 2012 15:14:41 +0000 (11:14 -0400)
--HG--
branch : 1.7

config.h.in
configure
configure.in
sudoreplay.c

index e313da8e9e05868736453fe0ab8afb599f6d933b..667a7fa55c826ba020c866d2e6a98fae577f67e4 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 35ac565927e84d39e509413d5c0f3c75c4157768..a05f8b74e451572c79bae6e1ec0c52a28ff84f77 100755 (executable)
--- a/configure
+++ b/configure
@@ -17115,6 +17115,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 46cb47834786b73fe6dcbc778d09eb84f1c8a3ed..1745afa8527f21b6e6f4f263e69fb84365b01d2c 100644 (file)
@@ -2133,6 +2133,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 4fff1107dbdb4ce61a4e9a3c7be639a2855905c6..019aa65d0328fca7fa5b78500e9329e6be0c97c3 100644 (file)
@@ -871,6 +871,10 @@ find_sessions(dir, re, user, 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) {
@@ -898,7 +902,9 @@ find_sessions(dir, re, user, 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);
        }
     }