I’m developing an Electron app that periodically executes a C file requiring elevated privileges on macOS. I need to prompt the user for their sudo password once when the app starts and use these elevated privileges for subsequent commands without repeatedly asking for the password.
I’ve tried using packages like sudo-prompt and electron-sudo, but they didn’t solve the issue. The only workaround that partially works is storing and reusing the password for every command, which is not secure.
How can I securely obtain and reuse elevated privileges for my Electron app? How do other applications that require elevated privileges handle this scenario? Any insights or code examples would be greatly appreciated.
Details:
OS: macOS
Framework: Electron
Requirements: Prompt for sudo password once and reuse privileges securely for periodic command execution
What I’ve Tried:
sudo-prompt
electron-sudo
Storing and reusing the password (not secure)
Objective:
Securely prompt for the sudo password once and maintain elevated privileges throughout the app’s lifecycle.
xeed xendrome is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.