From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4884C158089 for ; Mon, 23 Oct 2023 20:01:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6B51D2BC034; Mon, 23 Oct 2023 20:01:33 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2EEEE2BC031 for ; Mon, 23 Oct 2023 20:01:33 +0000 (UTC) From: =?UTF-8?q?Ulrich=20M=C3=BCller?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Ulrich=20M=C3=BCller?= , Mike Gilbert Subject: [gentoo-dev] [PATCH] acct-user.eclass: Warn when the user is removed from a group Date: Mon, 23 Oct 2023 22:01:03 +0200 Message-ID: <20231023200119.23497-1-ulm@gentoo.org> X-Mailer: git-send-email 2.42.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 8e4f9b9f-bbff-4485-b5ef-5f873373ac15 X-Archives-Hash: 9cacf45cd10804b09b6ffd9fd5b71b0b Acked-by: Mike Gilbert Signed-off-by: Ulrich Müller --- eclass/acct-user.eclass | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eclass/acct-user.eclass b/eclass/acct-user.eclass index f658aa0eabc3..67fdf509b3b1 100644 --- a/eclass/acct-user.eclass +++ b/eclass/acct-user.eclass @@ -431,6 +431,14 @@ 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 + [[ -n ${del_groups} ]] && + ewarn "Removing user ${ACCT_USER_NAME} from group(s): ${del_groups}" + 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