one2pret / winsys

Automatically exported from code.google.com/p/winsys
Other
0 stars 0 forks source link

event_log fails to open a remote computer event log if it can't read the remote registry #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call
event_logs.event_log(r'\\{0}\Application'.format(server))
where the caller has read permission for the event log on server but not for 
the registry on server.  I have not confirmed that's the cause, but infer that 
from the general security configuration of two servers, one that works and one 
that fails. 

What is the expected output? What do you see instead?

x_registry: (53, 'RegConnectRegistry', 'The network path was not found.')

What version of the product are you using? On what operating system?
0.5.2

Please provide any additional information below.

Here's my hack workaround that doesn't take the larger design into account and 
only (and on purpose) handles this very specific error.

event_logs.py line 26 and following:
    try:
      key = registry.registry (self.REG_ROOT % self.computer).get_key (self.name)
    except registry.x_registry as reg_err_53:
      if not (hasattr(reg_err_53, 'winerror') and reg_err_53.winerror == 53 and
              hasattr(reg_err_53, 'funcname') and reg_err_53.funcname == 'RegConnectRegistry'):
        raise

Original issue reported on code.google.com by stu...@gmail.com on 27 Jul 2011 at 3:57

GoogleCodeExporter commented 9 years ago
Hmmm. Thanks for picking this up and for the workaround. I'm going to have to 
think around this a bit but I'll almost certainly end up with a variation of 
your code.

Original comment by tjgolden@gmail.com on 27 Jul 2011 at 3:18

GoogleCodeExporter commented 9 years ago
Yes, I figured you'd need to think about it from the perspective of the larger 
design.  Options I considered, without trying to understand the larger design, 
included reading the registry lazily so it only fails if you try to use those 
values, stuffing the reg_err_53.strerror into a defaultdict for the chunk of 
code below my hack that reads attributes, and saving the error to check later 
in dumped().  Having no idea where else these attributes are used if anywhere, 
I offer these ideas, some obviously bad, hoping they'll help you think through 
the right design.

Original comment by stu...@gmail.com on 27 Jul 2011 at 3:39

GoogleCodeExporter commented 9 years ago
Thanks for the ideas. I've just tested the scenario you describe and... I get 
an access denied error, which is what I'd expect. At the risk of insulting your 
intelligence, could you confirm that you definitely are using a target machine 
name which is visible as such from your source? My test case is simply a 
non-domain virtual server to which my own user has no particular access. A call 
to registry.registry (r'\\server\HKLM') returns x_access_denied as does 
event_logs.event_log (r"\\server\Application") at the RegConnectRegistry call.

Original comment by tjgolden@gmail.com on 28 Jul 2011 at 7:29

GoogleCodeExporter commented 9 years ago
I can confirm because after adding my workaround I'm able to read the event
log on the remote machine with no problem, it's just accessing the registry
remotely that fails.  Access denied is not, if I recall, error 53, so maybe
something else is going on.

Original comment by stu...@gmail.com on 29 Jul 2011 at 3:44

GoogleCodeExporter commented 9 years ago
Thanks for the input. I'll look harder...

Original comment by tjgolden@gmail.com on 29 Jul 2011 at 9:05