Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12863
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!prichard.zen.co.uk.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.com> |
| Subject | Re: Can't use subprocess.Popen() after os.chroot() - why? |
| Date | Wed, 07 Sep 2011 02:01:11 +0100 |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| Message-Id | <pan.2011.09.07.01.01.11.196000@nowhere.com> |
| Newsgroups | comp.lang.python |
| References | <b46caa73-f7a7-4154-8643-cf77b052d31e@glegroupsg2000goo.googlegroups.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Lines | 34 |
| Organization | Zen Internet |
| NNTP-Posting-Host | b287de98.news.zen.co.uk |
| X-Trace | DXC=P35cClJVQl\dhTWaQPm9k]0g@SS;SF6nWR9OH0:RnENTZ?2j:BGS9YR^4:f3[2`5E^X3T^>X9HoNZ |
| X-Complaints-To | abuse@zen.co.uk |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12863 |
Show key headers only | View raw
On Sun, 04 Sep 2011 07:22:07 -0700, Erik wrote:
> I'm trying to do the following:
> os.chroot("/tmp/my_chroot")
> p = Popen("/bin/date", stdin=PIPE, stdout=PIPE, stderr=PIPE)
> but the Popen call is dying with the following exception:
> LookupError: unknown encoding: string-escape
>
> Am I missing something here? does the chroot environment need to be
> populated with more than just the date executable in this case?
Yes. It also needs to include any parts of the Python run-time which
Python will try to load while executing subsequent code. In this case, the
module which implements the string-escape encoding.
But fixing that will probably show up yet more files which need to exist
within the pseudo-root. E.g. any shared libraries which the executable
needs (probably at least libc), and any data files which those libraries
need (in the case of /bin/date, it may need /etc/timezone; many programs
may require locale data if you aren't in the "C" locale, and so on).
Whether from Python or from C, chroot() requires a good understanding of
the low-level details of your operating system. If you don't know how to
build a minimal Linux distribution from scratch, you're going to have to
learn many of those details in order to use chroot().
For any non-trivial chroot() usage, it's often easier to install a small
newlib+busybox-based Linux distribution under the pseudo-root than to try
to re-use files from and existing (presumably glibc+coreutils-based)
desktop/server distribution.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Can't use subprocess.Popen() after os.chroot() - why? Erik <erik.williamson@gmail.com> - 2011-09-04 07:22 -0700
Re: Can't use subprocess.Popen() after os.chroot() - why? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-09-04 17:25 +0200
Re: Can't use subprocess.Popen() after os.chroot() - why? Hans Mulder <hansmu@xs4all.nl> - 2011-09-04 19:36 +0200
Re: Can't use subprocess.Popen() after os.chroot() - why? Nobody <nobody@nowhere.com> - 2011-09-07 02:01 +0100
csiph-web