#
310173 |
|
16-Dec-2016 |
asomers |
MFC r308806
Speed up pw operations that edit /etc/group or /etc/passwd
r285050 fixed a bug in pw that could lead to /etc/passwd or /etc/group corruption on power loss. However, it fixed it by opening those files with O_SYNC, which is very slow, especially on ZFS. This change replaces O_SYNC with appropriately placed fsync()s instead, which is much faster. Using a ZFS tmpdir, the time to run pw's kyua tests drops from 245s to 35s.
|
#
285205 |
|
06-Jul-2015 |
garga |
MFC r285050, r285053, r285059:
When passwd or group information is changed (by pw, vipw, chpass, ...) temporary file is created and then a rename() call move it to official file. This operation didn't have any check to make sure data was written to disk and if a power cycle happens system could end up with a 0 length passwd or group database.
There is a pfSense bug with more information about it:
https://redmine.pfsense.org/issues/4523
The following changes were made to protect passwd and group operations:
* lib/libutil/gr_util.c: - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file - After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.c - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
* usr.sbin/pwd_mkdb/pwd_mkdb.c - Added O_SYNC flag on dbopen() calls - After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.3 - pw_lock() returns a file descriptor to master password file on success
Differential Revision: https://reviews.freebsd.org/D2978 Approved by: re (kib), bapt (implicit agreed) Sponsored by: Netgate
|
#
285205 |
|
06-Jul-2015 |
garga |
MFC r285050, r285053, r285059:
When passwd or group information is changed (by pw, vipw, chpass, ...) temporary file is created and then a rename() call move it to official file. This operation didn't have any check to make sure data was written to disk and if a power cycle happens system could end up with a 0 length passwd or group database.
There is a pfSense bug with more information about it:
https://redmine.pfsense.org/issues/4523
The following changes were made to protect passwd and group operations:
* lib/libutil/gr_util.c: - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file - After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.c - Replace mkstemp() by mkostemp() with O_SYNC flag to create temp file
* usr.sbin/pwd_mkdb/pwd_mkdb.c - Added O_SYNC flag on dbopen() calls - After rename(), fsync() call on directory for faster result
* lib/libutil/pw_util.3 - pw_lock() returns a file descriptor to master password file on success
Differential Revision: https://reviews.freebsd.org/D2978 Approved by: re (kib), bapt (implicit agreed) Sponsored by: Netgate
|