1

I am spawning a child process with root privileges in my Electron app for macos. Things are working fine but app is asking for root password on command line instead of user interface.

var cProcess = require('child_process');
var terminal = cProcess.spawn('sudo',['bash']);
terminal.stdin.write('rm /private/var/log/wifi.log');

I want a dialogue box for asking password from user instead. I found cocoasudo that can be helpful and it seems that it can be used with Electron from this thread. But I could not figure out How...

There is another question with similar problem, but it is not helpful in my case. Also a npm package exist but not working.

Nargis
  • 739
  • 7
  • 30
  • Why are you spawning a full shell (with root privileges!) instead of just running `rm` with `sudo`? – chepner Mar 01 '19 at 16:27
  • @chepner I need to run such commands throughout my application. At multiple times. Please check this question for detail: https://stackoverflow.com/questions/54652002/how-can-i-take-persistent-permissions-in-electron-app – Nargis Mar 01 '19 at 16:32

0 Answers0