From: catlee at globalserve.net (Chris AtLee)
Date: Fri, 23 Apr 1999 03:53:05 -0400
Subject: stdout in a restricted environment
References: <7fn3rs$1v9$1@whisper.globalserve.net> <MXET2.15$7j4.3896@news.shore.net>
Message-ID: <7fp92n$9fb$1@whisper.globalserve.net>
Content-Length: 1100
X-UID: 1527                                                  

Michael P. Reilly <arcege at shore.net> wrote in message
news:MXET2.15$7j4.3896 at news.shore.net...
...
> I would suggest making a subclass of RExec that redefines the
> make_delegate_files method.
>
>   def __init__(self, socket, hooks = None, verbose = 0):
>     RExec.__init__(self, hooks=hooks, verbose=verbose)
>     self._data_socket = socket
>
>   def make_delegate_files(self):
>     reader = self._data_socket.makefile('r')
>     writer = self._data_socket.makefile('w')
>     s = self.modules['sys']
>     self.delegate_stdin = FileDelegate(s, 'stdin')
>     self.delegate_stdout = FileDelegate(s, 'stdout')
>     self.delegate_stderr = FileDelegate(s, 'stderr')
>     self.restricted_stdin = FileWrapper(reader)
>     self.restricted_stdout = FileWrapper(writer)
>     self.restricted_stderr = FileWrapper(writer)
>
> Granted, I haven't tried this, but it looks correct. :)

This works, after I put in some code to flush the writer when something
happens...I think I may have had a working solution before but never knew it
because my output wasn't getting flushed :)

Cheers,
Chris






