• [gentoo-dev] [PATCH] user.eclass: allow UID/GID 0 in enewuser/enewgroup

    From Mike Gilbert@21:1/5 to All on Fri Jun 24 18:10:01 2022
    Used by acct-{user,group}/root.

    The check is skipped on most systems because root is created by baselayout.
    An error may be produced if a user runs emerge --root=/myroot
    acct-user/root, where /myroot is an empty directory.

    Signed-off-by: Mike Gilbert <floppym@gentoo.org>
    ---
    eclass/user.eclass | 8 ++++----
    1 file changed, 4 insertions(+), 4 deletions(-)

    diff --git a/eclass/user.eclass b/eclass/user.eclass
    index 906e84e83c6..d5b827d2e76 100644
    --- a/eclass/user.eclass
    +++ b/eclass/user.eclass
    @@ -123,13 +123,13 @@ enewuser() {
    # handle uid
    local euid=${1}; shift
    if [[ -n ${euid} && ${euid} != -1 ]] ; then
    - if [[ ${euid} -gt 0 ]] ; then
    + if [[ ${euid} -ge 0 ]] ; then
    if [[ -n $(egetent passwd ${euid}) ]] ; then
    [[ -n ${force_uid} ]] && die "${FUNCNAME}: UID ${euid} already taken"
    euid="next"
    fi
    else
    - eerror "Userid given but is not greater than 0!"
    + eerror "Userid given but is not greater than or equal to 0!"
    die "${euid} is not a valid UID"
    fi
    else
    @@ -289,13 +289,13 @@ enewgroup() {
    # handle gid
    local egid=${1}; shift
    if [[ -n ${egid} && ${egid} != -1 ]] ; then
    - if [[ ${egid} -gt 0 ]] ; then
    + if [[ ${egid} -ge 0 ]] ; then
    if [[ -n $(egetent group ${egid}) ]] ; then
    [[ -n ${force