]> git.ipfire.org Git - oddments/fireinfo.git/commitdiff
Add resonable functions for public_id and private_id.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Nov 2010 21:31:48 +0000 (22:31 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Nov 2010 21:31:48 +0000 (22:31 +0100)
Finding a valid unique_id is still to do.

fireinfo/system.py

index 6a19d98322785e3f6a7b8c023e42deffe6fa462d..74028a62db65fef5bcd2540b843d326d416772a3 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-
+import hashlib
 import json
 import os
 import string
@@ -62,12 +62,32 @@ class System(object):
 
        @property
        def public_id(self):
-               return "0"*40
+               """
+                       This returns a globally (hopefully) ID to identify the host
+                       later (by request) in the database.
+               """
+               return hashlib.sha1(self._unique_id).hexdigest()
        
        @property
        def private_id(self):
-               return "1"*40
-       
+               """
+                       The private ID is built out of the _unique_id and used to
+                       permit a host to do changes on the database.
+
+                       No one could ever guess this without access to the host.
+               """
+               return hashlib.sha1("%s" % reversed(self._unique_id)).hexdigest()
+
+       @property
+       def _unique_id(self):
+               """
+                       This is a helper ID which is generated out of some hardware information
+                       that is considered to be constant over a PC's lifetime.
+
+                       None of the data here is ever sent to the server.
+               """
+               return "123456789" # XXX just a dummy
+
        @property
        def language(self):
                with open("/var/ipfire/main/settings", "r") as f: