mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 12:16:41 +02:00
eclass/user-info: Sync with Gentoo
It's from Gentoo commit 9acc90f195babd6be689ea30a5b6dbdb42ba55a1.
This commit is contained in:
parent
5b1f5f8aee
commit
45e1118633
@ -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 <user>"
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user