Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 654876 - user.eclass always bypasses /etc/login.defs when selecting UID for new users
Summary: user.eclass always bypasses /etc/login.defs when selecting UID for new users
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-04 22:07 UTC by Matthew "Archer" Vaughn
Modified: 2022-12-07 00:01 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
proposed patch (user.eclass.patch,1.60 KB, patch)
2018-05-04 22:08 UTC, Matthew "Archer" Vaughn
Details | Diff
proposed patch (user.eclass.patch,1.59 KB, patch)
2018-05-04 22:17 UTC, Matthew "Archer" Vaughn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew "Archer" Vaughn 2018-05-04 22:07:32 UTC
The Portage user.eclass script does not respect the values for SYS_UID_MIN and SYS_UID_MAX when selecting the UID of a new user, always explicitly passing the '-u <UID>' option to 'useradd' with a value selected from the hard-coded range 101-999, even calling it on targets that support allowing useradd to choose a UID for us. This hard-coded range is in the general case unnecessary: in the absence of the '-u' option, 'useradd' will read /etc/login.defs and choose an appropriate allocation from the ranges therein defined for the caller.

There exist machines where the values for SYS_UID_MIN and SYS_UID_MAX set in /etc/login.defs differ from conventional practice (e.g., enterprise environments, wherein the ranges of available system UIDs may be dictated by network mappings). It is preferable to respect these values in such environments where possible.

One also observes that user.eclass already behaves in the desired manner with respect to groups when calling 'groupadd' and falls back on the hard-coded GID range 101-999 only for targets that require it.

The attached patch for user.eclass conservatively modifies the enewuser function to behave similarly to the enewgroup function, following its example, such that a manually set UID is provided by the internal function _enewgroup_next_uid only for targets that require it and where no pre-defined UID is chosen by the ebuild; otherwise, it allows useradd to choose an appropriate UID for us.

Reproducible: Always

Steps to Reproduce:
1. Alter SYS_UID_MIN and SYS_UID_MAX in /etc/login.defs to suitable values outside the range 101-999.
2. Emerge a package that installs a user via the 'enewuser' function.
Actual Results:  
The user has been installed with an UID from the range 101-999.

Expected Results:  
The user has been installed with an UID from the range defined by SYS_UID_MIN and SYS_UID_MAX in /etc/login.defs.
Comment 1 Matthew "Archer" Vaughn 2018-05-04 22:08:07 UTC
Created attachment 529806 [details, diff]
proposed patch
Comment 2 Matthew "Archer" Vaughn 2018-05-04 22:17:31 UTC
Created attachment 529808 [details, diff]
proposed patch

Replaces nonsensical _enewgroup_next_uid function name with _enewuser_next_uid as intended.
Comment 3 Mike Gilbert gentoo-dev 2022-12-07 00:01:24 UTC
user.eclass has been removed from the gentoo repo.