[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-dev] Whonix's help_check_tor_bootstrap.py



Hi adrelanos, I just noticed that Whonix uses Stem. That's great! Just
a few quick thoughts...

https://github.com/Whonix/Whonix/blob/master/whonix_shared/usr/lib/whonixcheck/help_check_tor_bootstrap.py

> with Controller.from_port(port = p) as controller:
>
>   if os.path.exists("/usr/share/whonix/whonix_gateway"):
>     controller.authenticate("password")

You always need to authenticate the controller. Tor will balk if you
omit the authenticate() call, even if it isn't using authentication...

  >>> from stem.control import Controller
  >>> c = Controller.from_port()
  >>> c.get_info('version')
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "stem/control.py", line 960, in get_info
      raise exc
  stem.ProtocolError: GETINFO response didn't have an OK status:
  Authentication required.

You should probably change this to...

  with Controller.from_port(port = p) as controller:
    controller.authenticate()

There also isn't a reason to pass in 'password' unless you're actually
using that as your controller password. ;)

> b = bootstrap_status.split( )
> progress = b[2]
> progress_percent = ( progress.split( "=" ) )[1]
> exit_code=int(progress_percent)

Operating by the positional argument is fine, but a little risky since
Tor is perfectly allowed to rearrange those. I'd suggest the following
instead...

  match = re.match('.* PROGRESS=([0-9]+).*', line)

  if match:
    exit_code = int(match.group(1))

Cheers! -Damian
_______________________________________________
tor-dev mailing list
tor-dev@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev