Don't write ControlPorts to disk till after we setuid and make datadir

Fix for bug 3747; bugfix on 0.2.2.26-beta.
This commit is contained in:
Nick Mathewson 2011-08-17 11:22:16 -04:00
parent 03f6ee8c5f
commit d79d648edc
3 changed files with 9 additions and 3 deletions

6
changes/bug3747 Normal file
View File

@ -0,0 +1,6 @@
o Major bugfixes:
- Write control ports to disk only after switching UID and
creating the data directory. This way, we don't fail when
starting up with a nonexistant DataDirectory and a
ControlPortWriteToFile setting based on that directory. Fixes
bug 3747; bugfix on Tor 0.2.2.26-beta.

View File

@ -1034,6 +1034,9 @@ options_act_reversible(or_options_t *old_options, char **msg)
/* No need to roll back, since you can't change the value. */ /* No need to roll back, since you can't change the value. */
} }
/* Write control ports to disk as appropriate */
control_ports_write_to_file();
if (directory_caches_v2_dir_info(options)) { if (directory_caches_v2_dir_info(options)) {
size_t len = strlen(options->DataDirectory)+32; size_t len = strlen(options->DataDirectory)+32;
char *fn = tor_malloc(len); char *fn = tor_malloc(len);

View File

@ -1061,9 +1061,6 @@ connection_create_listener(const struct sockaddr *listensockaddr,
"%s listening on port %u.", "%s listening on port %u.",
conn_type_to_string(type), gotPort); conn_type_to_string(type), gotPort);
if (type == CONN_TYPE_CONTROL_LISTENER)
control_ports_write_to_file();
conn->state = LISTENER_STATE_READY; conn->state = LISTENER_STATE_READY;
if (start_reading) { if (start_reading) {
connection_start_reading(conn); connection_start_reading(conn);