This patch doesn't apply to current origin/master . Please push a Git branch instead.
Use esc_for_log to quote var->initvalue when it exists (instead of wrapping it with double quotes), and distinguish a NULL initvalue from an empty-string initvalue.
From the documentation comment on esc_for_log in src/or/util.c:
/** Allocate and return a new string representing the contents of <b>s</b>, * surrounded by quotes and using standard C escapes.
So your branch leaks initvalue.
There are at least three ways to avoid freeing the constant string "NULL". One is to tor_strdup it in an else clause. Another is to use the tor_strdup("(null)") which esc_for_log returns if its argument is NULL as your representation of a NULLinitvalue. Another is to stick a second copy of the pointer which esc_for_log returns into another variable which can always be passed to tor_free (because it always holds a pointer to a temporary object or NULL).
Does anything else parse the output of GETINFO config/names? Does control-spec.txt specify its output format?
Multiple optional arguments, especially when the first is defined as 'Text', means that controllers can't differentiate Documentation from the InitialValue. We could redefine the Documentation's Text type as not having quotes but from a parsing perspective... ewww.
Multiple optional arguments, especially when the first is defined as 'Text', means that controllers can't differentiate Documentation from the InitialValue. We could redefine the Documentation's Text type as not having quotes but from a parsing perspective... ewww.
No version of Tor will support both Documentation and InitialValue. If Documentation was removed in Tor 0.2.2.x, arm (and other controllers) should simply drop support for it.
It seems to me that if we want to change the format and semantics of an existing option in a way that the current spec doesn't permit, and if doing so will break current controllers, it might be better just to provide a new GETINFO key and call it something other than "config/names".
Here's a branch that implements a "GETINFO config/defaults" and simply doesn't list anything which has a NULL initvalue (which is a separate commit if you don't want that). This would need a torspec change too, which I can do if this is acceptable.
I tweaked it just a little more (by removing one of the redundant blocks in config.c, and splitting a long line), then squashed and merged into master, which will become Tor 0.2.4.
You can see the changes in "ticket4971" in my public repository.
Thanks again!
Trac: Status: needs_review to closed Resolution: N/Ato implemented