Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use `electron` based app update file which requires `sudo` permission

Tags:

sudo

electron

I want to write an app via electron, but the requirement is to update a file which requires root permission.

It's easy to achieve via cli, just like sudo vi xxx.

Is it possible to update the file via electron?

like image 853
Howard Avatar asked Mar 31 '16 12:03

Howard


1 Answers

Yes, it is possible via electron.

You can use https://github.com/jorangreef/sudo-prompt to exec a command using sudo and show a graphical OS password prompt.

You can use sudo-prompt from Electron as well as from any Node script.

It is regularly updated, has no dependencies and does not require any native compilation.

like image 129
Joran Greef Avatar answered Nov 20 '22 01:11

Joran Greef