Unlink the output dump file before we open it, to make sure we don't
authorTheodore Tso <tytso@mit.edu>
Fri, 11 Jan 1991 00:06:24 +0000 (00:06 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 11 Jan 1991 00:06:24 +0000 (00:06 +0000)
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

index 35f21e61042640ec372b4193d8651517f2c4e9a3..98220b51c5690036dea8c943a48986f8da357552 100644 (file)
@@ -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]);