boost::uuids::uuid repo::core::RepoTranscoderString::stringToUUID( const std::string text, const std::string suffix) { boost::uuids::uuid uuid; if (text.empty()) uuid = boost::uuids::random_generator()(); else { try { boost::uuids::string_generator gen; // if ((text.find("{")) == std::string::npos) if (text.substr(0,1) != "{") uuid = gen("{" + text + "}"); else uuid = gen(text); } catch (std::runtime_error e) { // uniformly distributed hash boost::hash<std::string> string_hash; std::string hashedUUID; std::stringstream str; str << string_hash(text); str >> hashedUUID; // uuid: 8 + 4 + 4 + 4 + 12 = 32 // pad with zero, leave last places empty for suffix while (hashedUUID.size() < 32 - suffix.size()) hashedUUID.append("0"); hashedUUID.append(suffix); uuid = stringToUUID(hashedUUID, suffix); } } return uuid; }
static void setupEfiGetOverrideConfig( void ) { const char *value; int len; int i; unsigned char uuid[UUID_LEN]; if (!getValueForKey(kSMBIOS, &value, &len, &bootInfo->bootConfig)) { value = "/Extra/smbios.plist"; } if (loadConfigFile(value, &bootInfo->smbiosConfig) == -1) { verbose("No SMBIOS replacement found\n"); } if (getValueForKey("SMUUID", &value, &len, &bootInfo->smbiosConfig) && value != NULL && stringToUUID(value, uuid) == 0) { verbose("Using SMUUID='%s' from smbios.plist as System-ID\n", value); memcpy(SystemID, uuid, UUID_LEN); } else if (getValueForKey(kSystemID, &value, &len, &bootInfo->bootConfig) && value != NULL && value[0] != 'N' && value[0] != 'n' && stringToUUID(value, uuid) == 0) { verbose("Using SystemID='%s' from com.apple.Boot.plist as System-ID\n", value); memcpy(SystemID, uuid, UUID_LEN); } else if (getSMBIOSUUID(uuid)) { verbose("Using original SMBIOS UUID='%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x' as System-ID\n", uuid[0],uuid[1],uuid[2],uuid[3],uuid[4],uuid[5],uuid[6],uuid[7], uuid[8],uuid[9],uuid[10],uuid[11],uuid[12],uuid[13],uuid[14],uuid[15]); memcpy(SystemID, uuid, UUID_LEN); } else { verbose("Using builtin default UUID as System-ID\n"); } if (getValueForKey("SMserial", &value, &len, &bootInfo->smbiosConfig)) { if (len < MAX_SERIAL_LEN) { for (i=0; i<len; i++) { SystemSerial[i] = value[i]; } SystemSerial[len] = '\0'; SystemSerialLength = (len + 1) * 2; } } if (getValueForKey("SMproductname", &value, &len, &bootInfo->smbiosConfig)) { if (len < MAX_MODEL_LEN) { for (i=0; i<len; i++) { Model[i] = value[i]; } Model[len] = '\0'; ModelLength = (len + 1) * 2; } } }