summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorgarga <garga@FreeBSD.org>2016-01-14 14:18:10 +0000
committergarga <garga@FreeBSD.org>2016-01-14 14:18:10 +0000
commite76139f566ac2c0ce259cbcfc34d1f90db4d22a3 (patch)
treeb4228615ec609e14eb5ff92745db413385a0c808 /usr.bin
parentba538557c8e8d64174258f335439a5b76b03957e (diff)
downloadFreeBSD-src-e76139f566ac2c0ce259cbcfc34d1f90db4d22a3.zip
FreeBSD-src-e76139f566ac2c0ce259cbcfc34d1f90db4d22a3.tar.gz
MFC r293312:
Make cap_mkdb and services_mkdb file operations sync Similar fix was done for passwd and group operations in r285050. When a temporary file is created and then renamed to replace official file there are no checks to make sure data was written to disk and if a power cycle happens at this time, system can end up with a 0 length file Approved by: bapt Sponsored by: Netgate Differential Revision: https://reviews.freebsd.org/D2982
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cap_mkdb/cap_mkdb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c
index 2f8bd96..bbcedd5 100644
--- a/usr.bin/cap_mkdb/cap_mkdb.c
+++ b/usr.bin/cap_mkdb/cap_mkdb.c
@@ -119,7 +119,7 @@ main(int argc, char *argv[])
(void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv);
if ((capname = strdup(buf)) == NULL)
errx(1, "strdup failed");
- if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR,
+ if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR | O_SYNC,
DEFFILEMODE, DB_HASH, &openinfo)) == NULL)
err(1, "%s", buf);
OpenPOWER on IntegriCloud