The right fix for this shouldn't be the use of O_SYNC, but calling
fsync before the files are moved into place (plus calling fsync on
the directory, which is a good idea).
In fact, pwd_mkdb calls the close method on the db, which the man
page for dbopen claims should flush the file. However, looking at
the sync and close methods in lib/libc/db/hash, it seems the code
for flushing is missing, which is probably the real bug here.