freebsd-skq/lib/libutil
garga 43727d164b 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 infor 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:	bapt
Sponsored by:	Netgate
2015-07-02 17:30:59 +00:00
..
tests Convert libraries to use LIBADD 2014-11-25 11:07:26 +00:00
_secure_path.3
_secure_path.c
auth.c
expand_number.3 Indicate that expand_number is case-insensitive. 2013-11-12 00:56:22 +00:00
expand_number.c The round of expand_number() cleanups. 2013-08-30 11:21:52 +00:00
flopen.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
flopen.c
fparseln.3 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
fparseln.c fparseln(3): Update from NetBSD sources. 2014-07-23 14:57:15 +00:00
gr_util.c When passwd or group information is changed (by pw, vipw, chpass, ...) 2015-07-02 17:30:59 +00:00
hexdump.3 Add support for reading MAM attributes to camcontrol(8) and libcam(3). 2015-06-09 21:39:38 +00:00
hexdump.c
humanize_number.3 don't assert on bad args, instead return an error.. 2013-10-07 22:22:57 +00:00
humanize_number.c don't assert on bad args, instead return an error.. 2013-10-07 22:22:57 +00:00
kinfo_getallproc.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getallproc.c
kinfo_getfile.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getfile.c
kinfo_getproc.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getproc.c
kinfo_getvmmap.3 Add <sys/user.h> to the SYNOPSIS of the kinfo_get*() functions since these 2015-05-27 17:51:06 +00:00
kinfo_getvmmap.c
kinfo_getvmobject.3 Export a list of VM objects in the system via a sysctl. The list can be 2015-05-27 18:11:05 +00:00
kinfo_getvmobject.c Export a list of VM objects in the system via a sysctl. The list can be 2015-05-27 18:11:05 +00:00
kld.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
kld.c
libutil.h revert r283969,283970 not needed anymore after r283981 2015-06-04 08:00:11 +00:00
login_auth.3
login_auth.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
login_cap.3
login_cap.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
login_cap.h
login_class.3 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
login_class.c Fix a clang 3.5 warning about abs(3) being given an argument of type 2014-10-29 20:18:37 +00:00
login_crypt.c
login_ok.3
login_ok.c
login_times.3
login_times.c Fix -Wunsequenced warning 2013-06-29 15:52:48 +00:00
login_tty.3
login_tty.c
login.conf.5 Mention in login.conf.5 which fields may be infinite and how to specifify infinity. 2013-10-27 04:59:18 +00:00
Makefile Revert r284417 it is not necessary anymore 2015-06-15 19:28:07 +00:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
pidfile.3 use .Mt to mark up email addresses consistently (part3) 2014-06-23 08:23:05 +00:00
pidfile.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
property.3
property.c
pty.3
pty.c
pw_util.3 When passwd or group information is changed (by pw, vipw, chpass, ...) 2015-07-02 17:30:59 +00:00
pw_util.c When passwd or group information is changed (by pw, vipw, chpass, ...) 2015-07-02 17:30:59 +00:00
quotafile.3 mdoc: improvements to SEE ALSO. 2014-12-27 08:31:52 +00:00
quotafile.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00
realhostname_sa.3
realhostname.3
realhostname.c
stub.c
trimdomain.3
trimdomain.c
uucplock.3
uucplock.c libutil: Use O_CLOEXEC for internal file descriptors from open(). 2013-08-28 21:10:37 +00:00