[2998] in Kerberos
Problem with krb5_db_destroy
daemon@ATHENA.MIT.EDU (Steve Lunt)
Mon Jan 31 20:13:28 1994
Date: Mon, 31 Jan 1994 20:04:18 -0500
From: Steve Lunt <lunt@ctt.bellcore.com>
To: kerberos@MIT.EDU
The routine to destroy a database writes zeros to
the ndbm files before unlinking them. This is unwise, since
the ndbm files are mostly holes, and writing to them fills in the holes.
I ran out of space on my file system while destroying the database!
Here's a fix.
-- Steve
Steven J. Lunt lunt@bellcore.com
Information Technology Security RRC 1L-213
Bellcore 444 Hoes Lane
(908) 699-4244 Piscataway, NJ 08854
*** kdb_dbm.c Fri Dec 24 17:46:53 1993
--- kdb_dbm.c.new Mon Jan 31 19:58:53 1994
***************
*** 920,926 ****
}
/*
! * Destroy the database. Zero's out all of the files, just to be sure.
*/
krb5_error_code
destroy_file_suffix(dbname, suffix)
--- 920,926 ----
}
/*
! * Destroy the database.
*/
krb5_error_code
destroy_file_suffix(dbname, suffix)
***************
*** 928,971 ****
char *suffix;
{
char *filename;
- struct stat statb;
- int nb,fd,i;
- char buf[BUFSIZ];
filename = gen_dbsuffix(dbname, suffix);
if (filename == 0)
return ENOMEM;
- if ((fd = open(filename, O_RDWR, 0)) < 0) {
- int retval = errno == ENOENT ? 0 : errno;
- free(filename);
- return retval;
- }
- /* fstat() will probably not fail unless using a remote filesystem
- (which is inappropriate for the kerberos database) so this check
- is mostly paranoia. */
- if (fstat(fd, &statb) == -1) {
- int retval = errno;
- free(filename);
- return retval;
- }
- i = 0;
- while (i < statb.st_size) {
- nb = write(fd, buf, BUFSIZ);
- if (nb < 0) {
- int retval = errno;
- free(filename);
- return retval;
- }
- i += nb;
- }
- /* ??? Is fsync really needed? I don't know of any non-networked
- filesystem which will discard queued writes to disk if a file
- is deleted after it is closed. --jfc */
- #ifndef NOFSYNC
- fsync(fd);
- #endif
- close(fd);
-
if (unlink(filename)) {
int retval = errno;
free(filename);
--- 928,937 ----