[696] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

kdb5_edit doesn't update mod time of existing 'ok' file

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Fri Sep 2 10:45:34 1994

Date: Fri, 2 Sep 1994 10:45:26 -0400
From: "Jonathan I. Kamens" <jik@cam.ov.com>
To: krb5-bugs@MIT.EDU

The code in kdb5_edit's dump.c to create an 'ok' file opens the file
and then closes it, assuming that that will update the mod time on the
file.

If the file doesn't exist before that operation, it works, but if it
already exists, it doesn't on some systems.  For example, on SunOS
4.1.3, all file access is done by mapping files into memory, and if
you don't actually write to an existing file after opening it, its mod
time isn't updated.

The patch below fixes this problem.  Beware, however, that it ties
into some other fixes of ours (the exit_status patches, which I've
already submitted), so if you don't apply them, you should apply this
one with care.

Jonathan Kamens  |  OpenVision Technologies, Inc.  |   jik@cam.ov.com

--- /afs/gza.com/development/krb5.beta4/src/admin/edit/dump.c	Thu Jun  9 11:34:00 1994
+++ dump.c	Fri Sep  2 10:44:35 1994
@@ -177,8 +177,16 @@
 	if ((fd = open(file_ok, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
 		com_err(progname, errno, "while creating 'ok' file, '%s'",
 			file_ok);
+		exit_status++;
 		free(file_ok);
 		return;
+	}
+	if (write(fd, "", 1) != 1) {
+	     com_err(progname, errno, "while writing to 'ok' file, '%s'",
+		     file_ok);
+	     exit_status++;
+	     free(file_ok);
+	     return;
 	}
 	free(file_ok);
 	close(fd);



home help back first fref pref prev next nref lref last post