summaryrefslogtreecommitdiffstats
path: root/usr.bin/cap_mkdb
diff options
context:
space:
mode:
authorgarga <garga@FreeBSD.org>2016-01-07 10:39:13 +0000
committergarga <garga@FreeBSD.org>2016-01-07 10:39:13 +0000
commitcc39d2e41ac089ff2f629f360e16724dced3e2fb (patch)
tree70ed65065eef1b294230f712e8f246f02166ae82 /usr.bin/cap_mkdb
parent76a48b4688ad9db9f1f4cabc9ea88bfedf2bee05 (diff)
downloadFreeBSD-src-cc39d2e41ac089ff2f629f360e16724dced3e2fb.zip
FreeBSD-src-cc39d2e41ac089ff2f629f360e16724dced3e2fb.tar.gz
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 MFC after: 1 week Sponsored by: Netgate Differential Revision: https://reviews.freebsd.org/D2982
Diffstat (limited to 'usr.bin/cap_mkdb')
-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