Hello, this is my first post here, I hope this is the right place to ask
this question. I have also asked this on Stack Exchange but I think this
might be a more appropriate audience. I hope that's ok. I'm experencing
a problem with chroot and I am running on Arch Linux x86_64.
I have a 64 bit chroot and a 32 bit chroot. They are identical except
that one is 32 bit and one is 64 bit.
I can enter either of them using "chroot /path/to/chroot". No problems.
If I want to do that as a specific user the command is "chroot
--userspec=user:group /path/to/chroot"
This also works fine for the 64 bit chroot. However it fails for the 32
bit chroot. It fails with status 125 and the message "chroot: invalid user"
Also, doing "chroot --userspec=uid:gid /path/to/chroot" works fine in
both 32 and 64 bit chroots (uid and gid are the numeric ids of the
required user and group).
(All commands are issued as root.)
I am using a work around for this problem. Assuming $user has the
user:group I want (e.g. john:users), I do this:
|u=$(echo $user | awk -F ":" '{print $1}')
g=$(echo $user | awk -F ":" '{print $2}')
uid=$(grep $u /opt/chroot32/etc/passwd | awk -F ":" '{print $3}')
gid=$(grep $g /opt/chroot32/etc/group | awk -F ":" '{print $3}')
echo "Using $uid:$gid in place of $user"
chroot --userspec="$uid:$gid" /opt/chroot32
|
This works - it looks up the desired user:group inside the chroot's
passwd and group files and then uses those for the chroot. And the above
workaround is not necessary when accessing a 64 bit chroot.
I don't know why I am experiencing this inconsistent behaviour, whether
it is a bug or if it's due to me doing something wrong.
Any advice appreciated.
Thanks.