with file times and time of day.
/* Define to 1 if you have a timespecsub macro or function that takes two
arguments (not three) */
-#undef HAVE_TIMESPECSUB2
+#undef HAVE_TIMERSUB2
/* Define to 1 if you have the `tzset' function. */
#undef HAVE_TZSET
#undef volatile
/*
- * Macros to pull sec and nsec parts of mtime from struct stat.
- * We need to be able to convert between timeval and timespec
- * so the last 3 digits of tv_nsec are not significant.
+ * Macros to convert ctime and mtime into timevals.
*/
#ifdef HAVE_ST_MTIM
# ifdef HAVE_ST__TIM
-# define mtim_getsec(_x) ((_x).st_mtim.st__tim.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtim.st__tim.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctim.st__tim.tv_sec; (_y)->tv_usec = (_x)->st_ctim.st__tim.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtim.st__tim.tv_sec; (_y)->tv_usec = (_x)->st_mtim.st__tim.tv_usec / 1000; } while (0)
# else
-# define mtim_getsec(_x) ((_x).st_mtim.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtim.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctim.tv_sec; (_y)->tv_usec = (_x)->st_ctim.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtim.tv_sec; (_y)->tv_usec = (_x)->st_mtim.tv_usec / 1000; } while (0)
# endif
#else
# ifdef HAVE_ST_MTIMESPEC
-# define mtim_getsec(_x) ((_x).st_mtimespec.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtimespec.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctimespec.tv_sec; (_y)->tv_usec = (_x)->st_ctimespec.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtimespec.tv_sec; (_y)->tv_usec = (_x)->st_mtimespec.tv_usec / 1000; } while (0)
# else
-# define mtim_getsec(_x) ((_x).st_mtime)
-# define mtim_getnsec(_x) (0)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctime; (_y)->tv_usec = 0; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtime; (_y)->tv_usec = 0; } while (0)
# endif /* HAVE_ST_MTIMESPEC */
#endif /* HAVE_ST_MTIM */
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
- --sysconfdir=DIR read-only single-machine data [etc]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
else
ac_cv_prog_gcc_traditional=no
fi
-rm -f conftest*
+rm -f -r conftest*
if test $ac_cv_prog_gcc_traditional = no; then
$EGREP "$ac_pattern" >/dev/null 2>&1; then
ac_cv_prog_gcc_traditional=yes
fi
-rm -f conftest*
+rm -f -r conftest*
fi
fi
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
else
ac_cv_header_stdc=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
else
ac_cv_type_uid_t=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
else
sudo_cv_type_size_t=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $sudo_cv_type_size_t" >&5
else
sudo_cv_type_ssize_t=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $sudo_cv_type_ssize_t" >&5
else
sudo_cv_type_dev_t=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $sudo_cv_type_dev_t" >&5
else
sudo_cv_type_ino_t=no
fi
-rm -f conftest*
+rm -f -r conftest*
fi
{ echo "$as_me:$LINENO: result: $sudo_cv_type_ino_t" >&5
else
ac_cv_type_getgroups=int
fi
-rm -f conftest*
+rm -f -r conftest*
fi
fi
fi
- { echo "$as_me:$LINENO: checking for two-parameter timespecsub" >&5
-echo $ECHO_N "checking for two-parameter timespecsub... $ECHO_C" >&6; }
+ { echo "$as_me:$LINENO: checking for two-parameter timersub" >&5
+echo $ECHO_N "checking for two-parameter timersub... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
int
main ()
{
-struct timespec ts1, ts2;
-ts1.tv_sec = 1; ts1.tv_nsec = 0; ts2.tv_sec = 0; ts2.tv_nsec = 0;
-#ifndef timespecsub
-#error missing timespecsub
+struct timeval ts1, ts2;
+ts1.tv_sec = 1; ts1.tv_usec = 0; ts2.tv_sec = 0; ts2.tv_usec = 0;
+#ifndef timersub
+#error missing timersub
#endif
-timespecsub(&ts1, &ts2);
+timersub(&ts1, &ts2);
;
return 0;
}
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
-#define HAVE_TIMESPECSUB2 1
+#define HAVE_TIMERSUB2 1
_ACEOF
{ echo "$as_me:$LINENO: result: yes" >&5
echo "$as_me: WARNING: unable to find socket() trying -lsocket -lnsl" >&2;}
{ echo "$as_me:$LINENO: checking for socket in -lsocket" >&5
echo $ECHO_N "checking for socket in -lsocket... $ECHO_C" >&6; }
-if test "${ac_cv_lib_socket_socket_lnsl+set}" = set; then
+if test "${ac_cv_lib_socket_socket+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_socket_socket_lnsl=yes
+ ac_cv_lib_socket_socket=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_socket_socket_lnsl=no
+ ac_cv_lib_socket_socket=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket_lnsl" >&5
-echo "${ECHO_T}$ac_cv_lib_socket_socket_lnsl" >&6; }
-if test $ac_cv_lib_socket_socket_lnsl = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_socket_socket" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_socket" >&6; }
+if test $ac_cv_lib_socket_socket = yes; then
NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"
fi
echo "$as_me: WARNING: unable to find inet_addr() trying -lsocket -lnsl" >&2;}
{ echo "$as_me:$LINENO: checking for inet_addr in -lsocket" >&5
echo $ECHO_N "checking for inet_addr in -lsocket... $ECHO_C" >&6; }
-if test "${ac_cv_lib_socket_inet_addr_lnsl+set}" = set; then
+if test "${ac_cv_lib_socket_inet_addr+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_socket_inet_addr_lnsl=yes
+ ac_cv_lib_socket_inet_addr=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_socket_inet_addr_lnsl=no
+ ac_cv_lib_socket_inet_addr=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_socket_inet_addr_lnsl" >&5
-echo "${ECHO_T}$ac_cv_lib_socket_inet_addr_lnsl" >&6; }
-if test $ac_cv_lib_socket_inet_addr_lnsl = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_socket_inet_addr" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_inet_addr" >&6; }
+if test $ac_cv_lib_socket_inet_addr = yes; then
NET_LIBS="${NET_LIBS} -lsocket -lnsl"; LIBS="${LIBS} -lsocket -lnsl"
fi
#
{ echo "$as_me:$LINENO: checking for SD_Init in -laceclnt" >&5
echo $ECHO_N "checking for SD_Init in -laceclnt... $ECHO_C" >&6; }
-if test "${ac_cv_lib_aceclnt_SD_Init_______lpthread_______+set}" = set; then
+if test "${ac_cv_lib_aceclnt_SD_Init+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_aceclnt_SD_Init_______lpthread_______=yes
+ ac_cv_lib_aceclnt_SD_Init=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_aceclnt_SD_Init_______lpthread_______=no
+ ac_cv_lib_aceclnt_SD_Init=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_aceclnt_SD_Init_______lpthread_______" >&5
-echo "${ECHO_T}$ac_cv_lib_aceclnt_SD_Init_______lpthread_______" >&6; }
-if test $ac_cv_lib_aceclnt_SD_Init_______lpthread_______ = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_aceclnt_SD_Init" >&5
+echo "${ECHO_T}$ac_cv_lib_aceclnt_SD_Init" >&6; }
+if test $ac_cv_lib_aceclnt_SD_Init = yes; then
AUTH_OBJS="$AUTH_OBJS securid5.lo";
SUDO_LIBS="${SUDO_LIBS} -laceclnt -lpthread"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- as_ac_Lib=`echo "ac_cv_lib_krb_main$K4LIBS" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for main in -lkrb" >&5
+ { echo "$as_me:$LINENO: checking for main in -lkrb" >&5
echo $ECHO_N "checking for main in -lkrb... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
+if test "${ac_cv_lib_krb_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- eval "$as_ac_Lib=yes"
+ ac_cv_lib_krb_main=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- eval "$as_ac_Lib=no"
+ ac_cv_lib_krb_main=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_krb_main" >&5
+echo "${ECHO_T}$ac_cv_lib_krb_main" >&6; }
+if test $ac_cv_lib_krb_main = yes; then
K4LIBS="-lkrb $K4LIBS"
else
- as_ac_Lib=`echo "ac_cv_lib_krb4_main$K4LIBS" | $as_tr_sh`
-{ echo "$as_me:$LINENO: checking for main in -lkrb4" >&5
+ { echo "$as_me:$LINENO: checking for main in -lkrb4" >&5
echo $ECHO_N "checking for main in -lkrb4... $ECHO_C" >&6; }
-if { as_var=$as_ac_Lib; eval "test \"\${$as_var+set}\" = set"; }; then
+if test "${ac_cv_lib_krb4_main+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- eval "$as_ac_Lib=yes"
+ ac_cv_lib_krb4_main=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- eval "$as_ac_Lib=no"
+ ac_cv_lib_krb4_main=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
-ac_res=`eval echo '${'$as_ac_Lib'}'`
- { echo "$as_me:$LINENO: result: $ac_res" >&5
-echo "${ECHO_T}$ac_res" >&6; }
-if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_krb4_main" >&5
+echo "${ECHO_T}$ac_cv_lib_krb4_main" >&6; }
+if test $ac_cv_lib_krb4_main = yes; then
K4LIBS="-lkrb4 $K4LIBS"
else
K4LIBS="-lkrb $K4LIBS"
AC_CHECK_MEMBER([struct stat.st_mtim], [AC_DEFINE(HAVE_ST_MTIM)]
[AC_CHECK_MEMBER([struct stat.st_mtim.st__tim], AC_DEFINE(HAVE_ST__TIM))],
[AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_ST_MTIMESPEC]))])
- AC_MSG_CHECKING([for two-parameter timespecsub])
+ AC_MSG_CHECKING([for two-parameter timersub])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#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;
-#ifndef timespecsub
-#error missing timespecsub
+#include <sys/time.h>]], [[struct timeval ts1, ts2;
+ts1.tv_sec = 1; ts1.tv_usec = 0; ts2.tv_sec = 0; ts2.tv_usec = 0;
+#ifndef timersub
+#error missing timersub
#endif
-timespecsub(&ts1, &ts2);]])], [AC_DEFINE(HAVE_TIMESPECSUB2)
+timersub(&ts1, &ts2);]])], [AC_DEFINE(HAVE_TIMERSUB2)
AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
fi
dnl
#define _SUDO_CONFIG_H])
AH_BOTTOM([/*
- * Macros to pull sec and nsec parts of mtime from struct stat.
- * We need to be able to convert between timeval and timespec
- * so the last 3 digits of tv_nsec are not significant.
+ * Macros to convert ctime and mtime into timevals.
*/
#ifdef HAVE_ST_MTIM
# ifdef HAVE_ST__TIM
-# define mtim_getsec(_x) ((_x).st_mtim.st__tim.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtim.st__tim.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctim.st__tim.tv_sec; (_y)->tv_usec = (_x)->st_ctim.st__tim.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtim.st__tim.tv_sec; (_y)->tv_usec = (_x)->st_mtim.st__tim.tv_usec / 1000; } while (0)
# else
-# define mtim_getsec(_x) ((_x).st_mtim.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtim.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctim.tv_sec; (_y)->tv_usec = (_x)->st_ctim.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtim.tv_sec; (_y)->tv_usec = (_x)->st_mtim.tv_usec / 1000; } while (0)
# endif
#else
# ifdef HAVE_ST_MTIMESPEC
-# define mtim_getsec(_x) ((_x).st_mtimespec.tv_sec)
-# define mtim_getnsec(_x) (((_x).st_mtimespec.tv_nsec / 1000) * 1000)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctimespec.tv_sec; (_y)->tv_usec = (_x)->st_ctimespec.tv_usec / 1000; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtimespec.tv_sec; (_y)->tv_usec = (_x)->st_mtimespec.tv_usec / 1000; } while (0)
# else
-# define mtim_getsec(_x) ((_x).st_mtime)
-# define mtim_getnsec(_x) (0)
+# define ctim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_ctime; (_y)->tv_usec = 0; } while (0)
+# define mtim_get(_x, _y) do { (_y)->tv_sec = (_x)->st_mtime; (_y)->tv_usec = 0; } while (0)
# endif /* HAVE_ST_MTIMESPEC */
#endif /* HAVE_ST_MTIM */
#endif /* HAVE___PROGNAME */
#endif /* !HAVE_GETPROGNAME */
-#ifndef timespecclear
-# define timespecclear(ts) (ts)->tv_sec = (ts)->tv_nsec = 0
+#ifndef timerclear
+# define timerclear(ts) (ts)->tv_sec = (ts)->tv_nsec = 0
#endif
-#ifndef timespecisset
-# define timespecisset(ts) ((ts)->tv_sec || (ts)->tv_nsec)
+#ifndef timerisset
+# define timerisset(ts) ((ts)->tv_sec || (ts)->tv_nsec)
#endif
-#ifndef timespecsub
-# define timespecsub(minuend, subrahend, difference) \
- do { \
- (difference)->tv_sec = (minuend)->tv_sec - (subrahend)->tv_sec; \
- (difference)->tv_nsec = (minuend)->tv_nsec - (subrahend)->tv_nsec; \
- if ((difference)->tv_nsec < 0) { \
- (difference)->tv_nsec += 1000000000L; \
- (difference)->tv_sec--; \
- } \
- } while (0)
-#endif
-
#ifndef timeradd
# define timeradd(tv1, tv2, total) \
do { \
} \
} while (0)
#endif
-
#ifndef timersub
# define timersub(minuend, subrahend, difference) \
do { \
#include <sys/types.h>
#include <sys/param.h>
+#include <sys/time.h>
#include <sys/stat.h>
#ifndef __TANDEM
# include <sys/file.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#if TIME_WITH_SYS_TIME
+# include <time.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
-#include <time.h>
#include <pwd.h>
#include <grp.h>
-#ifndef HAVE_TIMESPEC
-# include <compat/timespec.h>
-#endif
#include "sudoers.h"
if (def_timestamp_timeout < 0 && sb.st_mtime != 0)
status = TS_CURRENT;
else {
- /* XXX - should use timespec here */
+ /* XXX - should use timeval here */
now = time(NULL);
boottime = get_boottime();
if (def_timestamp_timeout &&
remove_timestamp(remove)
int remove;
{
- struct timespec ts;
+ struct timeval tv;
char *timestampdir, *timestampfile, *path;
int status;
remove = FALSE;
}
} else {
- timespecclear(&ts);
- if (touch(-1, path, &ts) == -1)
+ timerclear(&tv);
+ if (touch(-1, path, &tv) == -1)
error(1, "can't reset %s to Epoch", path);
}
}
#if TIME_WITH_SYS_TIME
# include <time.h>
#endif
-#ifndef HAVE_TIMESPEC
-# include <compat/timespec.h>
-#endif
#include <compat.h>
* timespecs in struct stat or, otherwise, using time().
*/
int
-gettime(ts)
- struct timespec *ts;
+gettime(tv)
+ struct timeval *tv;
{
int rval;
#if defined(HAVE_GETTIMEOFDAY) && (defined(HAVE_ST_MTIM) || defined(HAVE_ST_MTIMESPEC))
- struct timeval tv;
-
- rval = gettimeofday(&tv, NULL);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec * 1000;
+ rval = gettimeofday(tv, NULL);
#else
- rval = (int)time(&ts->tv_sec);
- ts->tv_nsec = 0;
+ rval = (int)time(&tv->tv_sec);
+ tv->tv_usec = 0;
#endif
return (rval);
}
void dump_defaults(void);
void dump_auth_methods(void);
int lock_file(int, int);
-int touch(int, char *, struct timespec *);
+int touch(int, char *, struct timeval *);
int user_is_exempt(void);
void set_fqdn(void);
char *sudo_getepw(const struct passwd *);
int pam_prep_user(struct passwd *);
void zero_bytes(volatile void *, size_t);
-int gettime(struct timespec *);
+int gettime(struct timeval *);
FILE *open_sudoers(const char *, int, int *);
void display_privs(struct sudo_nss_list *, struct passwd *);
int display_cmnd(struct sudo_nss_list *, struct passwd *);
#else
# include <varargs.h>
#endif
-#ifndef HAVE_TIMESPEC
-# include <compat/timespec.h>
-#endif
#include "sudoers.h"
#include "interfaces.h"
char *cp; /* scratch char pointer */
char buf[PATH_MAX*2]; /* buffer used for copying files */
char linestr[64]; /* string version of lineno */
- struct timespec ts1, ts2; /* time before and after edit */
- struct timespec orig_mtim; /* starting mtime of sudoers file */
+ struct timeval tv, tv1, tv2; /* time before and after edit */
+ struct timeval orig_mtim; /* starting mtime of sudoers file */
off_t orig_size; /* starting size of sudoers file */
ssize_t nread; /* number of bytes read */
struct stat sb; /* stat buffer */
#endif
error(1, "can't stat %s", sp->path);
orig_size = sb.st_size;
- orig_mtim.tv_sec = mtim_getsec(sb);
- orig_mtim.tv_nsec = mtim_getnsec(sb);
+ mtim_get(&sb, &orig_mtim);
/* Create the temp file if needed and set timestamp. */
if (sp->tpath == NULL) {
* XPG4 specifies that vi's exit value is a function of the
* number of errors during editing (?!?!).
*/
- gettime(&ts1);
+ gettime(&tv1);
if (run_command(editor, av) != -1) {
- gettime(&ts2);
+ gettime(&tv2);
/*
* Sanity checks.
*/
/* Set modified bit if use changed the file. */
modified = TRUE;
+ mtim_get(&sb, &tv);
if (orig_size == sb.st_size &&
- orig_mtim.tv_sec == mtim_getsec(sb) &&
- orig_mtim.tv_nsec == mtim_getnsec(sb)) {
+ orig_mtim.tv_sec == tv.tv_sec &&
+ orig_mtim.tv_usec == tv.tv_usec) {
/*
* 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);
+#ifdef HAVE_TIMERSUB2
+ timersub(&tv1, &tv2);
#else
- timespecsub(&ts1, &ts2, &ts2);
+ timersub(&tv1, &tv2, &tv2);
#endif
- if (timespecisset(&ts2))
+ if (timerisset(&tv2))
modified = FALSE;
}
* Update the access and modify times on an fd or file.
*/
int
-touch(int fd, char *path, struct timespec *tsp)
+touch(int fd, char *path, struct timeval *tvp)
{
struct timeval times[2];
- if (tsp != NULL) {
- times[0].tv_sec = times[1].tv_sec = tsp->tv_sec;
- times[0].tv_usec = times[1].tv_usec = tsp->tv_nsec / 1000;
+ if (tvp != NULL) {
+ times[0].tv_sec = times[1].tv_sec = tvp->tv_sec;
+ times[0].tv_usec = times[1].tv_usec = tvp->tv_usec;
}
#if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES)
if (fd != -1)
- return(futimes(fd, tsp ? times : NULL));
+ return(futimes(fd, tvp ? times : NULL));
else
#endif
if (path != NULL)
- return(utimes(path, tsp ? times : NULL));
+ return(utimes(path, tvp ? times : NULL));
else
return(-1);
}