Skip to content

Commit

Permalink
Properly expand the home directory to that of the user running oonipr…
Browse files Browse the repository at this point in the history
…obe.

Previously when running ooniprobe under sudo you would not get the correct home
directory because $HOME was set to that of the user running sudo.
  • Loading branch information
hellais committed Feb 5, 2014
1 parent 7a132ea commit bd56669
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ooni/settings.py
@@ -1,6 +1,8 @@
import os
import sys
import yaml
import getpass

from shutil import copyfile
from os.path import abspath, expanduser

Expand All @@ -11,6 +13,7 @@

class OConfig(object):
def __init__(self):
self.current_user = getpass.getuser()
self.global_options = {}
self.reports = Storage()
self.scapyFactory = None
Expand Down Expand Up @@ -39,7 +42,7 @@ def set_paths(self):

self.nettest_directory = abspath(os.path.join(__file__, '..', 'nettests'))

self.ooni_home = os.path.join(expanduser('~'), '.ooni')
self.ooni_home = os.path.join(expanduser('~'+self.current_user), '.ooni')
self.inputs_directory = os.path.join(self.ooni_home, 'inputs')
self.decks_directory = os.path.join(self.ooni_home, 'decks')
self.reports_directory = os.path.join(self.ooni_home, 'reports')
Expand Down

0 comments on commit bd56669

Please sign in to comment.