Opened 8 years ago

Closed 4 years ago

#4471 closed defect (fixed)

Arm crashes with 'ControlPort auto'

Reported by: atagar Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Nyx Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Arm assumes querying 'GETCONF ControlPort' either provides an int or fails. The new 'auto' argument breaks this assumption, causing a stacktrace...

cba@cluster3:~$ sudo arm --interface 127.0.0.1:46632
Traceback (most recent call last):
  File "/usr/share/arm/starter.py", line 390, in <module>
    interface.controller.startTorMonitor(time.time() - initTime, expandedEvents, param["startup.blindModeEnabled"])
  File "/usr/share/arm/interface/controller.py", line 1918, in startTorMonitor
    curses.wrapper(drawTorMonitor, startTime, loggedEvents, isBlindMode)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/share/arm/interface/controller.py", line 458, in drawTorMonitor
    torPid = torTools.getConn().getMyPid()
  File "/usr/share/arm/util/torTools.py", line 839, in getMyPid
    return self._getRelayAttr("pid", None)
  File "/usr/share/arm/util/torTools.py", line 1647, in _getRelayAttr
    result = getPid(int(self.getOption("ControlPort", 9051)), self.getOption("PidFile"))
ValueError: invalid literal for int() with base 10: 'auto'

On first glance there's four spots that need to be fixed...

atagar@morrigan:~/Desktop/arm$ grep -R "getOption(\"ControlPort" src/
src/cli/headerPanel.py:      self.vals["tor/controlPort"] = conn.getOption("ControlPort", "0")
src/cli/connections/connEntry.py:    myCtlPort = conn.getOption("ControlPort")
src/cli/graphing/connStats.py:      self.controlPort = conn.getOption("ControlPort", "0")
src/util/torTools.py:          result = getPid(int(self.getOption("ControlPort", 9051)), self.getOption("PidFile"))

The change should be an isdigit check on the response and, if it fails, use the default value (the second argument in the getOption call or None if undefined).

This was caught by PurplePeter.

Child Tickets

Change History (1)

comment:1 Changed 4 years ago by atagar

Resolution: fixed
Severity: Normal
Status: newclosed

Just ran 'ControlPort auto' with the present master codebase and it works. Sucks since you gotta provide the random port but oh well, that's the tradeoff tor made with that feature.

Note: See TracTickets for help on using tickets.