Opened 5 years ago

Closed 5 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 5 years ago.
patch1 (2.5 KB) - added by Abhishek Kumar Singh 5 years ago.
patch2 (2.5 KB) - added by Abhishek Kumar Singh 5 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by atagar

Keywords: easy added

Changed 5 years ago by Abhishek Kumar Singh

Attachment: patch added

comment:2 Changed 5 years ago by Abhishek Kumar Singh

Status: newneeds_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 Changed 5 years ago by atagar

Status: needs_reviewneeds_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 5 years ago by Abhishek Kumar Singh

Attachment: patch1 added

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

Please review attachment patch1.

comment:5 Changed 5 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 5 years ago by Abhishek Kumar Singh

Attachment: patch2 added

comment:6 in reply to:  5 Changed 5 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 5 years ago by atagar

Resolution: fixed
Status: needs_revisionclosed
Note: See TracTickets for help on using tickets.