mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 14:51:11 +01:00
Make control_event_conf_changed() take a config_line_t
This commit is contained in:
parent
fadd292bf0
commit
99cf3f99c0
4 changed files with 14 additions and 18 deletions
4
changes/bug31531
Normal file
4
changes/bug31531
Normal file
|
@ -0,0 +1,4 @@
|
|||
o Minor bugfixes (configuration handling):
|
||||
- Make control_event_conf_changed() take in a config_line_t instead of
|
||||
a smartlist(k, v, k, v, ...) where keys are followed by values. Fixes
|
||||
bug 31531; bugfix on 0.2.3.3-alpha. Patch by Neel Chauhan.
|
|
@ -1001,15 +1001,9 @@ set_options(or_options_t *new_val, char **msg)
|
|||
/* Issues a CONF_CHANGED event to notify controller of the change. If Tor is
|
||||
* just starting up then the old_options will be undefined. */
|
||||
if (old_options && old_options != global_options) {
|
||||
smartlist_t *elements = smartlist_new();
|
||||
config_line_t *changes =
|
||||
config_get_changes(get_options_mgr(), old_options, new_val);
|
||||
for (config_line_t *line = changes; line; line = line->next) {
|
||||
smartlist_add(elements, line->key);
|
||||
smartlist_add(elements, line->value);
|
||||
}
|
||||
control_event_conf_changed(elements);
|
||||
smartlist_free(elements);
|
||||
control_event_conf_changed(changes);
|
||||
config_free_lines(changes);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "core/or/origin_circuit_st.h"
|
||||
|
||||
#include "lib/evloop/compat_libevent.h"
|
||||
#include "lib/encoding/confline.h"
|
||||
|
||||
static void flush_queued_events_cb(mainloop_event_t *event, void *arg);
|
||||
static void control_get_bytes_rw_last_sec(uint64_t *r, uint64_t *w);
|
||||
|
@ -1774,23 +1775,19 @@ control_event_guard(const char *nickname, const char *digest,
|
|||
* a smartlist_t containing (key, value, ...) pairs in sequence.
|
||||
* <b>value</b> can be NULL. */
|
||||
int
|
||||
control_event_conf_changed(const smartlist_t *elements)
|
||||
control_event_conf_changed(const config_line_t *elements)
|
||||
{
|
||||
int i;
|
||||
char *result;
|
||||
smartlist_t *lines;
|
||||
if (!EVENT_IS_INTERESTING(EVENT_CONF_CHANGED) ||
|
||||
smartlist_len(elements) == 0) {
|
||||
if (!EVENT_IS_INTERESTING(EVENT_CONF_CHANGED) || !elements) {
|
||||
return 0;
|
||||
}
|
||||
lines = smartlist_new();
|
||||
for (i = 0; i < smartlist_len(elements); i += 2) {
|
||||
char *k = smartlist_get(elements, i);
|
||||
char *v = smartlist_get(elements, i+1);
|
||||
if (v == NULL) {
|
||||
smartlist_add_asprintf(lines, "650-%s", k);
|
||||
for (const config_line_t *line = elements; line; line = line->next) {
|
||||
if (line->value == NULL) {
|
||||
smartlist_add_asprintf(lines, "650-%s", line->key);
|
||||
} else {
|
||||
smartlist_add_asprintf(lines, "650-%s=%s", k, v);
|
||||
smartlist_add_asprintf(lines, "650-%s=%s", line->key, line->value);
|
||||
}
|
||||
}
|
||||
result = smartlist_join_strings(lines, "\r\n", 0, NULL);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define TOR_CONTROL_EVENTS_H
|
||||
|
||||
#include "core/or/ocirc_event.h"
|
||||
#include "lib/encoding/confline.h"
|
||||
|
||||
/** Used to indicate the type of a CIRC_MINOR event passed to the controller.
|
||||
* The various types are defined in control-spec.txt . */
|
||||
|
@ -157,7 +158,7 @@ int control_event_server_error(const char *format, ...)
|
|||
|
||||
int control_event_guard(const char *nickname, const char *digest,
|
||||
const char *status);
|
||||
int control_event_conf_changed(const smartlist_t *elements);
|
||||
int control_event_conf_changed(const config_line_t *elements);
|
||||
int control_event_buildtimeout_set(buildtimeout_set_event_t type,
|
||||
const char *args);
|
||||
int control_event_signal(uintptr_t signal);
|
||||
|
|
Loading…
Add table
Reference in a new issue