freebsd-dev/lib/libutil
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
..
tests humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +00:00
_secure_path.3
_secure_path.c
auth.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
expand_number.3
expand_number.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
flopen.3 open.3: Use .Fa where appropriate 2018-03-04 18:00:32 +00:00
flopen.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
fparseln.3
fparseln.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
gr_util.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
hexdump.3 Fix some nroff style issue 2017-11-11 14:39:13 +00:00
hexdump.c General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
humanize_number.3 humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +00:00
humanize_number.c humanize_number(3): fix math edge case in rounding large numbers 2017-12-28 22:57:34 +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 lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
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 lib/libutil/kinfo_*: style cleanup 2017-01-09 00:47:23 +00:00
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 lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
kinfo_getvmmap.3 Add caveat to kinfo_getvmmap(3) explaining high CPU utilisation. 2017-08-18 16:42:58 +00:00
kinfo_getvmmap.c lib/libutil/kinfo_*: style cleanup 2017-01-09 00:47:23 +00:00
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 When sysctlbyname fails, free buf before returning. 2017-06-01 16:44:39 +00:00
kld.3
kld.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
libutil.h Make pw_scan(3) more compatible with getpwent(3) et. al. when processing 2018-07-26 18:34:38 +00:00
login_auth.3
login_auth.c libutil: minor spelling fixes. 2016-05-18 15:25:45 +00:00
login_cap.3
login_cap.c lib: initial use of reallocarray(3). 2017-04-21 19:27:33 +00:00
login_cap.h
login_class.3 Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
login_class.c Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
login_crypt.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
login_ok.3
login_ok.c
login_times.3
login_times.c
login_tty.3
login_tty.c Use __SCCSID() for SCCS IDs. 2018-05-23 17:02:12 +00:00
login.conf.5 Fix handling of umtxp resource limit in sh(1)/ulimit(1), limits(1), add 2016-03-12 14:54:34 +00:00
Makefile Use __SCCSID() for SCCS IDs. 2018-05-23 17:02:12 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
pidfile.3 libutil: minor spelling fixes. 2016-05-18 15:25:45 +00:00
pidfile.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
property.3
property.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
pty.3 pty.3: Add a HISTORY section 2018-06-02 22:40:16 +00:00
pty.c Use __SCCSID() for SCCS IDs. 2018-05-23 17:02:12 +00:00
pw_util.3 Make pw_scan(3) more compatible with getpwent(3) et. al. when processing 2018-07-26 18:34:38 +00:00
pw_util.c Make pw_scan(3) more compatible with getpwent(3) et. al. when processing 2018-07-26 18:34:38 +00:00
quotafile.3 mdoc: improvements to SEE ALSO. 2014-12-27 08:31:52 +00:00
quotafile.c This exposes ZFS user and group quotas via the normal 2018-07-05 22:56:13 +00:00
realhostname_sa.3
realhostname.3
realhostname.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
stub.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
trimdomain.3
trimdomain.c lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
uucplock.3
uucplock.c Use __SCCSID() for SCCS IDs. 2018-05-23 17:02:12 +00:00