Use utimes() and futimes() instead of utime() in touch(), emulating as needed.

Not all systems are able to support setting the times of an fd so touch()
takes both an fd and a file name as arguments.
This commit is contained in:
Todd C. Miller
2004-09-07 17:14:52 +00:00
parent 03b53b6911
commit 1c20ff1a6d
12 changed files with 271 additions and 157 deletions

View File

@@ -103,7 +103,7 @@ SRCS = alloc.c alloca.c check.c closefrom.c def_data.c defaults.c env.c err.c \
goodpath.c interfaces.c ldap.c lex.yy.c lsearch.c logging.c parse.c \
parse.lex parse.yacc set_perms.c sigaction.c snprintf.c strcasecmp.c \
strerror.c strlcat.c strlcpy.c sudo.c sudo_noexec.c sudo.tab.c \
sudo_edit.c testsudoers.c tgetpass.c utime.c visudo.c zero_bytes.c \
sudo_edit.c testsudoers.c tgetpass.c utimes.c visudo.c zero_bytes.c \
$(AUTH_SRCS)
AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \

24
aclocal.m4 vendored
View File

@@ -210,30 +210,6 @@ dnl
AC_DEFUN(SUDO_TYPE_INO_T,
[SUDO_CHECK_TYPE(ino_t, unsigned int)])
dnl
dnl check for POSIX utime() using struct utimbuf
dnl
AC_DEFUN(SUDO_FUNC_UTIME_POSIX,
[AC_MSG_CHECKING(for POSIX utime)
AC_CACHE_VAL(sudo_cv_func_utime_posix,
[rm -f conftestdata; > conftestdata
AC_TRY_RUN([#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
main() {
struct utimbuf ut;
ut.actime = ut.modtime = time(0);
utime("conftestdata", &ut);
exit(0);
}], sudo_cv_func_utime_posix=yes, sudo_cv_func_utime_posix=no,
sudo_cv_func_utime_posix=no)
rm -f core core.* *.core])dnl
AC_MSG_RESULT($sudo_cv_func_utime_posix)
if test $sudo_cv_func_utime_posix = yes; then
AC_DEFINE(HAVE_UTIME_POSIX, 1, [Define if you have a POSIX utime() (uses struct utimbuf).])
fi
])
dnl
dnl check for working fnmatch(3)
dnl

View File

@@ -149,10 +149,11 @@ update_timestamp(timestampdir, timestampfile)
char *timestampdir;
char *timestampfile;
{
time_t now = time(NULL);
if (timestamp_uid != 0)
set_perms(PERM_TIMESTAMP);
if (touch(timestampfile ? timestampfile : timestampdir, time(NULL)) == -1) {
if (touch(-1, timestampfile ? timestampfile : timestampdir, now) == -1) {
if (timestampfile) {
int fd = open(timestampfile, O_WRONLY|O_CREAT|O_TRUNC, 0600);
@@ -551,7 +552,7 @@ remove_timestamp(remove)
remove = FALSE;
}
}
if (!remove && touch(ts, 0) == -1)
if (!remove && touch(-1, ts, 0) == -1)
err(1, "can't reset %s to Epoch", ts);
}

View File

@@ -211,6 +211,14 @@ typedef struct sigaction sigaction_t;
# define HAVE_DIRFD
#endif
/*
* Define futimes() in terms of futimesat() if needed.
*/
#if !defined(HAVE_FUTIMES) && defined(HAVE_FUTIMESAT)
# define futimes(_f, _p, _tv) futimesat(_f, NULL, _tv)
# define HAVE_FUTIMES
#endif
/*
* If we lack getprogname(), emulate with __progname if possible.
* Otherwise, add a prototype for use with our own getprogname.c.

View File

@@ -71,16 +71,16 @@
/* Define if you use OSF DCE. */
#undef HAVE_DCE
/* Define to 1 if your `DIR' contains dd_fd. */
#undef HAVE_DD_FD
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `dirfd' function (not macro). */
/* Define if you have the `fnmatch' function or macro. */
#undef HAVE_DIRFD
/* Define to 1 if your `DIR' contains dd_fd. */
#undef HAVE_DD_FD
/* Define to 1 if you have the `dispcrypt' function. */
#undef HAVE_DISPCRYPT
@@ -102,6 +102,15 @@
/* Define to 1 if you have the `fstat' function. */
#undef HAVE_FSTAT
/* Define to 1 if you have the `futime' function. */
#undef HAVE_FUTIME
/* Define to 1 if you have the `futimes' function. */
#undef HAVE_FUTIMES
/* Define to 1 if you have the `futimesat' function. */
#undef HAVE_FUTIMESAT
/* Define if you use the FWTK authsrv daemon. */
#undef HAVE_FWTK
@@ -168,16 +177,16 @@
/* Define if you use Kerberos V. */
#undef HAVE_KERB5
/* Define if you use LDAP. */
#undef HAVE_LDAP
/* Define if your LDAP needs <lber.h>. (OpenLDAP does not) */
#undef HAVE_LBER_H
/* Define if your LDAP Supports URLs. (OpenLDAP does) */
/* Define if you use LDAP. */
#undef HAVE_LDAP
/* Define to 1 if you have the `ldap_initialize' function. */
#undef HAVE_LDAP_INITIALIZE
/* Define if your LDAP Supports start_tls_s. (OpenLDAP does) */
/* Define to 1 if you have the `ldap_start_tls_s' function. */
#undef HAVE_LDAP_START_TLS_S
/* Define to 1 if you have the `lockf' function. */
@@ -339,15 +348,12 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `utime' function. */
#undef HAVE_UTIME
/* Define to 1 if you have the `utimes' function. */
#undef HAVE_UTIMES
/* Define to 1 if you have the <utime.h> header file. */
#undef HAVE_UTIME_H
/* Define if you have a POSIX utime() (uses struct utimbuf). */
#undef HAVE_UTIME_POSIX
/* Define to 1 if you have the `vasprintf' function. */
#undef HAVE_VASPRINTF

236
configure vendored
View File

@@ -3118,7 +3118,8 @@ fi;
# Check whether --with-ldap-conf-file or --without-ldap-conf-file was given.
if test "${with_ldap_conf_file+set}" = set; then
withval="$with_ldap_conf_file"
cat >>confdefs.h <<_ACEOF
cat >>confdefs.h <<_ACEOF
#define _PATH_LDAP_CONF "$with_ldap_conf_file"
_ACEOF
@@ -5456,7 +5457,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 5459 "configure"' > conftest.$ac_ext
echo '#line 5460 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -6617,7 +6618,7 @@ fi
# Provide some information about the compiler.
echo "$as_me:6620:" \
echo "$as_me:6621:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -7626,11 +7627,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7629: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7630: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7633: \$? = $ac_status" >&5
echo "$as_me:7634: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -7858,11 +7859,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7861: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7862: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7865: \$? = $ac_status" >&5
echo "$as_me:7866: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -7925,11 +7926,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7928: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7929: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7932: \$? = $ac_status" >&5
echo "$as_me:7933: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9905,7 +9906,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 9908 "configure"
#line 9909 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10003,7 +10004,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10006 "configure"
#line 10007 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12139,11 +12140,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:12142: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12143: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:12146: \$? = $ac_status" >&5
echo "$as_me:12147: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -12206,11 +12207,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:12209: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12210: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:12213: \$? = $ac_status" >&5
echo "$as_me:12214: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -13410,7 +13411,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13413 "configure"
#line 13414 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13508,7 +13509,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13511 "configure"
#line 13512 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -14330,11 +14331,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14333: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14334: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:14337: \$? = $ac_status" >&5
echo "$as_me:14338: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -14397,11 +14398,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14400: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14401: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14404: \$? = $ac_status" >&5
echo "$as_me:14405: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16309,11 +16310,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16312: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16313: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16316: \$? = $ac_status" >&5
echo "$as_me:16317: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -16541,11 +16542,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16544: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16545: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16548: \$? = $ac_status" >&5
echo "$as_me:16549: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@@ -16608,11 +16609,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16611: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16612: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:16615: \$? = $ac_status" >&5
echo "$as_me:16616: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -18588,7 +18589,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 18591 "configure"
#line 18592 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -18686,7 +18687,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 18689 "configure"
#line 18690 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -25898,7 +25899,7 @@ fi
done
for ac_func in utime
for ac_func in utimes
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -25977,14 +25978,15 @@ 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 POSIX utime" >&5
echo $ECHO_N "checking for POSIX utime... $ECHO_C" >&6
if test "${sudo_cv_func_utime_posix+set}" = set; then
for ac_func in futimes futimesat
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
rm -f conftestdata; > conftestdata
if test "$cross_compiling" = yes; then
sudo_cv_func_utime_posix=no
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
@@ -25993,52 +25995,159 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
main() {
struct utimbuf ut;
ut.actime = ut.modtime = time(0);
utime("conftestdata", &ut);
exit(0);
/* 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
/* 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_exeext
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
(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
sudo_cv_func_utime_posix=yes
eval "$as_ac_var=yes"
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
sudo_cv_func_utime_posix=no
eval "$as_ac_var=no"
fi
rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
rm -f core core.* *.core
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
break
fi
echo "$as_me:$LINENO: result: $sudo_cv_func_utime_posix" >&5
echo "${ECHO_T}$sudo_cv_func_utime_posix" >&6
if test $sudo_cv_func_utime_posix = yes; then
done
cat >>confdefs.h <<\_ACEOF
#define HAVE_UTIME_POSIX 1
else
for ac_func in futime
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
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* 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
/* 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>&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.$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
fi
else
LIBOBJS="$LIBOBJS utime.$ac_objext"
done
LIBOBJS="$LIBOBJS utimes.$ac_objext"
fi
done
@@ -29700,7 +29809,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
cat >>confdefs.h <<\_ACEOF
cat >>confdefs.h <<\_ACEOF
#define HAVE_LBER_H 1
_ACEOF

View File

@@ -515,7 +515,7 @@ AC_ARG_WITH(ignore-dot, [ --with-ignore-dot ignore '.' in the PATH],
;;
esac])
if test "$ignore_dot" = "on"; then
AC_DEFINE(IGNORE_DOT_PATH, 1, [Define if you want to ignore '.' and empty \$PATH elements])
AC_DEFINE(IGNORE_DOT_PATH, 1, [Define if you want to ignore '.' and empty PATH elements])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
@@ -916,7 +916,7 @@ AC_ARG_WITH(ldap, [ --with-ldap[[=DIR]] enable LDAP support],
;;
esac])
AC_ARG_WITH(ldap-conf-file, [ --with-ldap-conf-file path to LDAP configuration file],
[AC_DEFINE_UNQUOTED(_PATH_LDAP_CONF, "$with_ldap_conf_file")])
[AC_DEFINE_UNQUOTED(_PATH_LDAP_CONF, "$with_ldap_conf_file", [Path to the ldap.conf file])])
AC_ARG_WITH(pc-insults, [ --with-pc-insults replace politically incorrect insults with less offensive ones],
[case $with_pc_insults in
@@ -1704,7 +1704,7 @@ AC_CHECK_FUNCS(lockf flock, [break])
AC_CHECK_FUNCS(waitpid wait3, [break])
AC_CHECK_FUNCS(innetgr _innetgr, [AC_CHECK_FUNCS(getdomainname) [break]])
AC_CHECK_FUNCS(lsearch, , [AC_CHECK_LIB(compat, lsearch, AC_CHECK_HEADER(search.h, AC_DEFINE(HAVE_LSEARCH) [LIBS="${LIBS} -lcompat"], AC_LIBOBJ(lsearch), -), AC_LIBOBJ(lsearch))])
AC_CHECK_FUNCS(utime, [SUDO_FUNC_UTIME_POSIX], [AC_LIBOBJ(utime)])
AC_CHECK_FUNCS(utimes, [AC_CHECK_FUNCS(futimes futimesat, [break])], [AC_CHECK_FUNCS(futime) AC_LIBOBJ(utimes)])
SUDO_FUNC_FNMATCH(AC_DEFINE(HAVE_FNMATCH, 1, [Define if you have the `fnmatch' function.]), AC_LIBOBJ(fnmatch))
SUDO_FUNC_ISBLANK
AC_REPLACE_FUNCS(strerror strcasecmp sigaction strlcpy strlcat closefrom)
@@ -2115,7 +2115,7 @@ if test -n "$with_ldap"; then
AC_TRY_LINK([#include <sys/types.h>
#include <ldap.h>], [(void)ldap_init(0, 0)], [AC_MSG_RESULT([no])], [
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_LBER_H)])
AC_DEFINE(HAVE_LBER_H, 1, [Define to 1 if your LDAP needs <lber.h>. (OpenLDAP does not)])])
AC_CHECK_FUNCS(ldap_initialize ldap_start_tls_s)

View File

@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#ifdef HAVE_FLOCK
# include <sys/file.h>
#endif /* HAVE_FLOCK */
@@ -31,13 +32,6 @@
#endif /* HAVE_UNISTD_H */
#include <fcntl.h>
#include <time.h>
#ifdef HAVE_UTIME
# ifdef HAVE_UTIME_H
# include <utime.h>
# endif /* HAVE_UTIME_H */
#else
# include "emul/utime.h"
#endif /* HAVE_UTIME */
#include "sudo.h"
@@ -46,26 +40,25 @@ static const char rcsid[] = "$Sudo$";
#endif /* lint */
/*
* Update the access and modify times on a file.
* Update the access and modify times on an fd or file.
*/
int
touch(path, when)
touch(fd, path, when)
int fd;
char *path;
time_t when;
{
#ifdef HAVE_UTIME_POSIX
struct utimbuf ut, *utp;
struct timeval times[2];
ut.actime = ut.modtime = when;
utp = &ut;
#else
/* BSD <= 4.3 has no struct utimbuf */
time_t utp[2];
times[0].tv_sec = times[1].tv_sec = when;
times[0].tv_usec = times[1].tv_usec = 0;
utp[0] = utp[1] = when;
#endif /* HAVE_UTIME_POSIX */
return(utime(path, utp));
#if defined(HAVE_FUTIME) || defined(HAVE_FUTIMES)
if (fd != -1)
return(futimes(fd, times));
else
#endif
return(utimes(path, times));
}
/*

8
sudo.h
View File

@@ -172,6 +172,12 @@ void closefrom __P((int));
#ifndef HAVE_GETCWD
char *getcwd __P((char *, size_t size));
#endif
#ifndef HAVE_UTIMES
int utimes __P((const char *, const struct timeval *));
#endif
#ifdef HAVE_FUTIME
int futimes __P((int, const struct timeval *));
#endif
#ifndef HAVE_SNPRINTF
int snprintf __P((char *, size_t, const char *, ...));
#endif
@@ -223,7 +229,7 @@ void dump_defaults __P((void));
void dump_auth_methods __P((void));
void init_envtables __P((void));
int lock_file __P((int, int));
int touch __P((char *, time_t));
int touch __P((int, char *, time_t));
int user_is_exempt __P((void));
void set_fqdn __P((void));
int set_runaspw __P((char *));

View File

@@ -157,7 +157,7 @@ int sudo_edit(argc, argv)
#else
chown(tf[i].tfile, user_uid, user_gid);
#endif
touch(tf[i].tfile, tf[i].omtime);
touch(tf[i].tfd, tf[i].tfile, tf[i].omtime);
}
if (argc == 1)
return(1); /* no files readable, you lose */

View File

@@ -1,6 +1,5 @@
/*
* Copyright (c) 1996, 1998, 1999, 2001
* Todd C. Miller <Todd.Miller@courtesan.com>.
* Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -19,43 +18,58 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
#include "config.h"
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_UTIME_H
# include <utime.h>
#else
# include <emul/utime.h>
#endif
#include "compat.h"
#include "emul/utime.h"
#include "config.h"
#ifndef lint
static const char rcsid[] = "$Sudo$";
#endif /* lint */
#ifndef HAVE_UTIMES
/*
* Emulate utime(3) via utimes(2).
* utime(3) sets the access and mod times of the named file.
* Emulate utimes() via utime()
*/
int
utime(file, tvp)
utimes(file, times)
const char *file;
const struct utimbuf *utp;
const struct timeval *times;
{
if (upt) {
struct timeval tv[2];
if (times != NULL) {
struct utimbuf utb;
tv[0].tv_sec = ut.actime;
tv[0].tv_usec = 0;
tv[1].tv_sec = ut.modtime;
tv[1].tv_usec = 0;
return(utimes(file, tv);
} else {
return(utimes(file, NULL);
}
utb.actime = (time_t)times[0].tv_sec;
utb.modtime = (time_t)times[1].tv_sec;
return(utime(file, &utb));
} else
return(utime(file, NULL));
}
#endif /* !HAVE_UTIMES */
#ifdef HAVE_FUTIME
/*
* Emulate futimes() via futime()
*/
int
futimes(fd, times)
int fd;
const struct timeval *times;
{
if (times != NULL) {
struct utimbuf utb;
utb.actime = (time_t)times[0].tv_sec;
utb.modtime = (time_t)times[1].tv_sec;
return(futime(fd, &utb));
} else
return(futime(fd, NULL));
}
#endif /* HAVE_FUTIME */

View File

@@ -220,8 +220,8 @@ main(argc, argv)
write(stmp_fd, buf, 1);
}
(void) touch(stmp_fd, stmp, sudoers_sb.st_mtime);
(void) close(stmp_fd);
(void) touch(stmp, sudoers_sb.st_mtime);
/* Parse sudoers to pull in editor and env_editor conf values. */
if ((yyin = fopen(stmp, "r"))) {