Code Review for illumos-useradd5

Prepared by:Gordon Ross (gwr) on 2017-Mar-27 17:24 -0400 EDT
Workspace:/tank/ws/illumos-useradd5 (at 29ce33048a3b)
Compare against: /tank/ws/illumos-useradd5 (explicit revision e9542cf7b65f)
Summary of changes: 1727 lines changed: 1428 ins; 262 del; 37 mod; 6354 unchg
Patch of changes: illumos-useradd5.patch
Printable review: illumos-useradd5.pdf

Problem:

1: The header file userdefs.h has a bunch of defines for things
that should not necessarily be constants, but settings that
can be changed by "useradd -D ..." etc.

2: The code to get those settings is currently part of the
"OAM user" commands (usr/src/cmd/oamuser/*) and not in any
library that the various userdefs.h consumers might use.

3: We'd like to have a way to add "vendor" (or distro)
modifications to these defaults, that override the
compiled-in defaults, but not "local" settings.
(Precedence: local, vendor, compiled-in)

4: The useradd defaults are stored in /usr/sadm/defadduser
and /usr/sadm/defaddrole which doesn't work on systems
where /usr is a read-only mount (i.e. some zones).

Proposed solution:

Move the code that reads and writes the "useradd" settings
to a library (libuserdefs), and let programs that need
useradd.h settings link with that library.
(Solves: 1, 2)

Introduce a new location for these settings:
(/etc/default/adduser, /etc/default/addrole)
and use the old locations as "vendor" settings.
The library uses settings (in precedence order)
from: /etc/default/*, /usr/sadm/*, build-in.
(Solves: 3, 4)

The implementation loadss all the settings at once,
with semantcs that new settings override previous,
and just loads (in order) the built-in values, then
the "vendor" values (if any) and finally the "local".

Upgrade and packaging implications:

Both the the old and new locations used to store the
settings for useradd are currently un-tracked by the
packaging systems. The simplest approach to upgrade
is to let packaging continue to ignore those files.

However, if a distro wants to use a tracked file to
install a "vendor" setting in /usr/sadm/defadduser
(i.e. with defparent=/export/home) then before it
should "migrate" that file before installing: i.e.
If /usr/sadm/defadduser exists and
/etc/default/adduser does not exist,
copy /usr/sadm/defadduser to /etc/default/adduser
It's then safe to replace /usr/sadm/defadduser
with a file tracked by packaging.

The changes...

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/cmd-inet/usr.sbin/in.routed/main.c

Remove include userdefs.h where not needed
1 line changed: 0 ins; 1 del; 0 mod; 1066 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/group/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
2 lines changed: 0 ins; 0 del; 2 mod; 81 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/user/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
1 line changed: 0 ins; 0 del; 1 mod; 120 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/user/funcs.c

Add libuserdefs and use in cmd/{oamuser,passwd}
27 lines changed: 27 ins; 0 del; 0 mod; 518 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/user/funcs.h

Add libuserdefs and use in cmd/{oamuser,passwd}
3 lines changed: 3 ins; 0 del; 0 mod; 60 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/user/useradd.c

Add libuserdefs and use in cmd/{oamuser,passwd}
2 lines changed: 0 ins; 2 del; 0 mod; 795 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/oamuser/user/userdefs.c

Add libuserdefs and use in cmd/{oamuser,passwd}
262 lines changed: 6 ins; 227 del; 29 mod; 176 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/cmd/passwd/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
1 line changed: 0 ins; 0 del; 1 mod; 48 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/head/userdefs.h

Add libuserdefs and use in cmd/{oamuser,passwd}
113 lines changed: 81 ins; 29 del; 3 mod; 140 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/lib/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
1 line changed: 1 ins; 0 del; 0 mod; 723 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/lib/libcmdutils/common/gid.c

Remove include userdefs.h where not needed
1 line changed: 0 ins; 1 del; 0 mod; 110 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/lib/libcmdutils/common/uid.c

Remove include userdefs.h where not needed
1 line changed: 0 ins; 1 del; 0 mod; 111 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
51 lines changed: 51 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/Makefile.com

Add libuserdefs and use in cmd/{oamuser,passwd}
58 lines changed: 58 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/common/defaults.c

Add libuserdefs and use in cmd/{oamuser,passwd}
466 lines changed: 466 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/common/llib-luserdefs

Add libuserdefs and use in cmd/{oamuser,passwd}
31 lines changed: 31 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/common/mapfile-vers

Add libuserdefs and use in cmd/{oamuser,passwd}
54 lines changed: 54 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/i386/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
29 lines changed: 29 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/lib/libuserdefs/sparc/Makefile

Add libuserdefs and use in cmd/{oamuser,passwd}
29 lines changed: 29 ins; 0 del; 0 mod; 0 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/lib/pam_modules/unix_auth/unix_auth.c

Remove include userdefs.h where not needed
1 line changed: 0 ins; 1 del; 0 mod; 335 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/pkg/manifests/developer-library-lint.mf

Add libuserdefs and use in cmd/{oamuser,passwd}
2 lines changed: 2 ins; 0 del; 0 mod; 584 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/pkg/manifests/system-library.mf

Add libuserdefs and use in cmd/{oamuser,passwd}
2 lines changed: 2 ins; 0 del; 0 mod; 1308 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/pkg/manifests/system-test-utiltest.mf

Add tests for libuserdefs
6 lines changed: 6 ins; 0 del; 0 mod; 161 unchg

Cdiffs Udiffs Wdiffs Sdiffs Frames Old New Patch Raw usr/src/test/util-tests/tests/Makefile

Add tests for libuserdefs
1 line changed: 0 ins; 0 del; 1 mod; 18 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/Makefile

Add tests for libuserdefs
52 lines changed: 52 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/oamu_01.ksh

Add tests for libuserdefs
87 lines changed: 87 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/oamu_02.ksh

Add tests for libuserdefs
85 lines changed: 85 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/oamu_03.ksh

Add tests for libuserdefs
75 lines changed: 75 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/oamu_defs.c

Add tests for libuserdefs
90 lines changed: 90 ins; 0 del; 0 mod; 0 unchg

------ ------ ------ ------ ------ --- New Patch Raw usr/src/test/util-tests/tests/libuserdefs/oamu_uakey.c

Add tests for libuserdefs
193 lines changed: 193 ins; 0 del; 0 mod; 0 unchg

This code review page was prepared using /tank/ws/illumos-useradd5/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/webrev. Webrev is maintained by the illumos project. The latest version may be obtained here.