[tor-bugs] #23271 [Core Tor/Tor]: control_auth_cookie isn't deleted when tor stops
Tor Bug Tracker & Wiki
blackhole at torproject.org
Thu Dec 14 13:24:38 UTC 2017
#23271: control_auth_cookie isn't deleted when tor stops
------------------------------+------------------------------------
Reporter: yurivict271 | Owner: (none)
Type: defect | Status: needs_review
Priority: Medium | Milestone: Tor: 0.3.3.x-final
Component: Core Tor/Tor | Version: Tor: 0.3.0.10
Severity: Normal | Resolution:
Keywords: easy tor-control | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
------------------------------+------------------------------------
Comment (by asn):
Here is a review:
1) In `tor_remove_file(char *file)` you can constify `file` as follows:
`tor_remove_file(const char *file)`. Also perhaps worth renaming to
`filename`.
2) This will slightly complicate the patch, but you probably need to use
`get_ext_or_auth_cookie_file_name()` and
`get_controller_cookie_file_name()` to get the right filename, since those
files will be created even if the `CookieAuthFile` torrc option is not set
but the control port is enabled.
I suggest the following way to do this: Use `file_status()` to check if
the filename that those functions returned exists, and unlink it if so.
It's fine to do this extra overhead since this will happen only on
shutdown. Example usage:
{{{
if (file_status(fname) == FN_FILE) {
if (tor_unlink(fname) != 0) {
}}}
3) Consider using `tor_unlink()` instead of `unlink()`, so that it's more
easily testable in the future if need be.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23271#comment:17>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list