I am working on my chroot jail but this time I am stuck. Doctests fail
because SAGE cannot start the standard interfaces. Here is a typical
exception.
In [6]: maxima.interact()
---------------------------------------------------------------------------
<type 'exceptions.RuntimeError'> Traceback (most recent call
last)
...................
<type 'exceptions.RuntimeError'>: Unable to start maxima because the
command 'maxima -p "//usr/local/sage/local/bin/sage-maxima.lisp"'
failed.
maxima.console() works fine. Also the indicated command maxima -p "//
usr/local/sage/local/bin/sage-maxima.lisp" works fine at the bash
prompt (I have
done install-scripts).
Does anybody recognize this situation? In particular I am very worried
that my
prompt is In [x]: and not sage:... What could possibly cause this?
Michel
(1) Maybe you should try building from source? You're going to want
to have a compiler in the chroot anyways, so %sagex will work,
upgrades will work, etc.
(2) What do typing
!usr/local/sage/local/bin/sage-maxima.lisp
at the SAGE prompt do?
William
Michel
Could you try building from source and see if that remedies the problem?
Once you get your chroot jail setup, perhaps it would make sense to
have a premade debian and premade fedora chroot jail for the SAGE
notebook. Then people could download it from sage.math and run
chroot jailed notebooks much more easily. Thoughts?
William
On Jun 4, 2:46 pm, "William Stein" <wst...@gmail.com> wrote:
> Thanks for the bug report about strip_automount_prefix. Please try
> the attached sage-test.
>
> On 6/4/07, Michel <michel.vandenbe...@uhasselt.be> wrote:
>
>
>
>
>
> > I am working on my chroot jail but this time I am stuck. Doctests fail
> > because SAGE cannot start the standard interfaces. Here is a typical
> > exception.
> > In [6]: maxima.interact()
> > ---------------------------------------------------------------------------
> > <type 'exceptions.RuntimeError'> Traceback (most recent call
> > last)
> > ...................
> > <type 'exceptions.RuntimeError'>: Unable to start maxima because the
> > command 'maxima -p "//usr/local/sage/local/bin/sage-maxima.lisp"'
> > failed.
>
> > maxima.console() works fine. Also the indicated command maxima -p "//
> > usr/local/sage/local/bin/sage-maxima.lisp" works fine at the bash
> > prompt (I have
> > done install-scripts).
>
> > Does anybody recognize this situation? In particular I am very worried
> > that my
> > prompt is In [x]: and not sage:... What could possibly cause this?
>
> (1) Maybe you should try building from source? You're going to want
> to have a compiler in the chroot anyways, so %sagex will work,
> upgrades will work, etc.
Yes you are probably right. My minimal install needs to be a little
less
limited than envisioned. I'll start from scratch some other day
(I kept notes so this should be quick).
>
> (2) What do typing
> !usr/local/sage/local/bin/sage-maxima.lisp
> at the SAGE prompt do?
>
>
This gives a syntax error
/usr/local/sage/local/bin/sage-maxima.lisp: line 1: syntax error near
unexpected token `;'
/usr/local/sage/local/bin/sage-maxima.lisp: line 1: `;(setf *prompt-
prefix* "<prompt>")'
but I assume that's natural.
Michel
Could you make a new section of the SAGE install
guide and send me a patch? To do this:
(1) cd to SAGE_ROOT/devel/doc/inst
(2) Type ./build_pdf or ./build_dvi depending
on your preference to make sure you can
build the install guide.
(3) Edit it -- it's just latex.
(4) Start SAGE and type hg_doc.ci() to
check in your changes. Then type
hg_doc.send('inst-doc-patch.hg')
to make a patch for me.
Don't worry -- I'll look over the patch and edit
it after you send it to me.
> Michel
>
> =============================================
>
> The following instructions for making
> sage run in a chroot environment have
> not been audited for security.
>
> Unless otherwise specified all instructions
> have to be executed as root.
>
>
> Step 0: Creating a root directory
> =================================
>
> #mkdir /sage-server
>
> Below we will refer to /sage-server as <sage-server>.
>
> Step 1: Teaching yum how to work with installroot
> =================================================
>
> We want to use
>
> #yum --installroot <sage-server> install packages
>
> Unfortunately the standard entries in /etc/yum.repos.d do not work
> well with "--installroot". No doubt there is a clean solution
> to this problem but I didn't find it.
> So I made a backup copy of /etc/yum.repos.d and
> created the following two files in /etc/yum.repos.d
>
> /etc/yum.repos.d/fedora.repo
> ============================
>
> [base]
> name=Fedora 7 - i386 - Base
> baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Fedora/i386/os
> #mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-7
> enabled=1
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
>
> /etc/yum.repos.d/fedora-updates.repo
> ====================================
>
> [updates-released]
> name=Fedora 7 - i386 - Released Updates
> baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/7/i386/
> #mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc7
> enabled=1
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
>
> I disabled all other repos.
>
>
> Step 2: Installing a minimal FC7 system
> =======================================
>
> My definition of minimal was the following
>
> #yum --installroot <sage-server> bash fileutils sed which make gcc
> gcc-c++ m4 tar
> gzip bzip2 flex bison findutils yum rpm passwd
>
> Sit back and relax. After this command completes you should be able
> to do (as root)
>
> #/usr/sbin/chroot <sage-server>
>
> and be greeted with a bash prompt. Type ^D to exit.
>
> Step 4: Auxiliary steps.
> =======================
>
> a) Populating the dev directory. We use the dev directory of the host
> environment.
>
> #mount --rbind /dev <sage-server>/dev
>
> c) Creating a sage user inside the chrooted environment
>
> #/usr/sbin/chroot <sage-server>
> #/usr/sbin/useradd -u 5000 sage # 5000 is a UID not existing in
> # the host environment
>
> #passwd sage
> Changing password for user sage.
> New UNIX password:
> etc...
>
>
> Step 3: Dowloading and compiling sage
> =====================================
>
> Download the sage source code (a big tar file). Move the source code
> to <sage-server>/root. Do
>
> #tar xvf <source-archive>
>
> This extracts the source code into a directory <sage-root>.
>
> #/usr/sbin/chroot <sage-server>
> #chdir <sage-root>
> #make
> #make test
> #make install
>
>
> This should succeed, otherwise install extra packages as needed. This
> can be done from within the chroot environment (since we have installed
> yum and rpm).
>
> Run sage once to modify the hardcoded paths
>
> #sage
>
> Test if the command "sage" works. If so: exit.
>
> #^D
>
> Step 4: Firing up the notebook
> ==============================
>
> Do as root in the host environment
>
> #/usr/sbin/chroot <sage-server> su - sage -c "sage -notebook"
>
>
> Step 5: Making things more user friendly
> ========================================
>
> Scripts:
>
> /etc/sysconfig/sage-config
> ==========================
> SAGE_SERVER=/sage-root
> ADDRESS=xxx.xxx.xxx.xxx
> PORT=8000
> USER=5000
>
> /usr/local/bin/sage-server
> ==========================
> #!/bin/bash
> . /etc/sysconfig/sage-config
> COMMAND="notebook(address='$ADDRESS', port=$PORT)"
> if ! ( grep $SAGE_SERVER /etc/mtab > /dev/null )
> then
> mount --rbind /dev/ $SAGE_SERVER/dev
> fi
>
> nohup /usr/sbin/chroot $SAGE_SERVER su - sage -c "sage -c \"$COMMAND\" " &
>
> /usr/local/bin/sage-killer
> ===========================
> #!/bin/bash
> . /etc/sysconfig/sage-config
> kill -9 `ps -u $USER -o "pid="` > /dev/null 2>/dev/null
>
> /etc/rc.d/init.d/sage
> =====================
>
> Note: I hate bash. The script below is very bad. It does no error checking
> whatsoever.
>
> To run the initscript at boot do
>
> #/sbin/chkconfig sage on
>
> To disable the initscript do
>
> #/sbin/chkconfig sage off
> =======================================================================
> #!/bin/sh
> #
> # This script starts up a sage notebook in a chroot environment.
> #
> # chkconfig: 2345 35 98
> # description: Run a notebook in chroot environment
> #
>
> . /etc/rc.d/init.d/functions
>
> start()
> {
> echo -n $"Starting sage "
> if [ ! -f /var/lock/subsys/sage ]; then
> nohup /usr/local/bin/sage-server 2> /dev/null > /dev/null &
> fi
> touch /var/lock/subsys/sage
> success
> echo
> return 0
> }
>
> stop()
> {
> echo -n $"Stopping sage "
> /usr/local/bin/sage-killer
> rm -f /var/lock/subsys/sage
> success
> echo
> return 0
> }
>
> status () {
> if [ ! -f /var/lock/subsys/sage ]; then
> echo $"We're stopped!"
> return 1
> else
> echo $"We're running!"
> return 0
> fi
>
> }
> # See how we were called.
> case "$1" in
> start)
> start
> ;;
> stop)
> stop
> ;;
> status)
> status
> ;;
> restart)
> stop
> start
> ;;
> *)
> echo $"Usage: $0 {start|stop|restart|status}"
> exit 1
> esac
>
> exit 0
>
>
>
>
>
>
>
>
>
>
>
>
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org