From 45e11186334738444051ffce5bbcef751758f0d7 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 16 Jun 2025 07:11:57 +0000 Subject: [PATCH] eclass/user-info: Sync with Gentoo It's from Gentoo commit 9acc90f195babd6be689ea30a5b6dbdb42ba55a1. --- .../portage-stable/eclass/user-info.eclass | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/user-info.eclass b/sdk_container/src/third_party/portage-stable/eclass/user-info.eclass index 1cc7b82503..848622fe94 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/user-info.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/user-info.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: user-info.eclass @@ -165,13 +165,18 @@ egetgroups() { [[ $# -eq 1 ]] || die "usage: egetgroups " local egroups_arr - if [[ -n "${ROOT}" ]]; then - local pgroup=$(egetent passwd "$1" | cut -d: -f1) - local sgroups=( $(grep -E ":([^:]*,)?$1(,[^:]*)?$" "${ROOT}/etc/group" | cut -d: -f1) ) - # Remove primary group from list - sgroups=${sgroups#${pgroup}} - egroups_arr=( ${pgroup} ${sgroups[@]} ) + if [[ -n "${ROOT}" ]]; then + local pgid=$(egetent passwd "$1" | cut -d: -f4) + local pgroup=$(egetent group "${pgid}" | cut -d: -f1) + local sgroups=( $(grep -E ":([^:]*,)?$1(,[^:]*)?$" "${ROOT}/etc/group" | cut -d: -f1) ) + egroups_arr=( "${pgroup}" ) + local sg + for sg in "${sgroups[@]}"; do + if [[ ${sg} != ${pgroup} ]]; then + egroups_arr+=( "${sg}" ) + fi + done else read -r -a egroups_arr < <(id -G -n "$1") fi