views:

34

answers:

1

My service program executes another instance of itself with, essentially, CreateProcess(GetCommandLine()). The child process then uses OpenProcess to get a handle to its parent process (so it can detect when the parent has stopped running). For some customers, OpenProcess fails with ERROR_ACCESS_DENIED. I'm trying to determine the reason and reproduce the circumstances for in-house testing.

I want something I can send to customers (either a program, or instructions for using programs that are already commonly installed on Windows servers) for them to run and generate a report that includes what account the service runs as and what privileges that account and its groups have been granted or denied. How can I collect that information from customers?

A: 

Getting the account name is easy -- GetUserName. Getting the rights assigned to that account is a bit more work. If memory serves, the sequence runs something like:

GetKernelObjectSecurity(Current_oject, &security_descriptor)
GetSecurityDescriptorDacl(security_descriptor, &dacl)
GetEffectiveRightsFromAcl(dacl, user_name, &rights)

You might prefer to use GetExplicitEntriesFromAcl for that last step. There is one problem with all this: if they've restricted the user too much, some (or all) of it might fail as well.

Jerry Coffin
I might be able to work with this. But what kernel object would I pass to GetKernelObjectSecurity? I'm guessing GetCurrentProcess, since I want to know what the current process is allowed to do. MSDN says I need READ_CONTROL permission in order to call this function, but that shouldn't be an issue since the process is requesting information about itself, right?
Rob Kennedy
Yes, you'd want the current process handle (I think). Yes, I think you'll almost always have permission to view that, but it's hard to say -- it's *probably* possible to set up some permissions to prevent even that.
Jerry Coffin