0

The question is related to Running command from Node.js with sudo (No working answer have been ever given).

A program is currently executed that way: sudo node xx.js This can't be changed, need the 80 port.

Now, I'm trying to use spawn and execute something without sudo, I've attempted to use uid: and guid:, however it doesn't actually work, it's still using sudo permissions.

How can I use spawn (or exec) - or even a Worker without sudo?

spawn(path,[], { uid: 1000, gid: 1000}); => This does not work (it should do a spawn with the right uid, but it doesnt), 1000 is the right one, checked by using id in terminal (root is 0, my user is 1000)

Thank you

ElixirBolt
  • 21
  • 3
  • Without "sudo" you mean, the child process should not be have root premissions/should run under a "nobody" user? Add a minimal working example. – Marc Aug 26 '21 at 10:08
  • Yes, exactly. I'm having a hard time figuring out a working example except putting the uid: guid: as I did in my mini sample. You said it right, the child process (or even Worker could be okay) should not have root permissions. It should run under the uid/guid that I've specified. – ElixirBolt Aug 27 '21 at 02:28
  • Try spawning the `su` command then tell `su` to execute your command. – slebetman Aug 28 '21 at 04:34
  • But su would simply upgrade my privileges no? I want to downgrade my privileges – ElixirBolt Sep 02 '21 at 08:46

0 Answers0