Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#13865 closed enhancement (implemented)

Enable Tor to load Torrc from <stdin> removing the need to write it to filesystem

Reported by: naif Owned by:
Priority: Medium Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor, txtorconn, torrc nickm-patch unfrozen
Cc: griffin, rl1987@… Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


This ticket is to enable Tor to load Torrc from <stdin> remove the need to write it.

Tor wrapper libraries such as txtorcon from meejah, today write "torrc" in temporary directory when starting Tor.

It would be good if Tor could load Torrc from standard input, that way wrapper libraries starting Tor would be able to dynamically "feed" Tor a configuration file, without having to write to filesystem.

Child Tickets

Change History (14)

comment:1 Changed 6 years ago by nickm

Keywords: lorax added
Milestone: Tor: 0.2.???

The right syntax is probably something like "tor -f -", if we're following a unixy model.

comment:2 Changed 6 years ago by meejah

I also created this:

Covers the same use-case, but without modifying tor. I presume the use-case is "don't ever put the config data on a disk"?

comment:3 Changed 6 years ago by naif

@meejah yes

comment:4 Changed 6 years ago by rl1987

Preliminary version of the patch:

I probably need to update src/test/ to get this feature covered.

comment:5 Changed 6 years ago by rl1987

Status: newneeds_review

comment:6 Changed 6 years ago by rl1987

Cc: rl1987@… added

comment:7 Changed 6 years ago by naif

With #1976 and #5976 using TxTorCon applications such as GlobaLeaks would be able to use Tor without having to deal with FileSystem interaction!

comment:8 Changed 6 years ago by nickm

Milestone: Tor: 0.2.???Tor: 0.2.6.x-final

comment:9 Changed 6 years ago by nickm

I agree that tests would be good. The code looks mostly plausible. A few suggestions:

  • Make read_torrc_from_stdin const.
  • Maybe instead of a trinary ... ? ... : ... expression, prefer an if...else ? If it's multiline like that it probaby isn't adding to clarity.
  • The strncmp... should be a strcmp. You're checking whether the value is exactly -, not whether it starts with -.
  • How about you replace the body of load_torrc_from_stdin with a call to read_file_to_str_until_eof(STDIN_FILENO, (1u<<24), NULL) ?

comment:10 Changed 6 years ago by dgoulet

Status: needs_reviewneeds_revision

comment:11 Changed 6 years ago by nickm

Keywords: nickm-patch unfrozen added; lorax removed
Status: needs_revisionneeds_review

Looks like rl1987 fixed the above issues!

comment:12 Changed 6 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Looks good now; merging; thanks!

comment:13 Changed 5 years ago by naif

FYI i just opened #14899 to "Enable Tor to work without using filesystem for cached files" that, together with #6411 would complete the ability to have a fully filesystem-free Tor process managed by a third party application controller.

comment:14 Changed 5 years ago by atagar

This was a great addition - thanks rl1987! Stem now takes advantage of this transparently.

Note: See TracTickets for help on using tickets.