commit:     971f326949216a7edf673bf1b26c644ef20b072d
Author:     Janusz Krzysztofik <jmkrzyszt <AT> gmail <DOT> com>
AuthorDate: Sat Nov  4 07:34:11 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov  4 07:34:11 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=971f3269

scripts/bootstrap-prefix: match user/group more precise

Avoid over-matching on entries from /etc/{passwd,group}.

Bug: https://bugs.gentoo.org/766417
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index b08a497f41..041acf1b1f 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -305,7 +305,7 @@ bootstrap_setup() {
 
        if is-rap ; then
                if [[ ! -f ${ROOT}/etc/passwd ]]; then
-                       if grep -q $(id -un) /etc/passwd; then
+                       if grep -q "^$(id -un):" /etc/passwd; then
                                ln -sf {,"${ROOT}"}/etc/passwd
                        else
                                getent passwd > "${ROOT}"/etc/passwd
@@ -314,7 +314,7 @@ bootstrap_setup() {
                        fi
                fi
                if [[ ! -f ${ROOT}/etc/group ]]; then
-                       if grep -q $(id -gn) /etc/group; then
+                       if grep -q "^$(id -gn):" /etc/group; then
                                ln -sf {,"${ROOT}"}/etc/group
                        else
                                getent group > "${ROOT}"/etc/group

Reply via email to