summaryrefslogtreecommitdiff
path: root/usr.bin/sudo/sudo_edit.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2009-12-07 18:43:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2009-12-07 18:43:12 +0000
commit6bfcd37f1f016756dee9e8afa2e1047ced8fd290 (patch)
treee72b60b6ec6b4eaa5e999e93987c77514f86c35c /usr.bin/sudo/sudo_edit.c
parentbef02f94761c7f7a003178056c11d51a8ada33ce (diff)
update to sudo 1.7.2p2
Diffstat (limited to 'usr.bin/sudo/sudo_edit.c')
-rw-r--r--usr.bin/sudo/sudo_edit.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/usr.bin/sudo/sudo_edit.c b/usr.bin/sudo/sudo_edit.c
index fba5a1b945c..d6a4da66a8a 100644
--- a/usr.bin/sudo/sudo_edit.c
+++ b/usr.bin/sudo/sudo_edit.c
@@ -56,7 +56,7 @@
#include "sudo.h"
#ifndef lint
-__unused static const char rcsid[] = "$Sudo: sudo_edit.c,v 1.37 2008/11/09 14:13:12 millert Exp $";
+__unused static const char rcsid[] = "$Sudo: sudo_edit.c,v 1.39 2009/09/30 13:50:58 millert Exp $";
#endif /* lint */
extern sigaction_t saved_sa_int, saved_sa_quit, saved_sa_tstp;
@@ -171,21 +171,23 @@ sudo_edit(argc, argv, envp)
}
close(ofd);
}
-#ifdef HAVE_FSTAT
/*
- * If we are unable to set the mtime on the temp file to the value
- * of the original file just make the stashed mtime match the temp
- * file's mtime. It is better than nothing and we only use the info
+ * We always update the stashed mtime because the time
+ * resolution of the filesystem the temporary file is on may
+ * not match that of the filesystem where the file to be edited
+ * resides. It is OK if touch() fails since we only use the info
* to determine whether or not a file has been modified.
*/
- if (touch(tfd, NULL, &tf[i].omtim) == -1) {
- if (fstat(tfd, &sb) == 0) {
- tf[i].omtim.tv_sec = mtim_getsec(sb);
- tf[i].omtim.tv_nsec = mtim_getnsec(sb);
- }
- /* XXX - else error? */
- }
+ (void) touch(tfd, NULL, &tf[i].omtim);
+#ifdef HAVE_FSTAT
+ error = fstat(tfd, &sb);
+#else
+ error = stat(tf[i].tfile, &sb);
#endif
+ if (!error) {
+ tf[i].omtim.tv_sec = mtim_getsec(sb);
+ tf[i].omtim.tv_nsec = mtim_getnsec(sb);
+ }
close(tfd);
}
if (argc == 1)
@@ -233,7 +235,7 @@ sudo_edit(argc, argv, envp)
(void) sigaction(SIGINT, &saved_sa_int, NULL);
(void) sigaction(SIGQUIT, &saved_sa_quit, NULL);
set_perms(PERM_FULL_USER);
- closefrom(def_closefrom + 1);
+ closefrom(def_closefrom);
execvp(nargv[0], nargv);
warning("unable to execute %s", nargv[0]);
_exit(127);