Opened 5 years ago

Closed 4 years ago

#7926 closed defect (fixed)

Avoid static /tmp usage

Reported by: atagar Owned by: atagar
Priority: Low Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords: testing easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Stem's tests have at least a couple places where it uses a static /tmp location...

  • The RUN_SOCKET target uses '/tmp/stem_integ/socket' as the control socket.
  • The process integ tests use '/tmp/stem_integ' as tor's data directory.

We should use the tempfile module to a pick dynamic testing location instead. Issue reported by Dererk.

Child Tickets

Attachments (3)

patch (903 bytes) - added by Abhishek Kumar Singh 4 years ago.
patch1 (2.5 KB) - added by Abhishek Kumar Singh 4 years ago.
patch2 (2.5 KB) - added by Abhishek Kumar Singh 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by atagar

  • Keywords easy added

Changed 4 years ago by Abhishek Kumar Singh

comment:2 Changed 4 years ago by Abhishek Kumar Singh

  • Status changed from new to needs_review

From http://docs.python.org/2/library/tempfile.html
tempfile.mkdtemp() - "Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID."

comment:3 follow-up: Changed 4 years ago by atagar

  • Status changed from needs_review to needs_revision

Hi Abhishek. mkdtemp() is to make a temporary directory so the usage in test/integ/process.py is correct, but CONTROL_SOCKET_PATH is a file so that'll cause problems. If you run "run_tests.py --integ --target RUN_SOCKET" then I suspect that you'll encounter an issue.

For test/integ/process.py it would also be nice if we cleaned up the temporary resource after those tests have completed, otherwise each test run will make a new temporary directory.

Changed 4 years ago by Abhishek Kumar Singh

comment:4 in reply to: ↑ 3 Changed 4 years ago by Abhishek Kumar Singh

Please review attachment patch1.

comment:5 follow-up: Changed 4 years ago by atagar

Hi Abhishek. Python conventions say that global constants are in all capital letters (like DATA_DIRECTORY), and instance variables are lowercase. Please swap it over to self.data_directory.

Have you tested this with 'run_tests.py --integ --target RUN_SOCKET'?

Changed 4 years ago by Abhishek Kumar Singh

comment:6 in reply to: ↑ 5 Changed 4 years ago by Abhishek Kumar Singh

Done.Please review patch2

Have you tested this with 'run_tests.py --integ --target RUN_SOCKET'?

Yes I have, it passed well except for tests I reported yesterday in ticket https://trac.torproject.org/projects/tor/ticket/8157 but that's not related with it so the changes works fine.

comment:7 Changed 4 years ago by atagar

  • Resolution set to fixed
  • Status changed from needs_revision to closed
Note: See TracTickets for help on using tickets.