Detlef Riekenberg : faultrep/tests: Fix a test failure when the user has limited access rights.

Alexandre Julliard julliard at winehq.org
Fri Aug 2 09:53:39 CDT 2013


Module: wine
Branch: master
Commit: c1f9129d7bfa8be0cf39aa267e3d0a2f4fe96568
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c1f9129d7bfa8be0cf39aa267e3d0a2f4fe96568

Author: Detlef Riekenberg <wine.dev at web.de>
Date:   Fri Aug  2 06:01:59 2013 +0200

faultrep/tests: Fix a test failure when the user has limited access rights.

---

 dlls/faultrep/faultrep.c       |    8 ++++----
 dlls/faultrep/tests/faultrep.c |   10 +++++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/dlls/faultrep/faultrep.c b/dlls/faultrep/faultrep.c
index a05dabb..83f9027 100644
--- a/dlls/faultrep/faultrep.c
+++ b/dlls/faultrep/faultrep.c
@@ -53,14 +53,13 @@ static const WCHAR SZ_EXCLUSIONLIST_KEY[] = {
  * Wine doesn't use this data but stores it in the registry (in the same place
  * as Windows would) in case it will be useful in a future version
  *
- * According to MSDN this function should succeed even if the user has no write
- * access to HKLM. This probably means that there is no error checking.
  */
 BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName)
 {
     WCHAR *bslash;
     DWORD value = 1;
     HKEY hkey;
+    LONG res;
 
     TRACE("(%s)\n", wine_dbgstr_w(lpAppFileName));
     bslash = strrchrW(lpAppFileName, '\\');
@@ -72,13 +71,14 @@ BOOL WINAPI AddERExcludedApplicationW(LPCWSTR lpAppFileName)
         return FALSE;
     }
 
-    if (!RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey))
+    res = RegCreateKeyW(HKEY_LOCAL_MACHINE, SZ_EXCLUSIONLIST_KEY, &hkey);
+    if (!res)
     {
         RegSetValueExW(hkey, lpAppFileName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value));
         RegCloseKey(hkey);
     }
 
-    return TRUE;
+    return !res;
 }
 
 /*************************************************************************
diff --git a/dlls/faultrep/tests/faultrep.c b/dlls/faultrep/tests/faultrep.c
index dd52928..948310d 100644
--- a/dlls/faultrep/tests/faultrep.c
+++ b/dlls/faultrep/tests/faultrep.c
@@ -43,7 +43,12 @@ static void test_AddERExcludedApplicationA(void)
     HKEY hexclude = 0;
 
     /* clean state */
-    lres = RegOpenKeyExA(HKEY_LOCAL_MACHINE, regpath_root, 0, KEY_WRITE, &hroot);
+    lres = RegCreateKeyA(HKEY_LOCAL_MACHINE, regpath_root, &hroot);
+    if (lres == ERROR_ACCESS_DENIED)
+    {
+        skip("Not enough access rights\n");
+        return;
+    }
 
     if (!lres)
         lres = RegOpenKeyA(hroot, regpath_exclude, &hexclude);
@@ -61,8 +66,7 @@ static void test_AddERExcludedApplicationA(void)
     ok(!res, "got %d and 0x%x (expected FALSE)\n", res, GetLastError());
 
     SetLastError(0xdeadbeef);
-    /* access rights to HKLM or existence of the path doesn't matter
-       this function succeeded */
+    /* existence of the path doesn't matter this function succeeded */
     res = AddERExcludedApplicationA("winetest_faultrep.exe");
     ok(res, "got %d and 0x%x (expected TRUE)\n", res, GetLastError());
 




More information about the wine-cvs mailing list