summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2019-06-19 15:57:03 +0300
committerandreykproductengine <andreykproductengine@lindenlab.com>2019-06-19 15:57:03 +0300
commita74ea1811640f2647a1f6dd15663167dfdbe00ab (patch)
tree4928ff9fb0010674e0abf0498662986a8f2a67dd /indra/newview
parent55670eef350c9db849eab8b813ca7335fdec3435 (diff)
DRTVWR-493 LLMachineId to singleton
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappviewer.cpp2
-rw-r--r--indra/newview/llhasheduniqueid.cpp2
-rw-r--r--indra/newview/llmachineid.cpp24
-rw-r--r--indra/newview/llmachineid.h17
-rw-r--r--indra/newview/llmainlooprepeater.cpp2
-rw-r--r--indra/newview/llsechandler_basic.cpp6
6 files changed, 27 insertions, 26 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 81d0523512..7ccbbc6e10 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -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"))
diff --git a/indra/newview/llhasheduniqueid.cpp b/indra/newview/llhasheduniqueid.cpp
index 03192d3e61..eca8d0935c 100644
--- a/indra/newview/llhasheduniqueid.cpp
+++ b/indra/newview/llhasheduniqueid.cpp
@@ -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);
diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp
index b0ee8e7fcb..1420161008 100644
--- a/indra/newview/llmachineid.cpp
+++ b/indra/newview/llmachineid.cpp
@@ -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??
+LLMachineID::LLMachineID() :
+mHasStaticUniqueId(false)
+{
+ // will set mStaticUniqueId to 0
+ requestUniqueID();
+}
-S32 LLMachineID::init()
+S32 LLMachineID::requestUniqueID()
{
- memset(static_unique_id,0,sizeof(static_unique_id));
+ 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
diff --git a/indra/newview/llmachineid.h b/indra/newview/llmachineid.h
index 6ef8c36fdb..b485910eb8 100644
--- a/indra/newview/llmachineid.h
+++ b/indra/newview/llmachineid.h
@@ -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
diff --git a/indra/newview/llmainlooprepeater.cpp b/indra/newview/llmainlooprepeater.cpp
index 6736e9a950..972b1d838f 100644
--- a/indra/newview/llmainlooprepeater.cpp
+++ b/indra/newview/llmainlooprepeater.cpp
@@ -1,5 +1,5 @@
/**
- * @file llmachineid.cpp
+ * @file llmainlooprepeater.cpp
* @brief retrieves unique machine ids
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp
index 9ab9e4a1a2..63471ab865 100644
--- a/indra/newview/llsechandler_basic.cpp
+++ b/indra/newview/llsechandler_basic.cpp
@@ -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());