I am testing mount namespace using the following steps:
# unshare --mount
# mount --bind rootfs/ ns_dir/
# cd ns_dir/
# pivot_root . .
# cd /
My rootfs has sub-folders /lib, /bin, /etc. I have put dependencies for
various binaries including bash and su.
My question relates to the use of su inside the namespace. I tried the following:
root:/# su alice
alice:/$ su bob
su: must be run from a terminal
I want to ask the meaning of the error su: must be run from a terminal. I searched online and find hackish answers like at this link which asks to the following:
echo "import pty; pty.spawn('/bin/bash')" > /tmp/asdf.py
python /tmp/asdf.py
I tried the approach in this answer, but it didn't work. I want to ask what is the right way to resolve this error. I presume the error is occurring because a password needs to be entered to switch the user.
pivot_root . .looks weird to me. Could you explain where do you want to mount the original/?ns_dirto eventually become root. I don't want to mount the original / anywhere. This is how LXC usespivot_root: github.com/lxc/lxc/blob/master/src/lxc/conf.c#L1516lxc-consolethat handles this, then that would be very helpful. Thank you