Browse Source

Add builduser to same groups as on host

This prevents permission errors when relying on a user's group
for accessing certain files (made available within the container
via bind mounts).
custom-20210202
Martchus 2 months ago
parent
commit
b981c6afe8
  1. 7
      makechrootpkg.in

7
makechrootpkg.in

@ -159,6 +159,7 @@ prepare_chroot() {
local builduser_uid builduser_gid
builduser_uid="$(id -u "$makepkg_user")"
builduser_gid="$(id -g "$makepkg_user")"
builduser_gids="$(id -G "$makepkg_user")"
local install="install -o $builduser_uid -g $builduser_gid"
local x
@ -167,6 +168,12 @@ prepare_chroot() {
# an x86_64 host).
sed -e '/^builduser:/d' -i "$copydir"/etc/{passwd,shadow,group}
printf >>"$copydir/etc/group" 'builduser:x:%d:\n' "$builduser_gid"
for gid in $builduser_gids; do
if [[ $gid != $builduser_gid ]]; then
group_name=$(getent group "$gid" | cut -d: -f1)
printf >>"$copydir/etc/group" "$group_name:x:%d:builduser\n" "$gid"
fi
done
printf >>"$copydir/etc/passwd" 'builduser:x:%d:%d:builduser:/build:/bin/bash\n' "$builduser_uid" "$builduser_gid"
printf >>"$copydir/etc/shadow" 'builduser:!!:%d::::::\n' "$(( $(date -u +%s) / 86400 ))"

Loading…
Cancel
Save