0

this is my code:

    var vlc = spawn("cvlc", [file], {uid:1000,gid:1000});

The program in node is executed through an instance of forever launched by root user. As cvlc does not permit to be executed as root I need it to be executed as normal user.

This is the way node.js explains how to do it: http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options but does not work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mario
  • 1,841
  • 4
  • 16
  • 23
  • http://stackoverflow.com/questions/6905697/how-to-run-script-as-another-user-without-password – Chris Dec 27 '13 at 18:55
  • How I adapt it to the structure of spawn? I mean, spawn("su",[-c "cvlc file" ',"1000"]) does not work – Mario Dec 27 '13 at 19:17

1 Answers1

-2

Maybe try

var vlc = spawn("su -c cvlc -s /bin/sh otheruser"....)

The command string is just a string, I have no idea if the spawn function will try to parse it or not, or straight up fail. I'm just trying to give you something to try, so give it a shot.

Chris
  • 1,611
  • 12
  • 11
  • Oh, use exec instead of spawn. http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback – Chris Dec 27 '13 at 19:32
  • I've tried and the stderr is : "su: must be run from a terminal" – Mario Dec 27 '13 at 20:12