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 AFAB515800D for ; Sun, 9 Jul 2023 01:11:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D2C23E0969; Sun, 9 Jul 2023 01:11:45 +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 F0A6EE094B for ; Sun, 9 Jul 2023 01:11:44 +0000 (UTC) From: Mike Gilbert To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] [PATCH] user-info.eclass: egetent: fix lookup by id when ROOT != / Date: Sat, 8 Jul 2023 21:11:41 -0400 Message-ID: <20230709011141.61136-1-floppym@gentoo.org> X-Mailer: git-send-email 2.41.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-Transfer-Encoding: 8bit X-Archives-Salt: ee47ac2a-1c5e-4bcd-9821-76def48c779a X-Archives-Hash: 02aa12d6de9cdb3458d14752eca34d79 Previous to this change, egetent would match any id that starts with the id given as input. For example: egetent group 1 bin::1:root,bin,daemon wheel::10:root floppy::11:root news::13:news uucp::14:uucp console::17: audio::18: cdrom::19: users::100: Adding a colon to the grep expression yeilds the desired result: egetent group 1 bin::1:root,bin,daemon Signed-off-by: Mike Gilbert --- eclass/user-info.eclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eclass/user-info.eclass b/eclass/user-info.eclass index b18f280c1022..1cc7b8250309 100644 --- a/eclass/user-info.eclass +++ b/eclass/user-info.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2022 Gentoo Authors +# Copyright 1999-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: user-info.eclass @@ -64,7 +64,7 @@ egetent() { getent "${db}" "${key}" else if [[ ${key} =~ ^[[:digit:]]+$ ]]; then - grep -E "^([^:]*:){2}${key}" "${ROOT}/etc/${db}" + grep -E "^([^:]*:){2}${key}:" "${ROOT}/etc/${db}" else grep "^${key}:" "${ROOT}/etc/${db}" fi -- 2.41.0