diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-08-16 16:41:41 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-08-16 16:41:41 +0000 |
commit | 0690f1fd7ed9b91b795981418ee5790ac6e43b43 (patch) | |
tree | f2ce539ae36e52b1103086909203248626da5a46 /src/or | |
parent | 2268d29e94212b8edbf12c15ea8870d4d0671b7f (diff) | |
download | tor-0690f1fd7ed9b91b795981418ee5790ac6e43b43.tar.gz tor-0690f1fd7ed9b91b795981418ee5790ac6e43b43.zip |
r14590@catbus: nickm | 2007-08-16 12:19:12 -0400
Backport r11117: exit when we fail to write an auth cookie, and do not attempt to rewrite the auth cookie every time we restart.
svn:r11134
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 5 | ||||
-rw-r--r-- | src/or/control.c | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index 13c7a56f6f..fcd0430cfe 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -958,7 +958,10 @@ options_act(or_options_t *old_options) /* Update address policies. */ policies_parse_from_options(options); - init_cookie_authentication(options->CookieAuthentication); + if (init_cookie_authentication(options->CookieAuthentication) < 0) { + log_warn(LD_CONFIG,"Error creating cookie authentication file"); + return -1; + } /* reload keys as needed for rendezvous services. */ if (rend_service_load_keys()<0) { diff --git a/src/or/control.c b/src/or/control.c index 84e0788b43..90ff173ef2 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3933,7 +3933,8 @@ control_event_guard(const char *nickname, const char *digest, /** Choose a random authentication cookie and write it to disk. * Anybody who can read the cookie from disk will be considered - * authorized to use the control connection. */ + * authorized to use the control connection. Return -1 if we can't + * write the file, or 0 on success */ int init_cookie_authentication(int enabled) { @@ -3944,13 +3945,17 @@ init_cookie_authentication(int enabled) return 0; } + if (authentication_cookie_is_set) + return 0; + tor_snprintf(fname, sizeof(fname), "%s/control_auth_cookie", get_options()->DataDirectory); crypto_rand(authentication_cookie, AUTHENTICATION_COOKIE_LEN); authentication_cookie_is_set = 1; if (write_bytes_to_file(fname, authentication_cookie, AUTHENTICATION_COOKIE_LEN, 1)) { - log_warn(LD_FS,"Error writing authentication cookie."); + log_warn(LD_FS,"Error writing authentication cookie to %s.", + escaped(fname)); return -1; } |