[tor-bugs] #4896 [Stem]: Chroot set up for stem

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Fri Jan 13 02:01:23 UTC 2012


#4896: Chroot set up for stem
-------------------------+--------------------------------------------------
 Reporter:  gsathya      |          Owner:  atagar
     Type:  enhancement  |         Status:  new   
 Priority:  normal       |      Milestone:        
Component:  Stem         |        Version:        
 Keywords:               |         Parent:        
   Points:               |   Actualpoints:        
-------------------------+--------------------------------------------------

Comment(by gsathya):

 Replying to [comment:1 atagar]:
 > > In stem/socket.py, Define a stripping_function(original_recv, prefix,
 control_file)...
 >
 > In the current master branch there's a "test/mocking.py" which I'll be
 using to make monkey patching more readable and less error prone (via a
 'revert all monkey patching' function).
 >
 > The stripping_function isn't of use to stem users so it should be in
 test/mocking.py instead.
 >

 Sure. I'll change that. But if we use Idea #3, we don't have to muck
 around with monkey patching.

 > > original_recv is the original function...
 >
 > On first thought I'm not sure why you'd need this arg since there's only
 a single recv that we might be wanting to overwrite, though maybe this'll
 make sense when I look closer at the branch...
 >

 We need original_recv because I'm overwriting stem.socket.recv_message in
 Runner.start() to a partial function-- stem.socket.recv_message =
 functools.partial(stem.socket.stripping_function, self._original_recv,
 self.get_test_dir())

 I could do  stem.socket.recv_message =
 functools.partial(stem.socket.stripping_function,
 stem.socket.recv_message, self.get_test_dir())
 Is this what you meant? Or did you want me to remove original_recv
 completely? The latter isn't possible because while closing down the Tor
 instance, in Runner.stop(), I need to revert stem.socket.recv_message to
 the original unmodified function which we have stored in original_recv --
 stem.socket.recv_message = self._original_recv

 > > Add a constant CHROOT_ENV that is set by run_tests.py when the
 --chroot arg is used.
 >
 > I'm not sure why this needs to be a global rather than just an arg to
 start(). Also, as mentioned on irc this should probably be done via
 something like "--target ATTR_CHROOT" rather than adding a new
 run_tests.py arg.
 >

 Like Runner.start(self, connection_type = DEFAULT_TOR_CONNECTION, quiet =
 False, prefix = False)?

 And then in run_tests.py, I could do
         integ_runner.start(connection_type = connection_type, prefix =
 True)

 I didn't want to do this because I'd be making a change to Runner.start
 which is used everywhere, and "prefix" has no meaning here. But, I like
 this better. I'll make the changes. Thanks!

 > > Define a function strip(self, prefix) in ControlMessage.
 >
 > From a coding point of view that does sound much nicer. However, it's a
 bad idea to introduce testing code into the library. There was one spot
 where I broke that rule (an override function for
 "stem.util.system.call()") and I'm currently trying to remove it...
 >

 Yeah got it. I don't like this much either.

 > > If I didn't really make much sense, I blame it on my insomnia trying
 to get this to work. And also it's almost midnight here.
 >
 > Ack! I didn't mean for this to disrupt your sleep. If you'd like I can
 write an alternate patch that uses 'mocking.py' and you can see if you
 like it better or not.
 >

 Sure. But I want to try it first. If I mess it up or take up too much
 time, then you can go ahead and finish it up :)

 > I'll try to look into the code in the next few days unless something in
 the above helps you zero in on an ideal solution.
 >

 Thanks! :)

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/4896#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list