[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] [PATCH v2] acct-user.eclass: Warn when the user is removed from a group
From:       Ulrich Müller <ulm () gentoo ! org>
Date:       2023-10-23 20:41:37
Message-ID: 20231023204145.27236-2-ulm () gentoo ! org
[Download RAW message or body]

Acked-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
---
v2: Add explanation and documentation reference to warning message

 eclass/acct-user.eclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass
index f658aa0eabc3..c9d335c4e558 100644
--- a/eclass/acct-user.eclass
+++ b/eclass/acct-user.eclass
@@ -431,6 +431,20 @@ acct-user_pkg_postinst() {
 		opts+=( --prefix "${ROOT}" )
 	fi
 
+	local g old_groups del_groups=""
+	old_groups=$(egetgroups "${ACCT_USER_NAME}")
+	for g in ${old_groups//,/ }; do
+		has "${g}" "${groups[@]}" || del_groups+="${del_groups:+, }${g}"
+	done
+	if [[ -n ${del_groups} ]]; then
+		ewarn "Removing user ${ACCT_USER_NAME} from group(s): ${del_groups}"
+		ewarn "To retain the user's group membership in the local system"
+		ewarn "config, override with ACCT_USER_${ACCT_USER_NAME^^}_GROUPS"
+		ewarn "or ACCT_USER_${ACCT_USER_NAME^^}_GROUPS_ADD in make.conf."
+		ewarn "Documentation reference:"
+		ewarn "https://wiki.gentoo.org/wiki/Practical_guide_to_the_GLEP_81_migration#Override_user_groups"
+	fi
+
 	elog "Updating user ${ACCT_USER_NAME}"
 	# usermod outputs a warning if unlocking the account would result in an
 	# empty password. Hide stderr in a text file and display it if usermod fails.
-- 
2.42.0


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic