Skip to Content.
Sympa Menu

sm-discuss - Re: [SM-Discuss] running sorcery in chroot

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: Benoit PAPILLAULT <benoit.papillault AT sourcemage.org>
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: Re: [SM-Discuss] running sorcery in chroot
  • Date: Mon, 08 Nov 2004 11:09:00 +0100

neuron a écrit :
Hello,

I'm trying to run sorcery in chroot, but I'm not able to run sorcery. It
gives me: "cannot open tty-output" error. I found that the failing
command is:

dialog --backtitle 'Sorcery Spell Management Utility' ...

but when I run this command alone in the chroot it works well.

The failing part in dialog is probably here:

if ((fd1 = open_terminal(&device, O_WRONLY)) >= 0
&& (dialog_state.screen_output = fdopen(fd1, "w")) != 0) {
if (newterm(NULL, dialog_state.screen_output, stdin) == 0) {
dlg_exiterr("cannot initialize curses");
}
free(device);
} else {
dlg_exiterr("cannot open tty-output");
}

but I haven't found yet why. Any ideas, please ? :)

--
Neuron

Maybe your /dev tree is not mounted. Moreover, sorcery requires 3 special links:

/dev/stdin
/dev/stdout
/dev/stderr

To use sorcery in a chroot, I use the following bash script (see attachement).

Benoit PAPILLAULT, ISO team
#!/bin/sh

# Author : Benoit PAPILLAULT <benoit.papillault AT free.fr>
# Creation : 23/08/2004

# This script properly enters the stage3 chroot env.

# we use $IMAGE if defined, or else work/image-stage3
if [ -z "${IMAGE}" ]; then
IMAGE="work/image-stage3"
fi
echo "using IMAGE=${IMAGE}"

TOOLS="/tmp/tools2"

# create the HOME dir for root account
mkdir -p "${IMAGE}/root"

# mount /proc & /dev/pts
(cd "${IMAGE}"; \
mkdir -p proc && mount -t proc proc ./proc; \
mkdir -p dev/pts && mount -t devpts devpts ./dev/pts)

# create /dev/stdin /dev/stdout /dev/stderr /dev/null
(cd "${IMAGE}/dev"; ln -sf /proc/self/fd; \
ln -sf fd/0 stdin; ln -sf fd/1 stdout; ln -sf fd/2 stderr; \
mknod null c 1 3)

# mount /tmp/.X11-unix to have X11 access to the host
if [ -n "${DISPLAY}" ]; then
mkdir -p "${IMAGE}/tmp/.X11-unix" &&
mount --bind /tmp/.X11-unix "${IMAGE}/tmp/.X11-unix"
V_DISPLAY="DISPLAY=${DISPLAY}"
# give access to any clients (might be a security risk)
# xhost + (does not work... since we are root)
fi

# check if target tools are installed (spell coreutils)
if [ -x "${IMAGE}/bin/env" ]; then
chroot "${IMAGE}" /bin/env -i \
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH=/bin:/sbin:/usr/bin:/usr/sbin \
${V_DISPLAY} \
/bin/sh --login
else
chroot "${IMAGE}" "${TOOLS}/bin/env" -i \
HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH="/bin:/sbin:/usr/bin:/usr/sbin:${TOOLS}/bin:${TOOLS}/sbin" \
${V_DISPLAY} \
"${TOOLS}/bin/bash" --login
fi

# umount /tmp/.X11 (if needed)
if [ -n "${DISPLAY}" ]; then
umount "${IMAGE}/tmp/.X11-unix"
fi



Archive powered by MHonArc 2.6.24.

Top of Page