summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1999-05-29 18:51:12 +0000
committermillert <millert@openbsd.org>1999-05-29 18:51:12 +0000
commit4884e5aaba35537ab46f0edf0467295e29d43aec (patch)
treef8ad881a0a0c111681634aaca492c55109b0e1a0
parentwe no longer have a builtin.h file (diff)
downloadwireguard-openbsd-4884e5aaba35537ab46f0edf0467295e29d43aec.tar.xz
wireguard-openbsd-4884e5aaba35537ab46f0edf0467295e29d43aec.zip
Check size as well as mtime when deciding whether or not the file
was changed during edit. Crontab patch from <andrew@untraceable.net>. It may be better to simply do a real compare inline.
-rw-r--r--usr.sbin/cron/crontab.c6
-rw-r--r--usr.sbin/vipw/vipw.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index 685e1bfb1e5..45b5737c82b 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -16,7 +16,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: crontab.c,v 1.13 1999/05/23 17:19:23 aaron Exp $";
+static char rcsid[] = "$Id: crontab.c,v 1.14 1999/05/29 18:51:12 millert Exp $";
#endif
/* crontab - install and manage per-user crontab files
@@ -310,6 +310,7 @@ edit_cmd() {
int ch, t, x;
struct stat statbuf;
time_t mtime;
+ off_t size;
WAIT_T waiter;
PID_T pid, xpid;
@@ -388,6 +389,7 @@ edit_cmd() {
goto fatal;
}
mtime = statbuf.st_mtime;
+ size = statbuf.st_size;
if ((!(editor = getenv("VISUAL")))
&& (!(editor = getenv("EDITOR")))
@@ -468,7 +470,7 @@ edit_cmd() {
perror("fstat");
goto fatal;
}
- if (mtime == statbuf.st_mtime) {
+ if (mtime == statbuf.st_mtime && size == statbuf.st_size) {
fprintf(stderr, "%s: no changes made to crontab\n",
ProgramName);
goto remove;
diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c
index 6308bc92299..dfcb22c6444 100644
--- a/usr.sbin/vipw/vipw.c
+++ b/usr.sbin/vipw/vipw.c
@@ -96,7 +96,8 @@ main(argc, argv)
pw_edit(0, NULL);
if (stat(_PATH_MASTERPASSWD_LOCK, &end))
pw_error(_PATH_MASTERPASSWD_LOCK, 1, 1);
- if (begin.st_mtime == end.st_mtime) {
+ if (begin.st_mtime == end.st_mtime &&
+ begin.st_size == end.st_size) {
warnx("no changes made");
pw_error((char *)NULL, 0, 0);
}