简体   繁体   中英

Gaining SUDO privileges for 'child_process.exec'

I am using exec from child_process in a node application to run some shell commands.

The problem is: I need to have sudo privileges to run some commands and I am not sure how to programmatically respond to the password prompt.

I do not want the application to hang until a password is entered by the user, I want the application to enter a default password and run the commands requiring sudo using said password.

Is this possible? Ideally, I would like to do this without first logging in as su , ie: just run the application and have it work.

Please no additional libraries.

You could set the SUID on the file so that it always runs with the permissions of the file owner or GUID if you want it to run with the permissions of the group. More information can be found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM