]> granicus.if.org Git - sudo/commitdiff
Add check for 2-argument form of timespecsub (FreeBSD and BSD/OS) and
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 25 Nov 2004 17:09:31 +0000 (17:09 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 25 Nov 2004 17:09:31 +0000 (17:09 +0000)
fix a typo in the gettimeofday check.

config.h.in
configure
configure.in
sudo_edit.c
visudo.c

index c60cbc6b186499ff567f785e41571f849c7c0234..be7c2109add1457d9c1665c3c36751224086b8d4 100644 (file)
    passwords) */
 #undef HAVE_GETSPWUID
 
-/* Define to 1 if you have the `getttimeofday' function. */
-#undef HAVE_GETTTIMEOFDAY
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
 
 /* Define to 1 if you have the `glob' function. */
 #undef HAVE_GLOB
 /* Define to 1 if you have struct timespec in sys/time.h */
 #undef HAVE_TIMESPEC
 
+/* Define to 1 if you have a timespecsub macro or function that takes
+   two arguments (not three) */
+#undef HAVE_TIMESPECSUB2
+
 /* Define to 1 if you have the `tzset' function. */
 #undef HAVE_TZSET
 
index 3d3abf638bb848d30ea0aae55d789ea2f210440e..3d6f02dd0ab3b9c05efd43503727739c0194e2cb 100755 (executable)
--- a/configure
+++ b/configure
@@ -25610,8 +25610,9 @@ esac
 
 
 
+
 for ac_func in strchr strrchr memchr memcpy memset sysconf tzset \
-              strftime setrlimit initgroups getgroups fstat
+              strftime setrlimit initgroups getgroups fstat gettimeofday
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -27588,105 +27589,8 @@ else
 fi
 done
 
-
-for ac_func in getttimeofday
-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 eval "test \"\${$as_ac_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 gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-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
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&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); } &&
-        { ac_try='test -z "$ac_c_werror_flag"
-                        || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-        { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; 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 conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
- echo "$as_me:$LINENO: checking for struct stat.st_mtim" >&5
+if test X"$ac_cv_type_struct_timespec" != X"no"; then
+    echo "$as_me:$LINENO: checking for struct stat.st_mtim" >&5
 echo $ECHO_N "checking for struct stat.st_mtim... $ECHO_C" >&6
 if test "${ac_cv_member_struct_stat_st_mtim+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 
 fi
 
-fi
-done
+    echo "$as_me:$LINENO: checking for two-parameter timespecsub" >&5
+echo $ECHO_N "checking for two-parameter timespecsub... $ECHO_C" >&6
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+int
+main ()
+{
+struct timespec ts1, ts2; ts1.tv_sec = 1; ts1.tv_nsec = 0; ts2.tv_sec = 0; ts2.tv_nsec = 0; timespecsub(&ts1, &ts2);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 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); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cat >>confdefs.h <<\_ACEOF
+#define HAVE_TIMESPECSUB2 1
+_ACEOF
+
+       echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -33521,6 +33477,8 @@ fi
 
 
 
+
+
 
 
 
index 62cf1d7024ae42ee66501d106ce0e4d8138e7c34..7853b4139168dcf352065a6d682feaac8ad53b16 100644 (file)
@@ -1674,7 +1674,7 @@ dnl
 dnl Function checks
 dnl
 AC_CHECK_FUNCS(strchr strrchr memchr memcpy memset sysconf tzset \
-              strftime setrlimit initgroups getgroups fstat)
+              strftime setrlimit initgroups getgroups fstat gettimeofday)
 if test -z "$SKIP_SETRESUID"; then
     AC_CHECK_FUNCS(setresuid, [SKIP_SETREUID=yes])
 fi
@@ -1703,7 +1703,14 @@ SUDO_FUNC_FNMATCH([AC_DEFINE(HAVE_FNMATCH)], [AC_LIBOBJ(fnmatch)])
 SUDO_FUNC_ISBLANK
 AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom)
 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf, , [NEED_SNPRINTF=1])
-AC_CHECK_FUNCS(getttimeofday, [AC_CHECK_MEMBER([struct stat.st_mtim], AC_DEFINE(HAVE_ST_MTIM), [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))])])
+if test X"$ac_cv_type_struct_timespec" != X"no"; then
+    AC_CHECK_MEMBER([struct stat.st_mtim], AC_DEFINE(HAVE_ST_MTIM), [AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))])
+    AC_MSG_CHECKING([for two-parameter timespecsub])
+    AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/time.h>], [struct timespec ts1, ts2; ts1.tv_sec = 1; ts1.tv_nsec = 0; ts2.tv_sec = 0; ts2.tv_nsec = 0; timespecsub(&ts1, &ts2);],
+       [AC_DEFINE(HAVE_TIMESPECSUB2)
+       AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
+fi
 dnl
 dnl Check for the dirfd function/macro.  If not found, look for dd_fd in DIR.
 dnl
@@ -2266,6 +2273,7 @@ AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimes
 AH_TEMPLATE(HAVE_SYSTRACE, [Define to 1 to build support for tracing subprocesses using systrace(4)])
 AH_TEMPLATE(HAVE_TERMIOS_H, [Define to 1 if you have the <termios.h> header file and the `tcgetattr' function.])
 AH_TEMPLATE(HAVE_TIMESPEC, [Define to 1 if you have struct timespec in sys/time.h])
+AH_TEMPLATE(HAVE_TIMESPECSUB2, [Define to 1 if you have a timespecsub macro or function that takes two arguments (not three)])
 AH_TEMPLATE(HAVE___PROGNAME, [Define to 1 if your crt0.o defines the __progname symbol for you.])
 AH_TEMPLATE(HOST_IN_LOG, [Define to 1 if you want the hostname to be entered into the log file.])
 AH_TEMPLATE(IGNORE_DOT_PATH, [Define to 1 if you want to ignore '.' and empty PATH elements])
index 2858a1294cc8226bb7488fbdd523cb1f0f1ee45e..f60c115297b9d7bcbbabd4d4b855868ceb8a775e 100644 (file)
@@ -294,7 +294,11 @@ int sudo_edit(argc, argv)
             * If mtime and size match but the user spent no measurable
             * time in the editor we can't tell if the file was changed.
             */
+#ifdef HAVE_TIMESPECSUB2
+           timespecsub(&ts1, &ts2);
+#else
            timespecsub(&ts1, &ts2, &ts2);
+#endif
            if (timespecisset(&ts2)) {
                warningx("%s unchanged", tf[i].ofile);
                unlink(tf[i].tfile);
index 160fbe4e051de752315e87a2e85a98de9f8af122..6795909265deb3054c7e4c75886bd9b4de1533bb 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -362,7 +362,11 @@ edit_sudoers(sp, editor, args, lineno)
         * If mtime and size match but the user spent no measurable
         * time in the editor we can't tell if the file was changed.
         */
+#ifdef HAVE_TIMESPECSUB2
+       timespecsub(&ts1, &ts2);
+#else
        timespecsub(&ts1, &ts2, &ts2);
+#endif
        if (timespecisset(&ts2))
            modified = FALSE;
     }