Arm crashes with 'ControlPort auto'
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.