When passwd and group files are being updated and a power failure happens it can end up corrupted. The issue happened on pfSense and there are details here:
https://redmine.pfsense.org/issues/4523
This patch changes all write operations to be sync. The idea of calling fsync() for directory after rename came from McKusick (thanks!).
We did almost 400 power cycles with this change applied and got any single failure.
Sponsored by: Netgate