[tor-bugs] #13111 [Tor]: Tor fails to start if onion keys are zero length

Tor Bug Tracker & Wiki blackhole at torproject.org
Sun Oct 19 06:58:53 UTC 2014


#13111: Tor fails to start if onion keys are zero length
-------------------------+----------------------------------
     Reporter:  ioerror  |      Owner:  teor
         Type:  defect   |     Status:  needs_review
     Priority:  normal   |  Milestone:  Tor: 0.2.6.x-final
    Component:  Tor      |    Version:
   Resolution:           |   Keywords:  tor-relay lorax easy
Actual Points:           |  Parent ID:
       Points:           |
-------------------------+----------------------------------
Changes (by teor):

 * status:  assigned => needs_review
 * keywords:  tor-relay lorax easy needs-tests => tor-relay lorax easy


Comment:

 I've created a git branch that fixes this issue:
 Branch: bug13111-empty-key-files
 Repository: ​​​https://github.com/teor2345/tor.git

 '''New Function:'''
 * int64_t file_size(const char *fname) - like file_status().
  * Returns the size of a (regular) file, or data waiting to be read on a
 FIFO, in bytes. Ignores the sizes returned for any other type of file and
 returns -1.
  * Should this be uint64_t?
  * I'm using -1 to signal error, but using 0 is also a possibility,
 requiring the user to check errno and/or file_status() as well.

 '''Bug Fixes:'''
 * empty RSA & curve25519 key files - overwrite empty key files rather than
 failing to start tor

 '''Improved Performance: (slightly?)'''
 * empty stats file while reading in extrainfo for router descriptor - skip
 reading file
 * empty router / extra info store files - skip reload
 * empty state file - skip load

 '''Unit Tests:'''
 After running make check, make test, benchmarks, and chutney --flavour
 bridges+ipv6, the file_size() function has been run 48 times. I'm ok with
 that level of coverage.

 '''Testing:'''

 Check desired behaviour: zero-length key file -> regenerate
 {{{
 src/or/tor --ShutdownWaitLength 0 --DataDirectory /tmp/tor --ORPort 12345
 ^C # when the keys have been generated
 ls /tmp/tor/keys/
 rm /tmp/tor/keys/secret_id_key
 touch /tmp/tor/keys/secret_id_key
 rm /tmp/tor/keys/secret_onion_key
 touch /tmp/tor/keys/secret_onion_key
 rm /tmp/tor/keys/secret_onion_key_ntor
 touch /tmp/tor/keys/secret_onion_key_ntor
 src/or/tor --ShutdownWaitLength 0 --DataDirectory /tmp/tor --ORPort 12345
 }}}

 Ensure previous behaviour: no key file -> regenerate
 {{{
 src/or/tor --ShutdownWaitLength 0 --DataDirectory /tmp/tor --ORPort 12345
 ^C # when the keys have been generated
 ls /tmp/tor/keys/
 rm /tmp/tor/keys/secret_id_key
 rm /tmp/tor/keys/secret_onion_key
 rm /tmp/tor/keys/secret_onion_key_ntor
 src/or/tor --ShutdownWaitLength 0 --DataDirectory /tmp/tor --ORPort 12345
 }}}

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


More information about the tor-bugs mailing list