From 840acfce95299e82a771b43be981b5328f36cff8 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 11 Jan 1991 00:06:24 +0000 Subject: [PATCH] Unlink the output dump file before we open it, to make sure we don't stomp on a running kprop. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1628 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/edit/dump.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c index 35f21e610..98220b51c 100644 --- a/src/admin/edit/dump.c +++ b/src/admin/edit/dump.c @@ -98,6 +98,17 @@ void dump_db(argc, argv) return; } if (argc == 2) { + /* + * Make sure that we don't open and truncate on the fopen, + * since that may hose an on-going kprop process. + * + * We could also control this by opening for read and + * write, doing an flock with LOCK_EX, and then + * truncating the file once we have gotten the lock, + * but that would involve more OS dependancies than I + * want to get into. + */ + unlink(argv[1]); if (!(f = fopen(argv[1], "w"))) { com_err(argv[0], errno, "While opening file %s for writing", argv[1]); -- 2.26.2