[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

dchroot scripts



So, the dchroot wrapper script suggestion in the FAQ is okay, but it
doesn't really work in all cases because dchroot appears to sh -c
... without doing proper quoting on the underlying command.  Commands
like

  mplayer 'rtsp://1.2.3.4:5678/encoder/listen.rm?cloakport=8080'

would choke because the shell would try to glob for ? and fail.

Here's a workaround that will continue to work even if dchroot is
eventually fixed.  You can consolidate this into one script if you
want, but I like having the first two scripts around for use in other
wrappers.

The only potential drawback is that you can't force wildcard expansion
or variable replacement in the chroot shell; the advantage is that
that behavior was a hack anyway, and this works the way you'd expect.


quote-sh
--------
#! /bin/sh

sed -e 's@'"'"'@'"'"'"'"'"'"'"'"'@g' -e 's@^@'"'"'@' -e 's@$@'"'"'@'


quote-args
----------
#! /bin/sh

QUOTED=`echo "$1" | quote-sh`
shift
for A in "$@"; do
        QUOTED="${QUOTED} `echo "$A" | quote-sh`"
done
echo "$QUOTED"


debian-ia32-chroot
------------------
#!/bin/sh

# ln -s this to an executable available via $PATH in the ia32 chroot: it
# will cause that executable to be run in the chroot with the arguments
# quoted correctly.

/usr/bin/dchroot -c ia32 -d "`echo $0 | sed 's|^.*/||'` `quote-args "$@"`"


Cheers,
Kyle



Reply to: