PROFILE_VERSION = 0
SYS_CLASS_DMI = "/sys/class/dmi/id"
+SECRET_ID_FILE = "/etc/fireinfo-id"
class Singleton(type):
def __init__(cls, name, bases, dict):
"public_id" : self.public_id,
"private_id" : self.private_id,
- # XXX just for testing:
- "secret_id" : self._unique_id,
-
# Actual profile data
"profile" : p,
}
This returns a globally (hopefully) ID to identify the host
later (by request) in the database.
"""
- public_id = self._unique_id
+ public_id = self.secret_id
if not public_id:
return "0" * 40
No one could ever guess this without access to the host.
"""
private_id = ""
- for i in reversed(self._unique_id):
+ for i in reversed(self.secret_id):
private_id += i
if not private_id:
return hashlib.sha1(private_id).hexdigest()
+ @property
+ def secret_id(self):
+ """
+ Read a "secret" ID from a file if available
+ or calculate it from the hardware.
+ """
+ if os.path.exists(SECRET_ID_FILE):
+ return read_from_file(SECRET_ID_FILE)
+
+ return hashlib.sha1(self._unique_id).hexdigest()
+
@property
def _unique_id(self):
"""