[tor-commits] [ooni-probe/master] * Forgot to remove the old ValueChecker. Made it dead.

isis at torproject.org isis at torproject.org
Thu Nov 1 12:14:01 UTC 2012


commit fe055521bfd05c6fa0d262d48f8154ca249f9c0b
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed Oct 31 16:33:32 2012 +0000

    * Forgot to remove the old ValueChecker. Made it dead.
---
 ooni/utils/config.py |   66 --------------------------------------------------
 1 files changed, 0 insertions(+), 66 deletions(-)

diff --git a/ooni/utils/config.py b/ooni/utils/config.py
index e429ef6..a5b32f8 100644
--- a/ooni/utils/config.py
+++ b/ooni/utils/config.py
@@ -53,69 +53,3 @@ class Config(Storage):
             self._cfgparser.write(cfgfile)
         finally:
             cfgfile.close()
-
-class ValueChecker(object):
-    """
-    A class for general purpose value checks on commandline parameters
-    passed to subclasses of :class:`twisted.python.usage.Options`.
-    """
-    def __init__(self, coerce_doc=None):
-        self.coerce_doc = coerce_doc
-
-    def port_check(self, port, range_min=1024, range_max=65535):
-        """
-        Check that given ports are in the allowed range for an unprivileged
-        user.
-
-        :param port:
-            The port to check.
-        :param range_min:
-            The minimum allowable port number.
-        :param range_max:
-            The minimum allowable port number.
-        :param coerce_doc:
-            The documentation string to show in the optParameters menu, see
-            :class:`twisted.python.usage.Options`.
-        """
-        if self.coerce_doc is not None:
-            coerceDoc = self.coerce_doc
-
-        assert type(port) is int
-        if port not in range(range_min, range_max):
-            raise ValueError("Port out of range")
-            log.err()
-
-    @staticmethod
-    def uid_check(error_message):
-        """
-        Check that we're not root. If we are, setuid(1000) to normal user if
-        we're running on a posix-based system, and if we're on Windows just
-        tell the user that we can't be run as root with the specified options
-        and then exit.
-
-        :param error_message:
-            The string to log as an error message when the uid check fails.
-        """
-        uid, gid = os.getuid(), os.getgid()
-        if uid == 0 and gid == 0:
-            log.msg(error_message)
-        if os.name == 'posix':
-            log.msg("Dropping privileges to normal user...")
-            os.setgid(1000)
-            os.setuid(1000)
-        else:
-            sys.exit(0)
-
-    @staticmethod
-    def dir_check(d):
-        """Check that the given directory exists."""
-        if not os.path.isdir(d):
-            raise ValueError("%s doesn't exist, or has wrong permissions" 
-                             % d)
-
-    @staticmethod
-    def file_check(f):
-        """Check that the given file exists."""
-        if not os.path.isfile(f):
-            raise ValueError("%s does not exist, or has wrong permissions" 
-                             % f)





More information about the tor-commits mailing list