Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/syscall/windows/registry: TestWalkFullRegistry fails #13500

Closed
mattn opened this issue Dec 5, 2015 · 5 comments
Closed

internal/syscall/windows/registry: TestWalkFullRegistry fails #13500

mattn opened this issue Dec 5, 2015 · 5 comments

Comments

@mattn
Copy link
Member

mattn commented Dec 5, 2015

c:\dev\go\src\internal\syscall\windows\registry>go test
--- FAIL: TestWalkFullRegistry (10.73s)
        registry_test.go:585: opening sub-keys btmshell of CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Intel\Bluetooth failed: The system cannot find the file specified.
FAIL
exit status 1
FAIL    internal/syscall/windows/registry       10.968s

I don't make sure but this seems that this key is guarded on windows.

#include <windows.h>
#include <stdio.h>

int
main(int argc, char* argv[]) {
    HKEY subkey;
    printf("%d\n", RegOpenKeyEx(HKEY_CLASSES_ROOT, "VirtualStore\\MACHINE\\SOFTWARE\\Intel\\Bluetooth\\btmshell", 0, KEY_ALL_ACCESS, &subkey));
    return 0;
}

for example this return 2. Eventhough, I run this on administrator's privileges. But return 2.

/cc @alexbrainman

@mattn mattn changed the title Test fail on internal/syscall/windows/registry Test fail on internal/syscall/windows/registry (RegOpenKeyEx) Dec 5, 2015
@ianlancetaylor ianlancetaylor changed the title Test fail on internal/syscall/windows/registry (RegOpenKeyEx) build: Test fail on internal/syscall/windows/registry (RegOpenKeyEx) Dec 5, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Dec 5, 2015
@ianlancetaylor ianlancetaylor changed the title build: Test fail on internal/syscall/windows/registry (RegOpenKeyEx) build: internal/syscal/windows/registry TestWalkFullRegistry fails Dec 5, 2015
@ianlancetaylor ianlancetaylor changed the title build: internal/syscal/windows/registry TestWalkFullRegistry fails build: internal/syscall/windows/registry TestWalkFullRegistry fails Dec 5, 2015
@rsc rsc changed the title build: internal/syscall/windows/registry TestWalkFullRegistry fails internal/syscall/windows/registry: TestWalkFullRegistry fails Dec 5, 2015
@rsc
Copy link
Contributor

rsc commented Dec 5, 2015

@mattn, what version of Windows are you using?

@mattn
Copy link
Member Author

mattn commented Dec 6, 2015

Windows10 64bit

On 12/6/15, Russ Cox notifications@github.com wrote:

@mattn, what version of Windows are you using?


Reply to this email directly or view it on GitHub:
#13500 (comment)

  • Yasuhiro Matsumoto

@alexbrainman
Copy link
Member

I think this works as expected. Your C program's output is the same as Go - it returns ERROR_FILE_NOT_FOUND.

I don't know why the RegOpenKeyEx fails on your computer. But I have seen all sorts of errors when reading all registry keys of various computers. People run all sorts of programs they download from Internet - buggy and shifty. These programs are free to do whatever they like with your registry - they have all your rights (more often then not administrator rights).

So I do not consider failing TestWalkFullRegistry to be a problem. I have added the test while I was developing package functionality, and left it in because it is helpful sometimes to debug things. But it is only running during "go test -short", so we ignore any registry inconsistencies.

Please, reopen if you disagree.

Alex

@mattn
Copy link
Member Author

mattn commented Dec 6, 2015

I do not have a strong opinion. It's a mental issue that all of the test is not passed. Also I am guessing that it is enough that you don't need to enumerate all of the registry.

@mattn
Copy link
Member Author

mattn commented Dec 21, 2015

For the memo or knowledge. There are another problem to run this test case on non-clean environment. This is not objection to current tests.

1. CLASSES_ROOT\VirtualStore\ require UAC to read

So should be ignored.

diff --git a/src/internal/syscall/windows/registry/registry_test.go b/src/internal/syscall/windows/registry/registry_test.go
index f63248c..564a126 100644
--- a/src/internal/syscall/windows/registry/registry_test.go
+++ b/src/internal/syscall/windows/registry/registry_test.go
@@ -10,6 +10,7 @@ import (
    "bytes"
    "crypto/rand"
    "os"
+   "strings"
    "syscall"
    "testing"
    "unsafe"
@@ -578,7 +579,7 @@ func walkKey(t *testing.T, k registry.Key, kname string) {
        func() {
            subk, err := registry.OpenKey(k, name, registry.ENUMERATE_SUB_KEYS|registry.QUERY_VALUE)
            if err != nil {
-               if err == syscall.ERROR_ACCESS_DENIED {
+               if err == syscall.ERROR_ACCESS_DENIED || strings.HasPrefix(kname, `CLASSES_ROOT\VirtualStore\`) {
                    // ignore error, if we are not allowed to access this key
                    return
                }

2. There are some broken registry values.

One of example, HKEY_CURRENT_USER\Software\PostgreSQL\StackBuilder

Those values seems to be stored as wide characters.

@golang golang locked and limited conversation to collaborators Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants