[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Check permissions on logfile as well



commit bfc0a51a0b63ceb1d07812f2a7edc6a63847ea90
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Tue Sep 6 17:09:18 2016 +0200

    Check permissions on logfile as well
    
    * Handle the case where the measurement directory doesn't exist yet
---
 ooni/measurements.py | 2 ++
 ooni/utils/log.py    | 7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/ooni/measurements.py b/ooni/measurements.py
index fd722ee..294b182 100644
--- a/ooni/measurements.py
+++ b/ooni/measurements.py
@@ -128,6 +128,8 @@ def get_summary(measurement_id):
 def list_measurements(compute_size=False):
     measurements = []
     measurement_path = FilePath(config.measurements_directory)
+    if not measurement_path.exists():
+        return measurements
     for measurement_id in measurement_path.listdir():
         try:
             measurements.append(get_measurement(measurement_id, compute_size))
diff --git a/ooni/utils/log.py b/ooni/utils/log.py
index 67079e0..93e6b31 100644
--- a/ooni/utils/log.py
+++ b/ooni/utils/log.py
@@ -133,9 +133,10 @@ class OONILogger(object):
             logfile = os.path.expanduser(config.basic.logfile)
 
         log_folder = os.path.dirname(logfile)
-        if not os.access(log_folder, os.W_OK):
-            # If we don't have permissions to write to the log_folder,
-            # write to running dir.
+        if (not os.access(log_folder, os.W_OK) or
+            (os.path.exists(logfile) and not os.access(logfile, os.W_OK))):
+            # If we don't have permissions to write to the log_folder or
+            # logfile.
             log_folder = config.running_path
             logfile = os.path.join(log_folder, "ooniprobe.log")
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits