Commit Graph

17 Commits

Author SHA1 Message Date
Gordon Bergling
bc89b58def libutil: Document function HISTORY within the manpages
Reviewed by:	bcr (mentor)
Approved by:	bcr (mentor)
MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D24795
2020-06-14 05:35:02 +00:00
Mark Johnston
8e7299c08b Typo.
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-06-03 16:47:00 +00:00
Ian Lepore
34e9190d82 Make pw_scan(3) more compatible with getpwent(3) et. al. when processing
data from /etc/passwd rather than /etc/master.passwd.

The libc getpwent(3) and related functions automatically read master.passwd
when run by root, or passwd when run by a non-root user.  When run by non-
root, getpwent() copes with the missing data by setting the corresponding
fields in the passwd struct to known values (zeroes for numbers, or a
pointer to an empty string for literals).  When libutil's pw_scan(3) was
used to parse a line without the root-accessible data, it was leaving
garbage in the corresponding fields.

These changes rename the static pw_init() function used by getpwent() and
friends to __pw_initpwd(), and move it into pw_scan.c so that common init
code can be shared between libc and libutil.  pw_scan(3) now calls
__pw_initpwd() before __pw_scan(), just like the getpwent() family does, so
that reading an arbitrary passwd file in either format and parsing it with
pw_scan(3) returns the same results as getpwent(3) would.

This also adds a new pw_initpwd(3) function to libutil, so that code which
creates passwd structs from scratch in some manner that doesn't involve
pw_scan() can initialize the struct to the values expected by lots of
existing code, which doesn't expect to encounter NULL pointers or garbage
values in some fields.
2018-07-26 18:34:38 +00:00
Renato Botelho
4cf57592f7 Bump .Dd due to changes made in r285050 and r285053
Spotted by:	loos
Approved by:	loos
2015-07-02 19:41:08 +00:00
Renato Botelho
6c5f7b239f Improve pw_lock.3 text changed in r285050
Suggested by:	wblock
Approved by:	gnn
2015-07-02 18:27:18 +00:00
Renato Botelho
d32a66b2a2 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
Baptiste Daroussin
c24c3080ea revert r283969,283970 not needed anymore after r283981 2015-06-04 08:00:11 +00:00
Baptiste Daroussin
86fa42a24a Capitalize the list of accepted variables
Suggested by:	wblock
2015-06-03 22:01:13 +00:00
Baptiste Daroussin
972cf03ed9 Add a pw_mkdb2(3) function which does the same thing as pw_mkdb(3) except
it takes a new argument allowing to specify the endianness of the database
to generate

Differential Revision:	https://reviews.freebsd.org/D2730
Reviewed by:	ian
2015-06-03 20:48:28 +00:00
Baptiste Daroussin
e2835957c4 Fix typo 2015-06-03 19:22:16 +00:00
Baptiste Daroussin
2b7af31cf5 use .Mt to mark up email addresses consistently (part3)
PR:		191174
Submitted by:	Franco Fichtner  <franco at lastsummer.de>
2014-06-23 08:23:05 +00:00
Eitan Adler
1748334408 libutil/pw_util.3: Fix two prototypes.
Reported by:	marino
Obtained from:	DragonFlyBSD (e82b5d3dfa969bfcda5ffadceccc682b6bdcd077)
MFC After:	3 days
2014-02-13 05:13:22 +00:00
Baptiste Daroussin
46f8c63df6 Fix typo 2012-11-03 00:30:22 +00:00
Dag-Erling Smørgrav
192bc3edf4 Correct attribution. 2012-10-31 15:04:27 +00:00
Joel Dahl
2acb4741ca Minor mdoc and language fixes. 2012-10-30 22:30:30 +00:00
Baptiste Daroussin
f5a05b2ba4 Removed unnecessary bits in the header that shows where I stole the template 2012-10-30 22:26:19 +00:00
Baptiste Daroussin
42818163b4 Document the pw_util(3) functions
Reviewed by:	des, gjb
2012-10-30 22:18:08 +00:00