#22102 closed defect (wontfix)

Can't HUP with a relative path in Log line

Reported by: pastly Owned by: Jigsaw52
Priority: Medium Milestone: Tor: 0.3.2.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: review-group-18, review-group-19
Cc: Actual Points:
Parent ID: #22731 Points:
Reviewer: Sponsor:

Description

Start Tor with

DataDirectory /home/mtraudt/src/qtime-with-load-testing/datadir-test
Log notice file ./datadir-test/notice.log
RunAsDaemon 1
SocksPort 0

and then sending a HUP after Tor bootstraps to cause

Apr 29 13:58:47.000 [notice] Received reload signal (hup). Reloading config and resetting internal state.
Apr 29 13:58:47.000 [notice] Read configuration file "/home/mtraudt/src/qtime-with-load-testing/torrc-test".
Apr 29 13:58:47.000 [warn] SocksPort, TransPort, NATDPort, DNSPort, and ORPort are all undefined, and there aren't any hidden services configured.  Tor will still run, but probably won't do anything.
Apr 29 13:58:47.000 [warn] Couldn't open file for 'Log notice file ./datadir-test/notice.log': No such file or directory
Apr 29 13:58:47.000 [warn] Failed to parse/validate config: Failed to init Log options. See logs for details.
Apr 29 13:58:47.000 [err] Reading config failed--see warnings above. For usage, try -h.
Apr 29 13:58:47.000 [warn] Restart failed (config error?). Exiting.

May be related to #22101?

Child Tickets

Change History (15)

comment:1 Changed 15 months ago by dgoulet

Milestone: Tor: 0.3.1.x-final

comment:2 Changed 14 months ago by Jigsaw52

Owner: set to Jigsaw52
Status: newassigned

I fixed this on my branch: https://github.com/Jigsaw52/tor/tree/relative_log_fix_22102

Part of the code is the same I used to fix #22101.

Last edited 14 months ago by Jigsaw52 (previous) (diff)

comment:3 Changed 14 months ago by Jigsaw52

Status: assignedneeds_review

comment:4 Changed 14 months ago by teor

Parent ID: #22101
Version: Tor: 0.3.0.6

comment:5 Changed 14 months ago by nickm

Milestone: Tor: 0.3.1.x-finalTor: 0.3.2.x-final

0.3.1 feature freeze today: these don't seem like they will be all sorted out in time. Let's try to make progress in 0.3.2.

comment:6 Changed 14 months ago by nickm

Also see #4885

comment:7 Changed 13 months ago by nickm

Keywords: review-group-18 added

comment:8 Changed 13 months ago by isis

Reviewer: isis

comment:9 Changed 13 months ago by nickm

Okay; these are going to have to wait, IIUC, until somebody can figure out

  • What the best behavior is, and
  • How we can change it without breaking everybody who relies on the current behavior.

comment:10 Changed 13 months ago by nickm

Keywords: review-group-19 added

comment:11 Changed 13 months ago by isis

Reviewer: isis

comment:12 Changed 13 months ago by arma

Diagnosis: this bug happens because Tor opens its log file before it switches to the DataDirectory, *and* because Tor calls check_private_dir(options->DataDirectory) before it opens its logs (otherwise Tor would have failed to open the file because the directory does not exist).

So when you HUP, Tor closes that original log file, and tries to open it again, but by now its cwd is its datadirectory, so now it can't open it because that (relative) directory does not exist.

Specifically, they are two parts to dropping privs, and Tor does the first part before opening its log files, but doesn't do the finish_daemon() part (which includes the chdir) until later.

comment:13 Changed 13 months ago by arma

This ticket is really related to #21975.

This current behavior is definitely a bug, since whether you are in the "all relative paths are relative to the starting cwd" camp or the "all relative paths are relative to the datadir" camp, right now this one does "both".

I think it could hang on until we do #21975 though, since not many people use RunAsDaemon and relative log file paths.

comment:14 Changed 13 months ago by nickm

Parent ID: #22101#22731
Status: needs_reviewneeds_revision

Marking this as needs_revision and child of #22731. Once #22731 is done, we can close this ticket.

comment:15 Changed 10 months ago by nickm

Resolution: wontfix
Status: needs_revisionclosed

wontfixing in favor of parent.

Note: See TracTickets for help on using tickets.