Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
6b7ef8c8
Commit
6b7ef8c8
authored
4 years ago
by
Mnikolenko ProductEngine
Browse files
Options
Downloads
Patches
Plain Diff
SL-14481 Use serial number as unique key on Mac
parent
c9879569
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/newview/llmachineid.cpp
+77
-5
77 additions, 5 deletions
indra/newview/llmachineid.cpp
with
77 additions
and
5 deletions
indra/newview/llmachineid.cpp
+
77
−
5
View file @
6b7ef8c8
...
...
@@ -33,6 +33,9 @@
using
namespace
std
;
#include
<comdef.h>
#include
<Wbemidl.h>
#elif LL_DARWIN
#include
<CoreFoundation/CoreFoundation.h>
#include
<IOKit/IOKitLib.h>
#endif
unsigned
char
static_unique_id
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
};
unsigned
char
static_legacy_id
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
};
...
...
@@ -344,8 +347,51 @@ bool LLWMIMethods::getGenericSerialNumber(const BSTR &select, const LPCWSTR &var
return
found
;
}
#elif LL_DARWIN
bool
getSerialNumber
(
unsigned
char
*
unique_id
,
size_t
len
)
{
CFStringRef
serial_cf_str
=
NULL
;
io_service_t
platformExpert
=
IOServiceGetMatchingService
(
kIOMasterPortDefault
,
IOServiceMatching
(
"IOPlatformExpertDevice"
));
if
(
platformExpert
)
{
serial_cf_str
=
(
CFStringRef
)
IORegistryEntryCreateCFProperty
(
platformExpert
,
CFSTR
(
kIOPlatformSerialNumberKey
),
kCFAllocatorDefault
,
0
);
IOObjectRelease
(
platformExpert
);
}
if
(
serial_cf_str
)
{
char
buffer
[
64
]
=
{
0
};
std
::
string
serial_str
(
""
);
if
(
CFStringGetCString
(
serial_cf_str
,
buffer
,
64
,
kCFStringEncodingUTF8
))
{
serial_str
=
buffer
;
}
#endif //LL_WINDOWS
S32
serial_size
=
serial_str
.
size
();
if
(
serial_str
.
size
()
>
0
)
{
S32
j
=
0
;
while
(
j
<
serial_size
)
{
for
(
S32
i
=
0
;
i
<
len
;
i
++
)
{
if
(
j
>=
serial_size
)
break
;
unique_id
[
i
]
=
(
unsigned
int
)(
unique_id
[
i
]
+
serial_str
[
j
]);
j
++
;
}
}
return
true
;
}
}
return
false
;
}
#endif
// get an unique machine id.
// NOT THREAD SAFE - do before setting up threads.
...
...
@@ -394,11 +440,37 @@ S32 LLMachineID::init()
}
ret_code
=
0
;
#el
se
unsigned
char
*
staticPtr
=
(
unsigned
char
*
)(
&
static_unique_id
[
0
]);
ret_code
=
LLUUID
::
getNodeID
(
staticPtr
);
#el
if LL_DARWIN
if
(
getSerialNumber
(
static_unique_id
,
len
))
{
has_static_unique_id
=
true
;
has_static_legacy_id
=
false
;
LL_DEBUGS
(
"AppInit"
)
<<
"Using Serial number as unique id"
<<
LL_ENDL
;
}
{
unsigned
char
*
staticPtr
=
(
unsigned
char
*
)(
&
static_legacy_id
[
0
]);
ret_code
=
LLUUID
::
getNodeID
(
staticPtr
);
has_static_legacy_id
=
true
;
}
// Fallback to legacy
if
(
!
has_static_unique_id
)
{
if
(
has_static_legacy_id
)
{
memcpy
(
static_unique_id
,
&
static_legacy_id
,
len
);
// Since ids are identical, mark legacy as not present
// to not cause retry's in sechandler
has_static_legacy_id
=
false
;
has_static_unique_id
=
true
;
LL_DEBUGS
(
"AppInit"
)
<<
"Using legacy serial"
<<
LL_ENDL
;
}
}
#else
unsigned
char
*
staticPtr
=
(
unsigned
char
*
)(
&
static_legacy_id
[
0
]);
ret_code
=
LLUUID
::
getNodeID
(
staticPtr
);
has_static_unique_id
=
true
;
has_static_legacy_id
=
false
;
#endif
LL_INFOS
(
"AppInit"
)
<<
"UniqueID: 0x"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment