Skip to content

Commit

Permalink
[FIX] windows ctrl-c from cmd as a non admin
Browse files Browse the repository at this point in the history
return False when calling is_running_as_nt_service from a non adminstrator
account.
  • Loading branch information
antonylesuisse committed Nov 18, 2014
1 parent aa9eec3 commit fb97948
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion openerp/service/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import resource
else:
# Windows shim
signal.SIGHUP = 0
signal.SIGHUP = -1

# Optional process names for workers
try:
Expand Down
11 changes: 7 additions & 4 deletions openerp/tools/osutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ def close_srv(srv):
finally:
ws.CloseServiceHandle(srv)

with close_srv(ws.OpenSCManager(None, None, ws.SC_MANAGER_ALL_ACCESS)) as hscm:
with close_srv(wsu.SmartOpenService(hscm, nt_service_name, ws.SERVICE_ALL_ACCESS)) as hs:
info = ws.QueryServiceStatusEx(hs)
return info['ProcessId'] == getppid()
try:
with close_srv(ws.OpenSCManager(None, None, ws.SC_MANAGER_ALL_ACCESS)) as hscm:
with close_srv(wsu.SmartOpenService(hscm, nt_service_name, ws.SERVICE_ALL_ACCESS)) as hs:
info = ws.QueryServiceStatusEx(hs)
return info['ProcessId'] == getppid()
except Exception:
return False

if __name__ == '__main__':
from pprint import pprint as pp
Expand Down

0 comments on commit fb97948

Please sign in to comment.