Module: wine Branch: master Commit: a2545727fea4c0e91dd67aa5000ad67645d6ed62 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a2545727fea4c0e91dd67aa500...
Author: Hans Leidekker hans@codeweavers.com Date: Thu Nov 17 13:07:59 2016 -0600
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
---
dlls/wbemprox/builtin.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index b0f5faa..cf9ae5c 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -22,6 +22,7 @@
#include "config.h" #include <stdarg.h> +#include <fcntl.h> #ifdef HAVE_UNISTD_H # include <unistd.h> #endif @@ -1346,6 +1347,33 @@ static WCHAR *get_compsysproduct_uuid(void) 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 ); }