[proposal 136] Re: Proposal: Simplify Configuration of Private Tor Networks
Roger Dingledine
arma at mit.edu
Fri May 23 22:25:03 UTC 2008
On Mon, May 19, 2008 at 11:53:12PM +0200, Karsten Loesing wrote:
> I now solved it differently: When reading configurations from torrc and
> the console, Tor checks if TestingTorNetwork was configured. If so,
> default values for dependent options are changed and the configuration
> is read in again. See lines 3835--3892 in config.c.
[snip]
> + /* If this is a testing network configuration, change defaults
> + * for a list of dependent config options, re-initialize newoptions
> + * with the new defaults, and assign all options to it second time. */
> + if (newoptions->TestingTorNetwork) {
> +
> + /* Change defaults. */
> + #define CHANGE_DEFAULT(key, val) \
> + { \
> + config_var_t *var = config_find_option(&options_format, key); \
> + tor_assert(var); \
> + var->initvalue = tor_strdup(val); \
> + }
> + CHANGE_DEFAULT("ServerDNSAllowBrokenResolvConf", "1");
The var->initvalue = tor_strdup(val) above clobbers the current value of
var->initvalue. For the first time we assign config options, that's fine,
since its initial value is from a static table. But for future times we
assign config options, we'll leak the previous value.
One better approach might be to have a static table of keys (strings)
and values (strings) for the alternate defaults, and walk through the
table doing a config_find_option() on the key and then assigning value
directly from the table (rather than making a copy).
I'll let Nick chime in with other better approaches, or to correct me,
as necessary. :)
--Roger
More information about the tor-dev
mailing list