commit:     d39c38ea123c5eaea7f06c1cde0a47ec4d58807d
Author:     Guilherme Amadio <amadio <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 28 11:22:42 2021 +0000
Commit:     Guilherme Amadio <amadio <AT> gentoo <DOT> org>
CommitDate: Thu Oct 28 11:22:42 2021 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d39c38ea

bootstrap-prefix.sh: fix RAP bootstrap with non-local user, bug 766417

When the bootstrapping user is handled by Kerberos and is not local to
the host, the libc from prefix doesn't know how to convert usernames
to user ids, which ends up confusing portage. Using getent from the host
to add the bootstrapping user to ${EPREFIX}/etc/passwd works around this
issue.

Closes: https://bugs.gentoo.org/766417
Signed-off-by: Guilherme Amadio <amadio <AT> gentoo.org>

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

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index ec489f1f26..0e21c83953 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -344,10 +344,24 @@ bootstrap_setup() {
        fi
 
        if is-rap ; then
-               [[ -f ${ROOT}/etc/passwd ]] || getent passwd > 
"${ROOT}"/etc/passwd || \
-                       ln -sf {,"${ROOT}"}/etc/passwd
-               [[ -f ${ROOT}/etc/group ]] || getent group > 
"${ROOT}"/etc/group || \
-                       ln -sf {,"${ROOT}"}/etc/group
+               if [[ ! -f ${ROOT}/etc/passwd ]]; then
+                       if grep -q $(id -un) /etc/passwd; then
+                               ln -sf {,"${ROOT}"}/etc/passwd
+                       else
+                               getent passwd > "${ROOT}"/etc/passwd
+                               # add user if it's not in /etc/passwd, bug 
766417
+                               getent passwd $(id -un) >> "${ROOT}"/etc/passwd
+                       fi
+               fi
+               if [[ ! -f ${ROOT}/etc/group ]]; then
+                       if grep -q $(id -gn) /etc/group; then
+                               ln -sf {,"${ROOT}"}/etc/group
+                       else
+                               getent group > "${ROOT}"/etc/group
+                               # add group if it's not in /etc/group, bug 
766417
+                               getent group $(id -gn) >> "${ROOT}"/etc/group
+                       fi
+               fi
                [[ -f ${ROOT}/etc/resolv.conf ]] || ln -s 
{,"${ROOT}"}/etc/resolv.conf
                [[ -f ${ROOT}/etc/hosts ]] || cp {,"${ROOT}"}/etc/hosts
                local 
profile_linux=default/linux/ARCH/17.0/prefix/$(profile-kernel)

Reply via email to