Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request elevated privileges only when needed #16

Open
ItsSim opened this issue Sep 19, 2021 · 0 comments
Open

Request elevated privileges only when needed #16

ItsSim opened this issue Sep 19, 2021 · 0 comments
Labels
critical Critical priority enhancement New feature or request feature accepted Feature has been accepted help wanted Extra attention is needed

Comments

@ItsSim
Copy link
Owner

ItsSim commented Sep 19, 2021

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:

  • When performing disk operations (using node’s fs module or fs-extra) in a protected folder (such as Program Files).
    • When downloading and extracting to a protected folder (such as Program Files).
  • When launching FreeSO and it’s installed in a protected folder (such as Program Files). FreeSO currently needs admin permissions if installed in a protected folder.

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:

  • How to determine if a FS operation is going to be performed on a protected folder (or see if fs throws an error, catch that to request privileges and redo the operation).
  • Find a way to actually request elevation, node-windows package?

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:

  • A node.js script to run an installer, if the user-selected installation folder is a protected folder like C:/Program Files
  • A node.js script for launching the game if it's located in a protected folder like C:/Program Files

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.

@ItsSim ItsSim added enhancement New feature or request help wanted Extra attention is needed labels Sep 19, 2021
@ItsSim ItsSim added the medium priority Medium priority label Sep 27, 2021
@ItsSim ItsSim added critical Critical priority and removed medium priority Medium priority labels Aug 4, 2023
@ItsSim ItsSim assigned ItsSim and unassigned ItsSim Aug 4, 2023
@ItsSim ItsSim added the feature accepted Feature has been accepted label Apr 3, 2024
@ItsSim ItsSim changed the title [Windows] Request elevated privileges only when needed [Feature] Request elevated privileges only when needed Apr 3, 2024
@ItsSim ItsSim changed the title [Feature] Request elevated privileges only when needed Request elevated privileges only when needed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical Critical priority enhancement New feature or request feature accepted Feature has been accepted help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant