On 02/11/2018 09:17 PM, Bruce Dubbs wrote:
Tim Tassonis wrote:
Hi all
I currently building LFS (svn) and seem to get a problem doing su in
the chroot environment. I am past shadow now and have set-up a user to
work with. The user however should be able to su to root. I have done
the same on lfs 7.9 and lfs 8.0 without problems.
I think, I follow the book when entering the chroot:
LFS=/lfs export LFS
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi
chroot "$LFS" /tools/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash --login +h
In chroot, /dev/pts looks like this:
root@lfsd82:/# ls -ld /dev/pts
drwxr-xr-x 2 root root 0 Feb 11 19:38 /dev/pts
root@lfsd82:/# ls -ld /dev/pts/*
c--------- 1 root root 5, 2 Feb 11 19:38 /dev/pts/ptmx
I can then call "login", enter the user's userid and password and get
a shell. I can also do a "su - timtas", which also works.
If I then call "su -" under the user, I always get:
su: must be run from a terminal
The contents of /dev/pts in the chroot always stay:
timtas@lfsd82:~$ ls -l /dev/pts/
total 0
c--------- 1 root root 5, 2 Feb 11 19:38 ptmx
What am I missing?
Well I'm attaching what I use. Of course you have to make sure the
non-root user is created in chroot and has a home directory.
Run mount-virt.sh, then enter chroot. You should be able to su from
there after a 'useradd -m userid'.
Thanks for that. Just another quick question: what are your contents in
/dev/pts after you entered chroot?
I have read some stuff now and someone pointed to a glibc issue when
failing to dereference /proc/self/fd/0. In my chroot, /proc/self/fd/0
points to:
root@lfsd82:/# ls -l /proc/self/fd/0
lrwx------ 1 root root 64 Feb 11 21:01 /proc/self/fd/0 -> /dev/pts/0
which doesn't exist in my chroot. This then seems to trigger the errors,
as the glibc function ttyname() fails in that case.
Somehow, the chroot call seems not to inherit the tty from outside and
therefore no valid tty exist in the chroot.
-- Bruce
--
decentral.ch - IT Stuff
Tim Tassonis
Hohlstrasse 400
c/o Baubüro Insitu
8048 Zürich
st...@decentral.ch
+41 79 229 36 17
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
Do not top post on this list.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
http://en.wikipedia.org/wiki/Posting_style