theendsofinvention / esst

MIT License
4 stars 0 forks source link

Manage PermissionError when installed in ProgramFiles #11

Open theendsofinvention opened 6 years ago

theendsofinvention commented 6 years ago

https://sentry.io/etcher/esst/issues/687778677/

PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Eagle Dynamics\\DCS World\\MissionEditor\\MissionEditor.lua'
(10 additional frame(s) were not displayed)
...
  File "esst\dcs\mission_editor_lua.py", line 84, in inject_mission_editor_code
    core.FS.mission_editor_lua_file.write_text(output, encoding='utf8')
  File "pathlib.py", line 1213, in write_text
  File "pathlib.py", line 1181, in open
  File "pathlib.py", line 1035, in _opener
  File "pathlib.py", line 387, in wrapped

PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Eagle Dynamics\\DCS World\\MissionEditor\\MissionEditor.lua'
theendsofinvention commented 6 years ago

Sentry issue: ESST-3K

57Dojo commented 6 years ago

This is probably caused by a Windows security feature that prevents programs running as Administrator (such as ESST) from affecting Program Files. This is not unique to ESST. The only known way to solve is to A) enable ESST to run without admin permissions, or B) give the logged in user the rights to the Program FIles directory (my preferred method).

(Yes, I understand it's counter-intuitive to think of a program running with admin permissions like ESST to not have permission to a directory, but that is an intentional security feature design since Windows 8)

theendsofinvention commented 6 years ago

I'm unaware of the way Win8/Win10 manage their UAC.

My idea was to implement the following:

  1. Verify that ESST has read/write permissions the all the directories it plans on using;
  2. Catch permission errors and notify the user accordingly instead of throwing an ugly low-level exception to their face.