wbemprox: Return the machine ID for Win32_ComputerSystemProduct.UUID on Linux.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2016-11-17 13:07:59 -06:00 committed by Alexandre Julliard
parent 9842bf333a
commit a2545727fe
1 changed files with 28 additions and 0 deletions

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <stdarg.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@ -1345,6 +1346,33 @@ static WCHAR *get_compsysproduct_uuid(void)
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15] );
return ret;
}
#endif
#ifdef __linux__
int file;
if ((file = open( "/var/lib/dbus/machine-id", O_RDONLY )) != -1)
{
unsigned char buf[32];
if (read( file, buf, sizeof(buf) ) == sizeof(buf))
{
unsigned int i, j;
WCHAR *ret, *p;
close( file );
if (!(p = ret = heap_alloc( 37 * sizeof(WCHAR) ))) return NULL;
for (i = 0, j = 0; i < 8; i++) p[i] = toupperW( buf[j++] );
p[8] = '-';
for (i = 9; i < 13; i++) p[i] = toupperW( buf[j++] );
p[13] = '-';
for (i = 14; i < 18; i++) p[i] = toupperW( buf[j++] );
p[18] = '-';
for (i = 19; i < 23; i++) p[i] = toupperW( buf[j++] );
p[23] = '-';
for (i = 24; i < 36; i++) p[i] = toupperW( buf[j++] );
ret[i] = 0;
return ret;
}
close( file );
}
#endif
return heap_strdupW( compsysproduct_uuidW );
}