Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | #! /usr/bin/env python |
michael@0 | 2 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | import os |
michael@0 | 8 | import sys |
michael@0 | 9 | |
michael@0 | 10 | # set the cuddlefish "root directory" for this process if it's not already |
michael@0 | 11 | # set in the environment |
michael@0 | 12 | cuddlefish_root = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) |
michael@0 | 13 | |
michael@0 | 14 | if 'CUDDLEFISH_ROOT' not in os.environ: |
michael@0 | 15 | os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root |
michael@0 | 16 | |
michael@0 | 17 | # add our own python-lib path to the python module search path. |
michael@0 | 18 | python_lib_dir = os.path.join(cuddlefish_root, "python-lib") |
michael@0 | 19 | if python_lib_dir not in sys.path: |
michael@0 | 20 | sys.path.insert(0, python_lib_dir) |
michael@0 | 21 | |
michael@0 | 22 | # now export to env so sub-processes get it too |
michael@0 | 23 | if 'PYTHONPATH' not in os.environ: |
michael@0 | 24 | os.environ['PYTHONPATH'] = python_lib_dir |
michael@0 | 25 | elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep): |
michael@0 | 26 | paths = os.environ['PYTHONPATH'].split(os.pathsep) |
michael@0 | 27 | paths.insert(0, python_lib_dir) |
michael@0 | 28 | os.environ['PYTHONPATH'] = os.pathsep.join(paths) |
michael@0 | 29 | |
michael@0 | 30 | import cuddlefish |
michael@0 | 31 | |
michael@0 | 32 | if __name__ == '__main__': |
michael@0 | 33 | cuddlefish.run() |