[tor-commits] [ooni-probe/master] Check for root once at startup
art at torproject.org
art at torproject.org
Thu Jul 4 13:24:22 UTC 2013
commit af02edbe6c1495e1cda07676ca24054a32d9ae9d
Author: aagbsn <aagbsn at extc.org>
Date: Sun Jun 30 19:00:42 2013 +0200
Check for root once at startup
---
ooni/director.py | 10 +---------
ooni/oonicli.py | 11 ++++++++++-
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py
index a44ee57..2c48bb0 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -6,7 +6,7 @@ import re
from ooni import geoip
from ooni.managers import ReportEntryManager, MeasurementManager
from ooni.reporter import Report
-from ooni.utils import log, checkForRoot, pushFilenameStack
+from ooni.utils import log, pushFilenameStack
from ooni.utils.net import randomFreePort
from ooni.nettest import NetTest, getNetTestInformation
from ooni.settings import config
@@ -238,14 +238,6 @@ class Director(object):
available.
"""
from ooni.utils.txscapy import ScapyFactory, ScapySniffer
- try:
- checkForRoot()
- except errors.InsufficientPrivileges:
- log.err("Includepcap options requires root priviledges to run")
- log.err("you should run ooniprobe as root or disable the options in ooniprobe.conf")
- reactor.stop()
- sys.exit(1)
-
config.scapyFactory = ScapyFactory(config.advanced.interface)
if os.path.exists(config.reports.pcap):
diff --git a/ooni/oonicli.py b/ooni/oonicli.py
index 218ec2e..32fc762 100644
--- a/ooni/oonicli.py
+++ b/ooni/oonicli.py
@@ -17,7 +17,7 @@ from ooni.director import Director
from ooni.reporter import YAMLReporter, OONIBReporter
from ooni.nettest import NetTestLoader, MissingRequiredOption
-from ooni.utils import log
+from ooni.utils import log, checkForRoot
class Options(usage.Options):
synopsis = """%s [options] [path to test].py
@@ -109,6 +109,15 @@ def runWithDirector():
config.read_config_file()
log.start(global_options['logfile'])
+
+ if config.privacy.includepcap:
+ try:
+ checkForRoot()
+ except errors.InsufficientPrivileges:
+ log.err("Insufficient Privileges to capture packets."
+ " See ooniprobe.conf privacy.includepcap")
+ sys.exit(2)
+
# contains (test_cases, options, cmd_line_options)
test_list = []
if global_options['no-collector']:
More information about the tor-commits
mailing list