DRTVWR-493 LLMachineId to singleton
parent
55670eef35
commit
a74ea18116
|
|
@ -826,7 +826,7 @@ bool LLAppViewer::init()
|
|||
|
||||
LL_INFOS("InitInfo") << "LLCore::Http initialized." << LL_ENDL ;
|
||||
|
||||
LLMachineID::init();
|
||||
LLMachineID::getInstance(); //needs to be initialized before threads
|
||||
|
||||
{
|
||||
if (gSavedSettings.getBOOL("QAModeMetrics"))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ bool llHashedUniqueID(unsigned char id[MD5HEX_STR_SIZE])
|
|||
LLMD5 hashed_unique_id;
|
||||
unsigned char unique_id[MAC_ADDRESS_BYTES];
|
||||
if ( LLUUID::getNodeID(unique_id)
|
||||
|| LLMachineID::getUniqueID(unique_id, sizeof(unique_id))
|
||||
|| LLMachineID::getInstance()->getUniqueID(unique_id, sizeof(unique_id))
|
||||
)
|
||||
{
|
||||
hashed_unique_id.update(unique_id, MAC_ADDRESS_BYTES);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ using namespace std;
|
|||
#include <comdef.h>
|
||||
#include <Wbemidl.h>
|
||||
#endif
|
||||
unsigned char static_unique_id[] = {0,0,0,0,0,0};
|
||||
bool static has_static_unique_id = false;
|
||||
|
||||
#if LL_WINDOWS
|
||||
|
||||
|
|
@ -60,16 +58,22 @@ public:
|
|||
#endif //LL_WINDOWS
|
||||
|
||||
// get an unique machine id.
|
||||
// NOT THREAD SAFE - do before setting up threads.
|
||||
// NOT THREAD SAFE - do first call before setting up threads.
|
||||
// MAC Address doesn't work for Windows 7 since the first returned hardware MAC address changes with each reboot, Go figure??
|
||||
|
||||
S32 LLMachineID::init()
|
||||
LLMachineID::LLMachineID() :
|
||||
mHasStaticUniqueId(false)
|
||||
{
|
||||
memset(static_unique_id,0,sizeof(static_unique_id));
|
||||
// will set mStaticUniqueId to 0
|
||||
requestUniqueID();
|
||||
}
|
||||
|
||||
S32 LLMachineID::requestUniqueID()
|
||||
{
|
||||
memset(mStaticUniqueId, 0, sizeof(mStaticUniqueId));
|
||||
S32 ret_code = 0;
|
||||
#if LL_WINDOWS
|
||||
# pragma comment(lib, "wbemuuid.lib")
|
||||
size_t len = sizeof(static_unique_id);
|
||||
size_t len = sizeof(mStaticUniqueId);
|
||||
|
||||
// algorithm to detect BIOS serial number found at:
|
||||
// http://msdn.microsoft.com/en-us/library/aa394077%28VS.85%29.aspx
|
||||
|
|
@ -228,7 +232,7 @@ S32 LLMachineID::init()
|
|||
if (vtProp.bstrVal[j] == 0)
|
||||
break;
|
||||
|
||||
static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]);
|
||||
mStaticUniqueId[i] = (unsigned int)(mStaticUniqueId[i] + serialNumber[j]);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
|
@ -253,16 +257,16 @@ S32 LLMachineID::init()
|
|||
unsigned char * staticPtr = (unsigned char *)(&static_unique_id[0]);
|
||||
ret_code = LLUUID::getNodeID(staticPtr);
|
||||
#endif
|
||||
has_static_unique_id = true;
|
||||
mHasStaticUniqueId = true;
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len)
|
||||
{
|
||||
if (has_static_unique_id)
|
||||
if (mHasStaticUniqueId)
|
||||
{
|
||||
memcpy ( unique_id, &static_unique_id, len);
|
||||
memcpy(unique_id, &mStaticUniqueId, len);
|
||||
LL_INFOS_ONCE("AppInit") << "UniqueID: 0x";
|
||||
// Code between here and LL_ENDL is not executed unless the LL_DEBUGS
|
||||
// actually produces output
|
||||
|
|
|
|||
|
|
@ -28,23 +28,20 @@
|
|||
#define LL_LLMACHINEID_H
|
||||
|
||||
|
||||
class LLMachineID
|
||||
class LLMachineID : public LLSingleton<LLMachineID>
|
||||
{
|
||||
LLSINGLETON(LLMachineID);
|
||||
public:
|
||||
LLMachineID();
|
||||
virtual ~LLMachineID();
|
||||
static S32 getUniqueID(unsigned char *unique_id, size_t len);
|
||||
static S32 init();
|
||||
|
||||
protected:
|
||||
S32 getUniqueID(unsigned char *unique_id, size_t len);
|
||||
|
||||
private:
|
||||
S32 requestUniqueID();
|
||||
|
||||
private:
|
||||
bool mHasStaticUniqueId;
|
||||
unsigned char mStaticUniqueId[6];
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // LL_LLMACHINEID_H
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file llmachineid.cpp
|
||||
* @file llmainlooprepeater.cpp
|
||||
* @brief retrieves unique machine ids
|
||||
*
|
||||
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
|
|
|
|||
|
|
@ -1310,7 +1310,7 @@ void LLSecAPIBasicHandler::_readProtectedData()
|
|||
U8 decrypted_buffer[BUFFER_READ_SIZE];
|
||||
int decrypted_length;
|
||||
unsigned char unique_id[MAC_ADDRESS_BYTES];
|
||||
LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLMachineID::getInstance()->getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLXORCipher cipher(unique_id, sizeof(unique_id));
|
||||
|
||||
// read in the salt and key
|
||||
|
|
@ -1395,7 +1395,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
|
|||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_EncryptInit(&ctx, EVP_rc4(), salt, NULL);
|
||||
unsigned char unique_id[MAC_ADDRESS_BYTES];
|
||||
LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLMachineID::getInstance()->getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLXORCipher cipher(unique_id, sizeof(unique_id));
|
||||
cipher.encrypt(salt, STORE_SALT_SIZE);
|
||||
protected_data_stream.write((const char *)salt, STORE_SALT_SIZE);
|
||||
|
|
@ -1639,7 +1639,7 @@ std::string LLSecAPIBasicHandler::_legacyLoadPassword()
|
|||
|
||||
// Decipher with MAC address
|
||||
unsigned char unique_id[MAC_ADDRESS_BYTES];
|
||||
LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLMachineID::getInstance()->getUniqueID(unique_id, sizeof(unique_id));
|
||||
LLXORCipher cipher(unique_id, sizeof(unique_id));
|
||||
cipher.decrypt(&buffer[0], buffer.size());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue