From: Michael Tremer Date: Tue, 23 Nov 2010 21:31:48 +0000 (+0100) Subject: Add resonable functions for public_id and private_id. X-Git-Tag: v0.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31a30328cfd7824580ae63c529266593251f8877;p=oddments%2Ffireinfo.git Add resonable functions for public_id and private_id. Finding a valid unique_id is still to do. --- diff --git a/fireinfo/system.py b/fireinfo/system.py index 6a19d98..74028a6 100644 --- a/fireinfo/system.py +++ b/fireinfo/system.py @@ -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: