ItsSim / fsolauncher

Official FreeSO Launcher made with Electron
https://beta.freeso.org
Mozilla Public License 2.0
18 stars 9 forks source link

[Feature] Request elevated privileges only when needed #16

Open ItsSim opened 3 years ago

ItsSim commented 3 years ago

The launcher on Windows currently requests elevated privileges upon running the program.

It would be better user experience and more secure to only request elevated privileges for the operations that need it. A few examples:

On macOS the launcher does not require elevation immediately, which is a better approach. It only requests elevated privileges when installing mono or SDL, so no changes would be necessary for macOS.

Need to figure out:

Update 1 The way to do this would be to use sudo-prompt (which is already being used on macOS for mono and SDL installations, it works for Windows too). Code that requires admin privileges would need to be refactored to be able to be run "standalone", since sudo-prompt only works by executing command line scripts.

Two node.js command line script files would need to be created:

Related code would need to be refactored to be able to be run as sudo_prompt.exec('node script.js <args>'), as standalone routines with input arguments and stdout logs reporting progress that will be handled in the main launcher application, and proper handling of error exit codes.

By default, the launcher will run without admin privileges and will use sudo-prompt to elevate in these two cases.

The FSOLauncher.ini config file location will also have to be changed to a non-admin-privileges location, like %APPDATA%. Currently, it is created wherever the launcher itself is installed, in the same folder. So if the launcher was installed in Program Files, it wouldn't be able to read the config file.